‎2009 Jan 23 1:04 PM
Hi Friends,
My query is, assume that have two internal tables as itab1 and itab2 ?
I need to pass the unique records to third internal table....
Let me know pls completely.....
Hope, early reply from your end.
Thanks & Regards,
Rahul Khan
‎2009 Jan 23 1:07 PM
APPEND LINES OF itab1 TO itab3.
APPEND LINES OF itab2 TO itab3.
SORT itab3.
DELETE ADJACENT DUPLICATES FROM itab3.
‎2009 Jan 23 1:08 PM
HI Rahul,
Unique as in i consider you have one field commomn in both tables which should be unique let the field be 'KEY'...
DELETE ADJACENT DUPLICATES FROM itab1 COMPARING key.
itab_final[] = itab1[].
LOOP AT itab2.
READ TABLE itab_final WITH KEY key = itab2-key.
IF sy-subrc NE 0.
itab_final = itab2.
APPEND itab_final.
ENDIF.
ENDLOOP>
‎2009 Jan 23 1:13 PM
Hi Rahul,
Try it this way:
Data:
w_lines type i,
w_index type i value 1.
Describe table itab1 lines w_lines.
While w_index LE w_lines.
Read table itab1 into wa1 index w_index.
Read table itab2 into wa2 with key field1 = wa1-field1.
If sy-subrc eq 0.
wa3-field1 = wa1-field1.
wa3-field2 = wa1-field2.
wa3-field3 = wa2-field2.
wa3-field4 = wa2-field3.
Append wa3 to itab3.
Endif.
w_index = w_index + 1.
EndwhileWith luck,
Pritam.
‎2009 Jan 23 1:45 PM
Hi Rahul,
If Itab1, Itab2 & itab3 are identical
( Append Itab1 to itab3.
Append itab2 to itab3.
Sort Itab3.
Delete adjacent duplicates of itab3. ) is the better way to proceed.
Regards
Sravan
‎2009 Feb 28 9:30 AM
Hi Rahul,
This transfers only unique entries from tab1 to tab3.
describe table itab1 lines w_lines.
loop at itab1.
w_idx = sy-tabix + 1.
do w_lines times.
read table itab1 index w_idx comparing all fields transporting no fields.
if sy-subrc eq 0.
fl_flag = 1.
exit.
endif.
add 1 to w_idx.
if w_idx gt w_lines.
exit.
endif.
enddo.
if fl_flag ne 1.
append itab1 to itab3.
fl_flag = 0.
endif.
endloop.
Regards,
Mdi.Deeba