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 into internal table

Former Member
0 Likes
3,000

I have 3 internal, for example, one of header table, one of item table, one of result table.

How can i insert header and item into result table.

Like.

Insert header-f1 header-f2 item-f1 item-f2 item-f3 into result

Thanks.

I have 3 internal, for example, one of header table, one of item table, one of result table.

How can i insert header and item into result table.

Like.

Insert header-f1 header-f2 item-f1 item-f2 item-f3 into result

Thanks.

4 REPLIES 4
Read only

Former Member
0 Likes
637

Hi,

Try as below -

Loop at header.

Loop at item.

Append the required fields from header and item itabs to result itab.

endloop.

endloop.

Reward ponits if found useful..!

Cheers

Abhishek

Read only

Former Member
0 Likes
637

Hi ,

create a work area for the result table and then move the values to the work area followed by appending to the result internal table.

wa-f1 = header-f1.

wa-f2 = header-f2

append wa to result.

clear wa.

wa-f1 = item-f1.

wa-f2 = item-f2

append wa to result.

Now the result itab contains 2 records.

Pls reward if found useful.

Thanks

Shyam

Read only

0 Likes
637

Hi,

Since you have more than one record in the item table for a corresponding header table entry.Consider the following steps.

1. Do a loop at the item table.

2. Read the header table for the above key combination from the item table.

For eg: Read it_header with key xxx from the it-item-xxx.

3. Populate the final internal table. You can append the new internal table.

4. Endloop.

Hope this helps..

Regards

Deepu.

Read only

Former Member
0 Likes
637

loop at ititem.

move-corresponding ititem to itresult.

read table itheader with key f1 = ititem-f1.

if sy-subrc = 0.

move-corresponding itheader to itresult.

endif.

append itresult.

endloop.

here all the tables are with header line if your table is without header line you have to use explicit work area.

regards

shiba dutta