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

how to insert the data to database through module pool programming

Former Member
0 Likes
2,017

hi

I want the syntax for how to inert the data to the two tables through module pool programming ,please help me

3 REPLIES 3
Read only

Former Member
0 Likes
869

Hi,

Try this.

Create two internal tables of same structure of the DB table.

In the module pgm either you may have a button or press enter to perform this save option. <according to your requirement>

Check the SY-UCOMM according to it, then fill the internal table with the values as given in the module pool pgm.

Then use call function ENQUEUE_E_TABLE to lock the table and use modify stmt.

MODIFY <TABLE NAME> FROM TABLE ITAB1.

then release the lock by calling the function module DEQUEUE_E_TABLE.

Sharin.

Read only

Former Member
0 Likes
869

hi,

First you create two internal tables same as your tables.

then use

SELECT SINGLE ......Fields..... FROM ...Table...

INTO CORRESPONDING FIELDS OF ITABLE1

SELECT SINGLE ..Fields... FROM table

INTO CORRESPONDING FIELDS OF Itable2

if sy-subrc = 0.

append itable1.

append itable2.

else.

message.....

hope it will help you.

regards,

Lokesh

Read only

Former Member
0 Likes
869

Hai Dhanunjay,

For example LIFNR is ur field in the database table LFA1 with primary key then define like this,

DATA : LIFNR_CHK TYPE LFA1-LIFNR,

IT_LIFNR TYPE LFA1-LIFNR OCCURS 0,

WA_LIFNR LIKE LINE OF IT_LIFNR.

Now in PAI of ur screen

when u click a button ur coding should be like this ,

CASE SY-UCOMM.

WHEN 'sAVE'.

LIFNR_CHK = ZLFA1-LIFNR.

SELECT SINGLE LIFNR INTO WA_LIFNR FROM LFA1 WHERE LIFNR = LIFNR_CHK.

INSERT ZLFA1.

ENDCASE.

do the same for two tables .

Regards,

Syam