‎2008 Sep 23 5:53 AM
Hi all,
Can I restrict for more than one value in my where condition for looping at internal table?
For ex. I have an internal table(ITAB) for purchase order details of different document types.I'ld like to call the data of only document type(BSART) = 'XXXX','YYYY','ZZZZ' only. How can write the loop statement . I have tried with LOOP AT ITAB WHERE BSART CS ( 'XXXX' , 'YYYY' , 'ZZZZ' ).But it's showing syntax error.please help.
‎2008 Sep 23 6:15 AM
You can use Ranges and use IN in Where condition.
data: r_basrt type range of bsart.
"populate the range values.
loop at itab where bsart in r_bsart.
endloop.
‎2008 Sep 23 5:54 AM
Hi,
Try this
LOOP AT ITAB WHERE BSART IN ( 'XXXX' , 'YYYY' , 'ZZZZ' )
Regards,
Surinder
‎2008 Sep 23 6:02 AM
>
> Try this
>
> LOOP AT ITAB WHERE BSART IN ( 'XXXX' , 'YYYY' , 'ZZZZ' )
> Surinder
STNTAX ERROR
‎2008 Sep 23 5:54 AM
Hi,
Loop at itab where doctype = 'XXX' or
doctype = 'YYY' or
doctype = 'ZZZ'.
Endloop.Best regards,
Prashant
‎2008 Sep 23 5:55 AM
Hi Jayasree,
U can try this...
LOOP AT ITAB WHERE BSART IN ( 'XXXX' , 'YYYY' , 'ZZZZ' ).
This should work...
Regards,
Navin
‎2008 Sep 23 6:04 AM
>
> Hi Jayasree,
>
> U can try this...
>
> LOOP AT ITAB WHERE BSART IN ( 'XXXX' , 'YYYY' , 'ZZZZ' ).
> This should work...
>
> Regards,
> Navin
Sorry It will not work!!
‎2008 Sep 23 6:16 AM
Yes,I have already tried that and got syntax error.
Of course, we can write conditions using OR if the doc. type values are two or three. Is there any other solution if there are no. of such particular values to be mentioned in WHERE condition?
‎2008 Sep 23 5:56 AM
Hi
I think you can try the following
Loop at itab where bsart = 'XXXX' or
bsart = 'YYYY' or
bsart = 'ZZZZ'.
endloop.
or
Loop at itab.
if itab-bsart = 'XXXX' or
itab-bsart = 'YYYY' or
itab-bsart = 'ZZZZ'.
endif.
endloop.
Regards
MD
‎2008 Sep 23 5:57 AM
Hi...
You cantry like this..,
loop at itab Field1 = A or Field1 = B or Field1 = CThanks,
Naveen.I
‎2008 Sep 23 6:00 AM
Hi Jayasri,
Use :
Loop at itab where BSART = 'XXX' or BSART = 'YYY' or
BSART = 'ZZZ'.
Regards,
Chandra Sekhar
‎2008 Sep 23 6:15 AM
You can use Ranges and use IN in Where condition.
data: r_basrt type range of bsart.
"populate the range values.
loop at itab where bsart in r_bsart.
endloop.
‎2008 Sep 23 6:17 AM
‎2008 Sep 23 6:27 AM
‎2008 Sep 23 6:26 AM
hi,
Try this below code. it will work.
loop at i_po_data into wa_po_data where bsart eq 'XYZ' or bsart eq 'ABC' or basrt eq 'PQR'.
endloop.
Regards,
Siva.