‎2006 Oct 18 7:23 AM
Hi Experts,
I m inserting record from table control to my database table. programme is executing without Error msg. but record in not getting inserted.
my Code is this :
PROCESS BEFORE OUTPUT.
MODULE STATUS_0001.
LOOP WITH CONTROL TBLCTRL.
MODULE move_data_to_table.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0001.
LOOP WITH CONTROL TBLCTRL.
MODULE move_data_from_table.
ENDLOOP.
&----
*& Module pool ZGSTT_YTBLCTRL
*&
&----
*&
*&
&----
PROGRAM ZGSTT_YTBLCTRL.
&----
*& Module move_data_to_table OUTPUT
&----
text
----
TABLES : ZYEMP_DTL.
DATA : ITAB LIKE ZYEMP_DTL OCCURS 0 WITH HEADER LINE.
CONTROLS : TBLCTRL TYPE TABLEVIEW USING SCREEN '0001'.
MODULE move_data_to_table OUTPUT.
READ TABLE ITAB INDEX TBLCTRL-current_line.
IF sy-subrc = 0.
zYEMP_DTL-ZEMPID = ITAB-ZEMPID.
zYEMP_DTL-ZEMPNM = ITAB-ZEMPNM.
zYEMP_DTL-ZEMPPHN = ITAB-ZEMPPHN.
zYEMP_DTL-ZDEPID = ITAB-ZDEPID.
ENDIF.
ENDMODULE. " move_data_to_table OUTPUT
&----
*& Module move_data_from_table INPUT
&----
text
----
MODULE move_data_from_table INPUT.
ITAB-ZEMPID = zYEMP_DTL-ZEMPID.
ITAB-ZEMPNM = zYEMP_DTL-ZEMPNM.
ITAB-ZEMPPHN = zYEMP_DTL-ZEMPPHN.
ITAB-ZDEPID = zYEMP_DTL-ZDEPID.
*here if the data is there, it will modify
MODIFY ITAB INDEX TBLCTRL-current_line.
IF sy-subrc NE 0. "data not exixting in table control . ie new data, then append it
APPEND ITAB.
CLEAR ITAB.
ENDIF.
ENDMODULE. " move_data_from_table INPUT
&----
*& Module USER_COMMAND_0001 INPUT
&----
text
----
MODULE USER_COMMAND_0001 INPUT.
CASE SY-UCOMM.
WHEN 'INS'.
INSERT INTO ZYEMP_DTL VALUES ITAB.
MESSAGE I001(ABC) WITH : 'RECORD INSERTED'.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
Thanks & Regards,
yunus
‎2006 Oct 18 7:29 AM
Hi,
Use modify for inserting into databse from itab.Since it has some records already existing in databse.
WHEN 'INS'.
modify ZYEMP_DTL from table itab.
‎2006 Oct 18 7:29 AM
CASE SY-UCOMM.
WHEN 'INS'.
<b>modify ZYEMP_DTL from table ITAB.</b>
MESSAGE I001(ABC) WITH : 'RECORD INSERTED'.
Regards
- Gopi
‎2006 Oct 18 7:32 AM
try using a COMMIT statement after insert the data into the table.
Regards,
Ravi
Note : Please mark all the helpful answers
‎2006 Oct 18 8:05 AM
Hi Yunus,
WHEN 'INS'.
INSERT INTO ZYEMP_DTL VALUES ITAB.
if sy-subrc eq 0.
commit work.
endif.
MESSAGE I001(ABC) WITH : 'RECORD INSERTED'.
Regards,
nagaraj
‎2006 Oct 18 11:07 AM
Tried above all Code but only Blank record getting inserted.
pls help...
‎2006 Oct 18 11:09 AM
are u able to c the data during debug in the internal table even.
Regards
- Gopi
‎2006 Oct 18 11:49 AM
yes i can c the record in the internal table during debug mode.