‎2009 May 27 12:31 PM
Dear friends,
I am using read statement :
loop at it_bkpf.
read table it_bsid with key belnr = it_bkpf-belnr BUKRS = it_bkpf-BUKRS binary search.
if sy-subrc = 0.
endif.
endloop.
there are 2 records of same belnr in BSID. eg :
BELNR WRBTR
10003 55.50
10003 100.50
but read statement is reading only 1 record.
its possible using loop at it_bsid. but using read statement is it possible?
‎2009 May 27 12:34 PM
Hi,
READ Statement will fetch you only one record always.
Regards,
Ankur Parab
‎2009 May 27 12:35 PM
HI,
The Read statement will read the first record with the BELNR & BUKRS combination even if yo have more that one reocrds in the internal table with the these combination.
If you want to have all the record..you need use the LOOP AT ITAB WHERE <condition>.
‎2009 May 27 12:35 PM
hi
read statement reads only one record at a time
if u wanna read more than one than go for loop.
‎2009 May 27 12:39 PM
hi ,
if you are using Binary search with key fields if they are duplicates then read fails..
so try to avoid binary search if they are duplicate entries you are reading with key fields..
read will return only one line of record..
and sort the table before doing binary search..
loop at it_bkpf.
read table it_bsid with key belnr = it_bkpf-belnr BUKRS = it_bkpf-BUKRS binary search.
if sy-subrc = 0.
loop at it_bsid where belnr = it_bkpf-belnr and BUKRS = it_bkpf-BUKRS . "add this to get multiple
"move to another table or modify..
endloop.
endif.
endloop.
Regards,
Prabhudas
‎2009 May 27 12:45 PM
Hello,
But IT_BKPF will have only one record for BELNR, BUKRS & GJAHR combination.
So you can loop at IT_BSID & read IT_BKPF, simple )
LOOP AT it_bsid.
READ TABLE it_bkpf WITH KEY belnr = it_bsid-belnr bukrs = it_bsid-bukrs BINARY SEARCH.
IF sy-subrc = 0.
ENDIF.
ENDLOOP.I will not suggest nested LOOP stmt like this:
LOOP AT it_bkpf.
LOOP AT it_bsid WHERE belnr = it_bkpf-belnr AND bukrs = it_bkpf-bukrs.
ENDLOOP.
ENDLOOP.Hope this helps.
BR,
Suhas
‎2009 May 27 1:09 PM
Dear Friend ,
Use loop into loop and pass parameters as customer, document number fileds in the loop.
Hope this will solve your problem.
Regards,
Vijay
‎2009 May 27 1:22 PM
READ statement reads single record at a time.
if u want to process all records, dont use REAd
use SELECT END SELECT.
if u want to use only READ statement, there should be item number or some other field to fetch correct record.
Regards,
ajay
‎2009 May 27 1:22 PM
Hi,
If you want to use read statemeny please use the following eg code:
loop at it_vbep into xx_vbep.
clear avbep.
read table it_eintn into avbep with key
edatu = xx_vbep-edatu.
IF sy-subrc = 0.
XX_WMENG_OLD_sum = XX_WMENG_OLD_sum + avbep-wmeng.
XX_WMENG_AKT_sum = XX_WMENG_AKT_sum + xx_vbep-wmeng.
endif.
else.
XX_WMENG_AKT_sum = XX_WMENG_AKT_sum + xx_vbep-wmeng.
endif.
endloop.Regards,
Nikhil.