‎2009 Aug 07 4:57 PM
Hi,
I need to fetch multiple records from an interntal table using another internal table. ARC_PPDIX is an internal table that has multiple records for each selection of select_kostl-docnum and select_kostl-doclin. I am aware of 'FOR ALL ENTRIES' syntax but it works only in case of DB tables. Now I am able to retrieve just one record for each query. How can I change this code to get the desired result?
Here is the code.
LOOP AT select_kostl.
read TABLE ARC_PPDIX with key docnum = select_kostl-docnum
doclin = select_kostl-doclin binary search.
if sy-subrc = 0.
MOVE-CORRESPONDING ARC_PPDIX TO run_doc_xref.
Append run_doc_xref.
clear run_doc_xref.
ENDIF.
ENDLOOP.
Thanks,
VG
‎2009 Aug 07 5:03 PM
Hi,
You will have to use a loop inside another loop as you say there is many to many relation.
LOOP AT select_kostl.
loop at ARC_PPDIX where docnum = select_kostl-docnum and
doclin = select_kostl-doclin
MOVE-CORRESPONDING ARC_PPDIX TO run_doc_xref.
Append run_doc_xref.
clear run_doc_xref.
endloop.
ENDLOOP.
.
Hope this helps.
Regards,
Sachin
‎2009 Aug 07 5:03 PM
Hi,
You will have to use a loop inside another loop as you say there is many to many relation.
LOOP AT select_kostl.
loop at ARC_PPDIX where docnum = select_kostl-docnum and
doclin = select_kostl-doclin
MOVE-CORRESPONDING ARC_PPDIX TO run_doc_xref.
Append run_doc_xref.
clear run_doc_xref.
endloop.
ENDLOOP.
.
Hope this helps.
Regards,
Sachin
‎2009 Aug 07 5:04 PM
Hi,
If u have to fetch multiple records based on another internal table, you cannot use READ statement since its fetches only one record per main loop. what you can do is write a nested loop and acheive it.
LOOP AT select_kostl.
LOOP AT ARC_PPDIX where docnum = select_kostl-docnum and doclin = select_kostl-doclin binary search.
MOVE-CORRESPONDING ARC_PPDIX TO run_doc_xref.
Append run_doc_xref.
clear run_doc_xref.
ENDLOOP.
ENDLOOP.
Regards,
Vik
‎2009 Aug 07 5:04 PM
Try with loop inside loop
LOOP AT select_kostl.
LOOP AT ARC_PPDIX where docnum = select_kostl-docnum
and doclin = select_kostl-doclin.
MOVE-CORRESPONDING ARC_PPDIX TO run_doc_xref.
Append run_doc_xref.
ENDLOOP.
ENDLOOP.
a®
‎2009 Aug 07 5:25 PM
thanks. I was aware of using NESTED loops. I wanted to know is there a different way keeping the performance in view. it seems nested loop is the uanimous choice.
VG