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

Insert lines with different fields between two tables

Former Member
0 Likes
476

Hi all,

Once again I need a help!!! here I go with my problem: I have one internal table with 3 records and I have another internal table with data related first internal table wich I need to fill it:

Table 1

F1 F2 F3 F4 F5

01 A C X

02 A B X

03 B C

Table2

F1 F2 F3 F4

01 A C 5

01 A C 10

02 B C 5

Result Table (Table 1)

F1 F2 F3 F4 F5

01 A C 5 X

- - - 10 X

02 A B 5 X

03 B C

I tried to


Loop at TABLE1.
Read TABLE 2 with key F1 = TABLE1-F1.
if sy-subrc = 0.
   TABLE1-F4 = TABLE2-F4.
    MODIFY TABLE1 FROM TABLE1
       TRANSPORTING F4
    WHERE F1 = TABLE1-F1.
endif.
Endloop.

But only modify first record of TABLE1 and I need to append the records of TABLE2.

Thanks in advance with any help !!!

Regards

Tokio

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
424

Hi,

in result table

- - - 10 X

is hard to explain. - - - 10 - would be resonable, or better 01 A C 15 X?.

Better define your result table separately. Loop at table 1, read table 2 with key. If found, move-corresponding table 1 ro result table header line, fill empty collumns in table1 from table 2, then append combined line to result table. The delete row in table 2.

When done, loop at table 2 and move-corresponding table 2 ro result table header line, append it.

Something like that.

Regards,

Clemens

2 REPLIES 2
Read only

Clemenss
Active Contributor
0 Likes
425

Hi,

in result table

- - - 10 X

is hard to explain. - - - 10 - would be resonable, or better 01 A C 15 X?.

Better define your result table separately. Loop at table 1, read table 2 with key. If found, move-corresponding table 1 ro result table header line, fill empty collumns in table1 from table 2, then append combined line to result table. The delete row in table 2.

When done, loop at table 2 and move-corresponding table 2 ro result table header line, append it.

Something like that.

Regards,

Clemens

Read only

Former Member
0 Likes
424

Hi Clemens

Thanks for your help!!!

Regards,

Tokio