on 07-23-2020 8:40 PM
I have created two tables(ztable1 abd ztable2),in this ztable1 is item table and ztable2 is header table.Now what I have to do is I have to enter record to this table using table control.I have created table control with wizard in screen menu painter and also created module pool program.Now what I have to do is when I enter records in table control that record should be updated in ztable1 which item table and we have to do same with header table.
one more requirement is that each time sales order no should be generated automatically.capture1.png
next requirement is when I enter customer the address should be display automatically also address fields should be grey out.
Please find my code below and let me know as soon as possible.
*&SPWizard: Data incl. inserted by SP Wizard. DO NOT CHANGE THIS LINE!
INCLUDE ZSALES_ORDER_TOP .
*&SPWizard: Include inserted by SP Wizard. DO NOT CHANGE THIS LINE!
INCLUDE ZSALES_ORDER_PBO .
INCLUDE ZSALES_ORDER_PAI .
INCLUDE ZSALES_ORDER_SUB
TABLES : ZTABLE1,ZTABLE2.
DATA : ITAB TYPE STANDARD TABLE OF ZTABLE1.
DATA : WA TYPE ZTABLE1.
*&SPWIZARD: DECLARATION OF TABLECONTROL 'TABC' ITSELF
CONTROLS: TABC TYPE TABLEVIEW USING SCREEN 0100.
*&SPWIZARD: LINES OF TABLECONTROL 'TABC'
DATA: G_TABC_LINES LIKE SY-LOOPC.
DATA: OK_CODE LIKE SY-UCOMM.
DATA: GV_TOTAL TYPE VBAP-NETWR.
Data: w_item type i,
Fl_flag type c.
*****in pbo
MODULE TABC_CHANGE_TC_ATTR OUTPUT.
DESCRIBE TABLE ITAB LINES TABC-lines.
ENDMODULE.
*&SPWIZARD: OUTPUT MODULE FOR TC 'TABC'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: GET LINES OF TABLECONTROL
MODULE TABC_GET_LINES OUTPUT.
G_TABC_LINES = SY-LOOPC.
ENDMODULE.
*****pai
MODULE TABC_MODIFY INPUT.
MODIFY ITAB
FROM WA
INDEX TABC-CURRENT_LINE.
if sy-subrc <> 0.
append wa to itab.
endif.
ENDMODULE.
*&SPWIZARD: INPUT MODULE FOR TC 'TABC'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: PROCESS USER COMMAND
MODULE TABC_USER_COMMAND INPUT.
OK_CODE = SY-UCOMM.
PERFORM USER_OK_TC USING 'TABC'
'ITAB'
' '
CHANGING OK_CODE.
SY-UCOMM = OK_CODE.
CASE SY-UCOMM.
WHEN 'SAVE'.
LOOP AT ITAB INTO WA.
WA-ZPOSNR = ZTABLE1-ZPOSNR.
WA-ZMATNR = ZTABLE1-ZMATNR.
WA-ZWAERK = ZTABLE1-ZWAERK.
WA-ZMENGE = ZTABLE1-ZMENGE.
WA-ZMEINS = ZTABLE1-ZMEINS.
WA-ZNETWR = ZTABLE1-ZNETWR.
APPEND WA TO ITAB.
CLEAR WA.
ENDLOOP.
IF ITAB IS NOT INITIAL.
MODIFY ZTABLE1 FROM TABLE ITAB.
IF SY-SUBRC = 0.
MESSAGE 'DATA ADDED SUCCESSFULLY.' TYPE 'S'.
ELSE.
MESSAGE 'DATA NOT ADDED' TYPE 'I'.
ENDIF.
ELSE.
MESSAGE 'NO DATA' TYPE 'I'.
ENDIF.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
When Refresh.
FL_FLAG = 'X'.
ENDCASE.
ENDMODULE.
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'STAT100'.
* SET TITLEBAR 'xxx'.
ENDMODULE.
Hi Ranjita,
Since you need the header and item tables to be updated together, best approach will be to have a function module for the same. The FM can have header and item details as the parameter. Your modify table can be inside this FM and you can call the FM to add entries to the table.
For the sales order number to be generated automatically, you can create and use a number range object in SNRO transaction. In the FM call SAP stantard FM get_number_next with the number range object to get next salesorder number.
Disabling input fields is something that is possible in screenpainter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
11 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.