2

I've made a table with three fields: KUNNR, NAME_1 and Z_CLASS. KUNNR has KUNNR as data element, NAME_1 has NAME1_GP and Z_CLASS has a data element that I made with 3 values (1, 2 or 3). I've made the table maintenance generator and put some data in with SM30.

Now, I need to make the name of the client show automatically (NAME_1) when I enter a client number (KUNNR) and press enter; and need to make sure that the Z_CLASS is filled and not leaved in blank.

I don't really know how to search for the solution because I'm new to SAP. Thank you.

PROCESS BEFORE OUTPUT.
 MODULE LISTE_INITIALISIEREN.
 LOOP AT EXTRACT WITH CONTROL
  TCTRL_Z10FICLASSFICA CURSOR NEXTLINE.
   MODULE LISTE_SHOW_LISTE.
 ENDLOOP.
*
PROCESS AFTER INPUT.
 MODULE LISTE_EXIT_COMMAND AT EXIT-COMMAND.
 MODULE LISTE_BEFORE_LOOP.
 LOOP AT EXTRACT.
   MODULE LISTE_INIT_WORKAREA.
   CHAIN.
    FIELD Z10FICLASSFICA-KUNNR .
    FIELD Z10FICLASSFICA-NAME1 .
    FIELD Z10FICLASSFICA-Z_CLASS .
    MODULE SET_UPDATE_FLAG ON CHAIN-REQUEST.
   ENDCHAIN.
   FIELD VIM_MARKED MODULE LISTE_MARK_CHECKBOX.
   CHAIN.
    FIELD Z10FICLASSFICA-KUNNR .
    MODULE LISTE_UPDATE_LISTE.
   ENDCHAIN.
 ENDLOOP.
 MODULE LISTE_AFTER_LOOP.
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Eva Dias
  • 1,709
  • 9
  • 36
  • 67
  • Why did you add NAME_1 as a field to the table? Did you denormalize the data "accidentally" or is there a special reason behind this? – vwegert Oct 15 '12 at 16:23
  • Yes, I aware that I shouldn't have created but it asked by another person. I've founded the solution for getting the name when filling the number. Now I just need to know how to make the z_class obligatory. Any thoughts? – Eva Dias Oct 15 '12 at 16:53
  • 1
    I know it's already answered, but for future reference for another: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2082425f-416b-2d10-25a3-85b8b6c5302c?QuickLink=index&overridelayout=true&48558900346775 – mrjimoy_05 Jun 28 '13 at 08:27

2 Answers2

2

As for the name, do not keep it as a reundant field. Define a foreign key relationship and then use a maintenance view to display the name that corresponds to the customer number.

For the mandatory field check, edit the generated screen and add a module that checks whether the required fields are filled out. It should also be possible to set the field to mandatory in the screen field options, but I wouldn't recommend this because then the field will be displayed as mandatory even for empty lines.

vwegert
  • 18,371
  • 3
  • 37
  • 55
  • I'm sorry but you have to explain this a little bit more. I'm going to add the cod that I have in the table maintenance that was generated automatically (I think). For what you're saying I believe I have to make something in there. – Eva Dias Oct 16 '12 at 09:38
  • How far do I have to go into the details? Can I assume that you know what MODULEs and FIELDs are ad that you know what the CHAIN ... ENDCHAIN block does? – vwegert Oct 16 '12 at 10:28
  • No need to go into details. I found the solution and there was no need for coding. Thank you. – Eva Dias Oct 16 '12 at 10:30
-1

I've found the answer for both problems. For automatic filling the name of the client I used a form routine with the event "Filling hidden fields" (no. 21). In the generated include I used this code:

FORM fill_hidden.
DATA: lc_name1 TYPE kna1-name1.
Data: lc_kunnr TYPE kna1-kunnr.

lc_kunnr = z10ficlassfica-kunnr.

SELECT SINGLE name1 INTO lc_name1 FROM kna1 WHERE kunnr = lc_kunnr.

z10ficlassfica-name1 = lc_name1.
endform.

For the mandatory field I went to Maintenance Screens, Element List tab, Special Attributes tab and choose mandatory from the drop down menu in the Entry column. Worked like a charm. Thanks for all your answers :)

Eva Dias
  • 1,709
  • 9
  • 36
  • 67
  • 2
    So you're fine with generating redundancies instead of normalizing your database structrures properly? No offense intended, but this breaks every convention of the SAP R/3 system, so you should state it in your question. – vwegert Oct 18 '12 at 09:06