Skip to Content
0
Former Member
Apr 25, 2010 at 12:45 PM

merge same internal table

22 Views

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