‎2009 Feb 08 6:42 AM
Hi experts,
i ahve a problem with read statement. i have put the read statement in the loop but it always reads the 1st record.. please help me guys..
if u need my code..i shall paste it here..
Regards ,
Sunita.
‎2009 Feb 08 6:44 AM
‎2009 Feb 08 6:44 AM
‎2009 Feb 08 6:47 AM
use this syntax if u are using read statement inside the loop.
read table itab index sy-tabix.if u are using inside loop it will get all records
‎2009 Feb 08 6:51 AM
mibght be:
loop at a into wa.
read table b into wb with key (field of b) = wa-field of a
endloop.
now problemmight be that in tab a there might be multiple recors containing a..so when you do read on b it will retrieve you first recod of b based on condition ..so always you gettin same record
‎2009 Feb 08 7:04 AM
hi experts,
loop at it_trip.
READ TABLE it_ptrv_head WITH KEY pernr = it_trip-pernr.
READ TABLE it_ptrv_srec WITH KEY pernr = it_ptrv_head-pernr.
READ TABLE it_ptrv_sadd WITH KEY pernr = it_ptrv_srec-pernr.
endloop.so can u now tell me y it always reads only 1st record .
regards,
sunita.
‎2009 Feb 08 7:09 AM
can you be more elaborate...which read is giving you first record ..what is your expected result?
and after each read where are you passing the value..
if you are using the read data after end loop..then you will get single record only....
and every read..plz dont forget to put sy-subrc check..you might have empty internal table in between
‎2009 Feb 08 7:11 AM
Hi,
Use work area to read all of your records,
DATA : wa_trip like line of it_trip .
loop at it_trip into wa_trip .
READ TABLE it_ptrv_head WITH KEY pernr = wa_trip-pernr.
endloop.
similarly rread all your records inside the loop.hope this will helps you,if you want more help send all of your code.
Regds,
Sree.
‎2009 Feb 08 7:13 AM
Hi,
Can you show your full code?
You are using 3 Read statement in this loop. In which read statement you want to capture the data?
Thanks.
‎2009 Feb 08 7:16 AM
Hi,
Change with the following i think you will find the problem i think some of you internal table have no pernr..
and you are not Checking sy-subrc so facing such problem.
LOOP AT it_trip.
READ TABLE it_ptrv_head WITH KEY pernr = it_trip-pernr.
IF sy-subrc = 0.
READ TABLE it_ptrv_srec WITH KEY pernr = it_ptrv_head-pernr.
IF sy-subrc = 0.
READ TABLE it_ptrv_sadd WITH KEY pernr = it_ptrv_srec-pernr.
IF sy-subrc = 0.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.kind Regards.
Faisal
Edited by: Faisal Altaf on Feb 8, 2009 12:17 PM
‎2009 Feb 09 5:30 AM
Hi Sunita,
Please check the table entries of it_trip, if the pernr field in that table has the same value for every record, if so then it will always show you the first record, or check if the last record of it_trip pernr field matches the first record in that case as the loop ends it will show you the first record.
Regards,
Siddarth
‎2009 Feb 08 6:45 AM
hi,
the read statemnet will get the first successful record based on tyeh key.Suppose for the same key 2 0r 3 records are there,then always the first successful record will be returned.in ur case may be the first record itself satisfying the key.
‎2009 Feb 08 6:46 AM
Hi,
are you using Index or table key ?
Kind Regards,
Faisal
Edited by: Faisal Altaf on Feb 8, 2009 11:48 AM
‎2009 Feb 08 6:50 AM
Hello Sunitha ,
Loop at itab .
read table jtab { with key f1 = itab-f1 } OR index sy-tabix .
Endloop.
This will fetch as per the access to the JTAB table data .
If u r still facing the problem please paste u r code.
Regardss
‎2009 Feb 09 5:24 AM
hi Sunitha,
Besides checking the return code..
loop at it_trip.
READ TABLE it_ptrv_head WITH KEY pernr = it_trip-pernr.
READ TABLE it_ptrv_srec WITH KEY pernr = it_ptrv_head-pernr.
READ TABLE it_ptrv_sadd WITH KEY pernr = it_ptrv_srec-pernr.
write:/ it_ptrv_head-pernr,
it_ptrv_srec-pernr,
it_ptrv_sadd-pernr,
endloop.
Regards,
Mdi.Deeba