2007 Jun 22 6:49 PM
Hi all,
I need a good algorithms for the next question:
Given 2 internal tables with the same structures, i need to print out the difference between the 2 tables .
types : BEGIN OF ty_s_table,
PERSONNR type i,
END OF ty_s_table.
DATA : itab1 TYPE TABLE OF ty_s_table,
itab2 TYPE TABLE OF ty_s_table.
For example : if itab1 contains the persons 1 , 2 , 3 , 5 and
itab2 contains the persons 2 , 4 , 6.
I need to print 1,3,4,6 (difference)
Thanks
Hi all,
I need a good algorithms for the next question:
Given 2 internal tables with the same structures, i need to print out the difference between the 2 tables .
types : BEGIN OF ty_s_table,
PERSONNR type i,
END OF ty_s_table.
DATA : itab1 TYPE TABLE OF ty_s_table,
itab2 TYPE TABLE OF ty_s_table.
For example : if itab1 contains the persons 1 , 2 , 3 , 5 and
itab2 contains the persons 2 , 4 , 6.
I need to print 1,3,4,6 (difference)
Thanks
2007 Jun 22 6:53 PM
Add one more field say FLAG with CHAR1 to ITAB2.
LOOP AT ITAB1.
READ TABLE ITAB2 WITH KEY PERSON = ITAB1-PERSON.
IF SY-SUBRC = 0.
ITAB2-FLAG = 'X'.
MODIFY ITAB2 TRANSPORTING FLAG.
ELSE.
WRITE ITAB1-PERSON.
ENDLOOP.
LOOP AT ITAB2 WHERE FLAG <> 'X'.
WRITE ITAB2-PERSON.
ENDLOOP.
Output will contain all the persons which are not common.
2007 Jun 22 7:12 PM
Something like this?
report zrich_0001 .
types: begin of ty_s_table,
personnr type i,
end of ty_s_table.
data: itab1 type table of ty_s_table,
itab2 type table of ty_s_table,
itab3 type table of ty_s_table.
data: wa1 type ty_s_table.
data: wa2 type ty_s_table.
data: wa3 type ty_s_table.
wa1-personnr = '1'. append wa1 to itab1.
wa1-personnr = '2'. append wa1 to itab1.
wa1-personnr = '3'. append wa1 to itab1.
wa1-personnr = '5'. append wa1 to itab1.
wa2-personnr = '2'. append wa2 to itab2.
wa2-personnr = '4'. append wa2 to itab2.
wa2-personnr = '6'. append wa2 to itab2.
append lines of itab1 to itab3.
append lines of itab2 to itab3.
loop at itab3 into wa3.
clear wa1.
clear wa2.
read table itab1 into wa1 with key personnr = wa3-personnr.
read table itab2 into wa2 with key personnr = wa3-personnr.
if wa1 <> wa2.
write:/ wa3-personnr.
endif.
endloop.
Regards,
RIch Heilman
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |