Automatic filling of NAME_1 when entered a valid KUNNR - SM30
Solution 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 :)
Solution 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.
Comments
-
Eva Dias almost 2 years
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.
-
Eva Dias over 11 yearsI'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.
-
vwegert over 11 yearsHow 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?
-
Eva Dias over 11 yearsNo need to go into details. I found the solution and there was no need for coding. Thank you.
-
vwegert over 11 yearsSo 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.