‎2012 Jul 03 12:33 PM
Dear all,
I checked with all the forums but iam unable to make my code correct.
My problem is when iam entering data into table control it is getting filled,but when i press enter key there is no data in that
corresponding lines.
here using table control iam inserting records in ztables.
iam attaching my code please helpme in this.
DATA : IT TYPE TABLE OF ZADV_NO,
WA LIKE LINE OF IT.
DATA :IT1 TYPE TABLE OF ZGOV_ORDERS,
WA1 LIKE LINE OF IT1.
DATA :S1 TYPE ZADV_NO-SERIALNO,
S2 TYPE ZGOV_ORDERS-SERIALNO.
CASE OK_CODE.
** when ''.
** wa_tabc-POSTCODE = ZGOV_ORDERS-POSTCODE.
** wa_tabc-NAMEOFTHEPOST = ZGOV_ORDERS-NAMEOFTHEPOST.
** wa_tabc-NOOFPOSTS = ZGOV_ORDERS-NOOFPOSTS.
** wa_tabc-POSTDETAILS = ZGOV_ORDERS-POSTDETAILS.
** append wa_tabc to it_tabc.
***modify it_tabc from wa_tabc index tabc-current_line.
**loop at it_tabc INTO wa_tabc.
*** READ TABLE it_tabc INTO wa_tabc index tabc-current_line.
** ZGOV_ORDERS-POSTCODE = wa_tabc-POSTCODE .
** ZGOV_ORDERS-NAMEOFTHEPOST = wa_tabc-NAMEOFTHEPOST .
** ZGOV_ORDERS-NOOFPOSTS = wa_tabc-NOOFPOSTS.
** ZGOV_ORDERS-POSTDETAILS = wa_tabc-POSTDETAILS.
** modify control from wa_tabc ."index tabc-current_line.
**endloop.
WHEN 'SAVE'.
SELECT * FROM ZADV_NO INTO TABLE IT .
SORT IT BY SERIALNO DESCENDING.
READ TABLE IT INTO WA INDEX 1.
S1 = WA-SERIALNO + 1.
SELECT * FROM ZGOV_ORDERS INTO TABLE IT1.
SORT IT1 BY SERIALNO DESCENDING.
READ TABLE IT1 INTO WA1 INDEX 1.
S2 = WA1-SERIALNO + 1.
ITAB1-SERIALNO = S1.
ITAB1-OFFID = V1.
ITAB1-REFADVNO = REF_ADV_NO.
ITAB1-SANCTIONORDERS = SANCTION.
ITAB1-LASTDATESUBMISSI = LASTDATE.
APPEND ITAB1.
MOVE-CORRESPONDING ITAB1 TO WTAB1.
INSERT INTO ZADV_NO VALUES WTAB1.
IF SY-SUBRC <> 0.
MESSAGE 'Error While Inserting Data ZADV_NO' type 'E'.
ENDIF.
ITAB-SERIALNO = S2.
ITAB-OFFID = V1.
ITAB-POSTCODE = ZGOV_ORDERS-POSTCODE.
ITAB-NAMEOFTHEPOST = ZGOV_ORDERS-NAMEOFTHEPOST.
ITAB-NOOFPOSTS = ZGOV_ORDERS-NOOFPOSTS .
ITAB-POSTDETAILS = ZGOV_ORDERS-POSTDETAILS.
APPEND ITAB.
MOVE-CORRESPONDING ITAB TO WTAB.
INSERT INTO ZGOV_ORDERS VALUES WTAB.
IF SY-SUBRC <> 0.
MESSAGE 'Error While Inserting Data ZGOV_ORDERS' type 'E'.
ENDIF.
ENDCASE.
CLEAR: WA-SERIALNO,WA1-SERIALNO.
ENDMODULE. " USER_COMMAND_2000 INPUT
Thanks in advance
Regards
shiv
‎2012 Jul 03 12:55 PM
Can you please paste also the flow logic with the corresponding modules of your screen ?
‎2012 Jul 04 4:39 AM
PROCESS BEFORE OUTPUT.
MODULE STATUS_2000.
loop with CONTROL tabc.
endloop.
*
PROCESS AFTER INPUT.
MODULE CANCEL AT EXIT-COMMAND.
loop WITH CONTROL tabc.
MODULE USER_COMMAND_2000.
endloop.
tabc is my table control .
‎2012 Jul 04 6:21 AM
See the following example:
loop with control tabctr.
module display.
endloop.
process after input.
module get_data1.
loop with control tabctr.
module read_table_control.
endloop.
module user_command_90001.
module display output.
read table itab1 into itab index tabctr-current_line.
endmodule.
module read_table_control input.
.
lines = sy-loopc.
modify itab1 from itab index tabctr-current_line.
endmodule.
‎2012 Jul 04 7:09 AM
Dear Jani,
When you press ENTER, you have to capture the values in the screen to your table control internal table (it_tabc). For this purpose we use the statement -> modify it_tabc from wa_tabc index tabc-current_line.
But imagine you are entering the first record in table control. The work area of your table control will have the first record and the internal table will be empty (since we have not captured the value yet). Now if we try to capture the value using modify statement, the modify statement will look something like this -> modify it_tabc from wa_tabc index 1.
Now the internal table is empty and we are trying to modify index 1. So this MODIFY will always give sy-subrc 4. Hence we will always fail to capture the records in it_tabc.
Try to use the following logic now:
MODULE tabc_modify INPUT.
DATA: tc_lines TYPE i.
* Modify table
DESCRIBE TABLE it_tabc LINES tc_lines.
IF tc_lines GE tabc-current_line.
MODIFY it_tabc
FROM wa_tabc
INDEX tabc-current_line.
ELSE.
APPEND wa_tabc TO it_tabc.
ENDIF.
ENDMODULE.
I hope you understand the logic here. If the internal table already contains some value it will modify. If not it will APPEND it_tabc.
Include this module inside loop..endloop.
Thanks,
Manikandan JN.