10-10-2007 1:16 PM
Hi Gurus.
I need to fetch all the records of a particular pernr from table pa0008
then i need to loop at this internal table with some where condition(so 1 record will be fetched from int table satisfying the criteria)
Then i need to fetch the record from this internal table which has begda as '1/1/(year is the year of record fetched at loop into wa with where condition) and endda as (begda -1) of this record which is in work area.
But for this i need to use loop inside this loop to fetch record from internal table with where condition(ie range of dates)
as i can't use read table with range.
Can anybody tell me any alternative to using loop inside loop.
10-10-2007 1:18 PM
Hi,
Try using read table for the first requirment and then use loop endloop.
10-10-2007 1:19 PM
Hi
fetch the data from PA0008 like below
Report Zabc.
tables:pernr.
infotypes:0008.
data: begin of wagetypes,
lga like pa0008-lga01,
bet like pa0008-bet01,
anz like pa0008-anz01,
end of wagetypes.
get pernr.
rp_provide_from_last p0008 space pn-begda pn-endda.
do 20 times varying wagetypes
from p0008-lga01 next p0008-lga02.
if not wagetypes-lga is initial.
write:/ wagetypes-lga, wagetypes-bet, wagetypes-anz.
endif.
enddo.
Regards
Anji
10-10-2007 1:21 PM
Hi,
have a look at the following codes:
DATA: BEGIN OF wt_table1 OCCURS 0,
field1 LIKE wt_table1_key,
field4 LIKE table4-field4,
field5 LIKE table5-field5,
END OF wt_table1.
DATA: BEGIN OF wt_table2 OCCURS 0,
field1 LIKE wt_table1_key,
field6 LIKE table6-field6,
field7 LIKE table7-field7,
field8 LIKE table8-field8,
END OF wt_table2.
SORT wt_table1 BY field1.
SORT wt_table2 BY field1.
wv_index = 1.
LOOP AT wt_table1.
Treatment.
LOOP AT wt_table2 FROM wv_index.
IF wt_table2-field1 > wt_table1-field1.
wv_index = sy-tabix.
EXIT.
ELSE IF wt_table2-field1 = wt_table1-field1.
Treatment.
ENDIF.
ENDLOOP.
Treatment.
ENDLOOP.
Regards
10-10-2007 1:22 PM
For ranges of dates.....
u have to use loop inside a loop...
there is no other option.....as read statement will not allow ranges of dates....
Regards
vasu
10-10-2007 2:33 PM
Check this:
<a href="/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops">Performance of Nested Loops</a>
It shows how to avoid them.
Rob