2008 Jul 23 6:01 AM
experts,
if an internal table(ex : itab) contains another internal table (ex : jtab),
which will be the correcct mechanism to loop.
ie first loop jtab then read each row of itab based on criteria
or first loop itab then read each row of jtab.
thanks and regards.
2008 Jul 23 6:04 AM
Hi,
First loop itab.Nested Internal Tables:
Check this links:
http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9eaa35c111d1829f0000e829fbfe/content.htm
Regards
Adil
experts,
if an internal table(ex : itab) contains another internal table (ex : jtab),
which will be the correcct mechanism to loop.
ie first loop jtab then read each row of itab based on criteria
or first loop itab then read each row of jtab.
thanks and regards.
2008 Jul 23 6:04 AM
Hi,
First loop itab.Nested Internal Tables:
Check this links:
http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9eaa35c111d1829f0000e829fbfe/content.htm
Regards
Adil
2008 Jul 23 6:06 AM
Hi,
Loop at itab.
loop at jtab where field1 = itab-field1.
STATEMENTS.
endloop.
endloop.Regards,
Shailaja
2008 Jul 23 6:06 AM
Hi,
first loop Itab then read the row of jtab for each row value of itab.
Mechnism:
The internal table of these kind are called Nested table. The inner table have a set of row for every row in the outer table. so, we need nested loop to access data. The mechanism is similar to any other programming language like C.
for example code , check the link
http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9eaa35c111d1829f0000e829fbfe/content.htm
under the heading
"Formatting Data Using Nested Internal Tables"
Regards,
Anirban
2008 Jul 23 6:07 AM
hi,
Here you have nested internal tables.
It is always better to LOOP from the top and then LOOP on the inner internal table.
loop at itab.
loop at jtab <condition>.
<program>.
endloop.
endloop.
Regards
Sumit Agarwal
2008 Jul 23 6:10 AM
Hi Ramesh,
I will explain with example :
Suppose we have two tables SPFLI and SFLIGHT.
Now if we have to retrieve the fields CARRID, CONNID, CITYFROM & CITYTO from Table SPFLI.
And the fields FLDATE PRICE SEATSMAX & SEATSOCC from SFLIGHT on the condition that SPFLI-CARRID = SFLIGHT-CARRID & SPFLI-CONNID = SFLIGHT-CONNID.
Now the LOOP.....ENDLOOP will be like this :
Loop at t_spfli into fs_spfli.
write :/ fs_spfli-carrid,
fs_spfli-connid.
Loop at t_sflight into fs_sflight where carrid = fs_spfli-carrid
and connid = fs_spfli-connid.
write :/ fs_sflight-fldate,
fs_sflight-price,
fs_sflight-seatsocc,
fs_sflight-seatsmax.
Endloop.
Endloop.This will fetch all the records from sflight depending upon the condition. This solves the issue.
Regards,
Swapna.
2008 Jul 23 6:11 AM
Hi Ramesh,
the way will always be...
LOOP AT ITAB.
LOOP AT JTAB.
...........
...........
ENDLOOP.
ENDLOOP.
refer to the link for sample code:
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/call-function-read_text-173330
WIth luck,
Pritam.
2008 Jul 23 6:11 AM
Hi,
since you are using table within a table.
do like this
LOOP AT itab1.
LOOP AT itab2 WHERE <cond>.
ENDLOOP.
ENDLOOP.
Regards
Abhijeet