Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Inserting Record in database table from table control...

Former Member
0 Likes
735

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

7 REPLIES 7
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
700

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.

Read only

gopi_narendra
Active Contributor
0 Likes
700

CASE SY-UCOMM.

WHEN 'INS'.

<b>modify ZYEMP_DTL from table ITAB.</b>

MESSAGE I001(ABC) WITH : 'RECORD INSERTED'.

Regards

- Gopi

Read only

Former Member
0 Likes
700

try using a COMMIT statement after insert the data into the table.

Regards,

Ravi

Note : Please mark all the helpful answers

Read only

former_member404244
Active Contributor
0 Likes
700

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

Read only

0 Likes
700

Tried above all Code but only Blank record getting inserted.

pls help...

Read only

0 Likes
700

are u able to c the data during debug in the internal table even.

Regards

- Gopi

Read only

0 Likes
700

yes i can c the record in the internal table during debug mode.