05-29-2006 2:36 PM
dear firends,
would you like to give me some idea, about how to fetch, similar record from one internal table to another internal table...any code, suggestion, article will be greate help of mine,,
thankign you..
regards,
Naim
05-29-2006 2:41 PM
do u mean to get similar records from 2 internal tables then u need to use the read statement and get the records into another internal table of similar structure
LOOP AT ITAB1.
READ TABLE ITAB2 WITH KEY VBELN = ITAB1-VBELN.
IF SY-SUBRC = 0.
ITAB3 = ITAB1.// this get the header line into itab
APPEND ITAB3.
ENDIF.
ENDLOOP.
otherwise if u mean to say similar records from one internal table then u need to
SORT ITAB BY VBELN POSNR.
LOOP AT ITAB.
AT NEW VBELN.
MOVE ITAB TO ITAB2.
ENDAT.
ENDLOOP.
This will get all the distinct records into ITAB2
05-29-2006 2:37 PM
Hello Naim,
Could you provide an example of 2 internal tables with their content, to clarify your problem?
Regards,
John.
05-29-2006 2:40 PM
loop at itab where field1 = 'test'.
move-coresponding itab to itab_new.
append itab_new.
clear itab_new.
endloop.
For demo programs on internal tables, look at the program:
DEMO_INTERNAL_TABLE
and for more:
go to se38 and type
demointtable* and press f4 to get a big list of programs.
Regards,
Ravi
05-29-2006 2:41 PM
do u mean to get similar records from 2 internal tables then u need to use the read statement and get the records into another internal table of similar structure
LOOP AT ITAB1.
READ TABLE ITAB2 WITH KEY VBELN = ITAB1-VBELN.
IF SY-SUBRC = 0.
ITAB3 = ITAB1.// this get the header line into itab
APPEND ITAB3.
ENDIF.
ENDLOOP.
otherwise if u mean to say similar records from one internal table then u need to
SORT ITAB BY VBELN POSNR.
LOOP AT ITAB.
AT NEW VBELN.
MOVE ITAB TO ITAB2.
ENDAT.
ENDLOOP.
This will get all the distinct records into ITAB2
05-29-2006 2:52 PM
hi naim,
loop at itab where field1 = 'aaa'.
itab1[] = itab[].
append itab1.
clear itab1.
endloop.
05-29-2006 4:20 PM
Hi Naim,
loop at itab1.
read table itab2 where fld1 = itab1-dat1.
if sy-subrc=0.
append itab2 to itab3.
endif.
endloop.
award if it helps.
regards,
keerthi.
05-29-2006 4:28 PM
Hi Naim,
Do this way.
Sort internal table first and then check for similar records and transfer those records.
Sort itab.
Loop at itab.
if itab_previous = itab.
move itab to itab1.
append itab1.
endif.
itab_previous = itab.
clear itab.
endloop.
loop at itab1.
write:/ itab1.
endloop.
declare itab and itab1 as similar internal tables and itab_previous is the work area of itab.
Finally, itab1 contains the similar records present in itab.
Hope this helps.
Regards,
Vicky
PS: Award points if helpful