‎2008 May 21 9:51 AM
Hi all,,
I have a loop containing material number, bwkey , bwtar.
And for the combination of material number and bwkey, we could find two records for different bwtar.
one record whose bwtar would be empty and
other record whose bwtar will hold some value.
The issue is, now while looping into the loop, am using the read stmt with the combination of material number and bwkey.
And i want to pick first the record whose bwtar holds some value.and next if i dont find bwtar which holds value, then i need to look for bwtar which is empty..
Could you please help us with the logic:
loop at internal table.
read table with combination of matnr&bwkey
If material has a bwtar
then i need this record
else
then i need to take record whose bwtar is empty.
‎2008 May 21 10:03 AM
Hi,
In READ statement you can not use the logical operators.
Better you take two internal tables one is to fill the records those having the BWTAR as blank and second one is to fill the records those are having some value for BWTAR field.
So that you can write READ statement for both of the internal tables as shown below.
loop at itab.
read table itab1 with key matnr = itab-matnr bwkey = itab-bwkey bwtar = ' '.
if sy-subrc ne 0.
read table itab2 with key matnr = itab-matnr bwkey = itab- bwkey.
endif.
endloop.
‎2008 May 21 9:55 AM
Hi ,
U can loop and read twice.
loop at internal table.
read table with combination of matnr&bwkey & bwtar <> space.
if sy-subrc = 0.
use the record.
else.
read table with combination of matnr&bwkey & bwtar = space
if sy-subrc = 0
use the record.
endif.
endif.
Thanks,
‎2008 May 21 9:59 AM
Hi naveena,
You do like this.
sort itab by matnr bwkey bwtar decending.
Loop at it_some.
read table itab with key matnr = it_some-matnr
bwkey = it_some-bwkey.
if sy-subrc = 0.
then do the process....
endif.
endloop.
You will get all the value entries.
Reward points.
Regards,
Madan.
‎2008 May 21 10:01 AM
Hi Naveena,
Then u have to sort ur itab accordingly.
SORT itab ASCENDING BY matnr bwkey DESCENDING by bwtar.
LOOP at table.
READ with matnr and bwkey
if sy-subrc is initial.
do ur processing
else.
do ur second processing.
endif.
ENDLOOP.
thanks,
Vinod.
‎2008 May 21 10:03 AM
Hi,
In READ statement you can not use the logical operators.
Better you take two internal tables one is to fill the records those having the BWTAR as blank and second one is to fill the records those are having some value for BWTAR field.
So that you can write READ statement for both of the internal tables as shown below.
loop at itab.
read table itab1 with key matnr = itab-matnr bwkey = itab-bwkey bwtar = ' '.
if sy-subrc ne 0.
read table itab2 with key matnr = itab-matnr bwkey = itab- bwkey.
endif.
endloop.