2008 May 12 9:08 AM
in internal tables
itab1
a
b
c
d
itab2
b
c
in final itab i should get
a
d
how
in internal tables
itab1
a
b
c
d
itab2
b
c
in final itab i should get
a
d
how
2008 May 12 9:12 AM
hi,
do this way..
data : lv_tabix like sy-tabix.
loop at itab1.
lv_tabix = sy-tabix.
read table itab2 with key field = itab1-field.
if sy-subrc = 0.
else.
it_final-field = itab1-field.
append it_final.
clear it_final.
endif.
endllop.
loop at it_final.
write : it_final-field.
endloop.
2008 May 12 9:14 AM
Try like this.
loop at itab1.
read table itab2 with field = itab1-field.
if sy-subrc eq 0.
delete itab1.
endif.
endloop.
2008 May 12 9:31 AM
Hi Jyothsana,
Try this logic.This is very much helpful to u.Check it once..
There are two ways to solve ur question...Here 1st one is some what complicated, in the sense performance wise...
METHOD 1:
loop at itab1 into wa1.
loop at itab2 into wa2.
if wa1-field1 eq wa2-field1.
else.
wa-field1 = wa1-field1.
append wa to itab.
endif
endloop.
endloop.
METHOD 2:
loop at itab1 into wa1.
read table itab2 with key field1 = wa1-field1.
if sy-subrc eq 0.
else.
wa-field1 = wa1-field1.
append wa to itab.
endif
endloop.
Reward points if helpful...
Kiran Kumar.G.A
2008 May 12 9:33 AM
hi
data : begin of itab1 occurs 0,
a type c,
end of itab1.
data : begin of itab2 occurs 0,
b type c,
end of itab2.
data : begin of itab3 occurs 0,
e type c,
end of itab3.
itab1-a = 'A' .
append itab1.
clear itab1.
itab1-a = 'B' .
append itab1.
clear itab1.
itab1-a = 'C' .
append itab1.
clear itab1.
itab1-a = 'D' .
append itab1.
clear itab1.
itab2-b = 'B' .
append itab2.
clear itab2.
itab2-b = 'C' .
append itab2.
clear itab2.
loop at itab1.
read table itab2 with key b = itab1-a.
if sy-subrc <> 0.
itab3-e = itab1-a.
append itab3.
endif.
endloop.
loop at itab3.
write itab3-e.
endloop.
REGARDS
PRASANTH
2008 May 12 9:48 AM
Hi,
Sort itab2 byb.
Loop at itab1 into wa1.
read table itab2 with key b eq wa1-b c eq wa1-c binary search.
if sy-subrc eq 0.
Move itabf-a = wa1-a.
Move itabf-d = wa1-d
Append itabf.
clear itabf. "itabf should be an internal table with header
Endif.
clear wa1.
Endloop.
Reward Points
2008 May 12 9:53 AM
Hi,
Please find below the code snippet.
TYPES: BEGIN OF ty_itab1 ,
field1 TYPE char1,
END OF ty_itab1.
DATA: itab1 TYPE STANDARD TABLE OF ty_itab1,
itab2 TYPE STANDARD TABLE OF ty_itab1,
itab_final TYPE STANDARD TABLE OF ty_itab1,
ls_itab1 TYPE ty_itab1,
ls_itab2 TYPE ty_itab1.
APPEND: 'a' TO itab1,
'b' TO itab1,
'c' TO itab1,
'd' TO itab1.
APPEND: 'b' TO itab2,
'c' TO itab2.
LOOP AT itab1 INTO ls_itab1 .
READ TABLE itab2 INTO ls_itab2
WITH KEY field1 = ls_itab1-field1.
IF sy-subrc EQ 0.
Do nothing as this record is not required
ELSE.
APPEND ls_itab1 TO itab_final.
ENDIF.
ENDLOOP.
Regards,
Farheen.
2008 May 12 10:44 AM
loop at itab1.
read table itab2 where b = itab1-b and c = itab1-c.
move: itab1-a to itab3-a,
itab1-d to itab3-d.
apend itab3.
endloop.
hope it will be useful. Reward if it is useful.
2008 May 12 11:09 AM
If ur problem is solved plz reward points and close the thread.