Application Development 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: 

merge same internal table

Former Member
0 Kudos

Hi Friends,

I have an INTERNAL TABLE ITAB_1 (fields A, B, C , D,E,F,G).

ITAB_1 has records for A B C D, E,F,fields. E,F,G is Empty.

I have 2nd itab ITAB_2 (fields A,B, C, D,E,F,G).

ITAB_2 has records for A,B, C, D,NULL,NULL,G

THE TWO ITAB WITH THE KEY A,B,C,D

HOW TO GET THE ITAB WITH VALUES

A,B,C,D,E,F,G?

USIGN MOVE-CORRESPONDING I CAN NOT SUCCESSFUL.

because if the itab have so many fields i have to use

itab-xxx = ITMP-xxx

there are easy way to merge the second itab value to the first (if the first field is null).

the follow method is ok

REPORT YXLIU0024.

TYPES:BEGIN OF IAA,

A TYPE C,

B TYPE C,

C TYPE C,

D TYPE C ,

E TYPE C ,

F TYPE C ,

G TYPE C ,

END OF IAA.

DATA:ITAB TYPE TABLE OF IAA WITH HEADER LINE .

DATA:ITAB1 TYPE TABLE OF IAA WITH HEADER LINE .

DATA ITMP LIKE LINE OF ITAB .

ITMP-A = 'A' .

ITMP-B = 'B' .

ITMP-C = 'C' .

ITMP-D = 'D' .

ITMP-E = 'E' .

ITMP-F = 'F' .

APPEND ITMP TO ITAB .

CLEAR ITMP .

ITMP-A = 'A' .

ITMP-B = 'B' .

ITMP-C = 'C' .

ITMP-D = 'D' .

ITMP-G = 'G' .

APPEND ITMP TO ITAB1 .

LOOP AT ITAB INTO ITAB.

READ TABLE ITAB1 INTO :ITMP WITH KEY A = ITAB-A

B = ITAB-B C = ITAB-C D = ITAB-D.

itab-g = ITMP-g .

MODIFY ITAB .

ENDLOOP.

Edited by: dellsoft on Apr 25, 2010 2:46 PM

2 REPLIES 2

Former Member
0 Kudos

HI,

As far as your code thats fine, may be adding transporting G would be

good but your Internal table contains just minimum data.

If you have huge data and then you use READ statement, its always

better to sort the internal table and add BINARY SEARCH addition to the

READ statement.

Regards and Best wishes.

Kiran Bura

Former Member
0 Kudos

Hi,

Is your code not working? Looping and reading is the most common way merging two table data.

it seems fine , only thing is your code can be made more better, but for the start it's ok.