Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

loop at itab where..

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

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.

13 REPLIES 13

Former Member
0 Kudos

Hi,

Try this

LOOP AT ITAB WHERE BSART IN ( 'XXXX' , 'YYYY' , 'ZZZZ' )

Regards,

Surinder

0 Kudos

>

> Try this

>

> LOOP AT ITAB WHERE BSART IN ( 'XXXX' , 'YYYY' , 'ZZZZ' )

> Surinder

STNTAX ERROR

former_member223537
Active Contributor
0 Kudos

Hi,

Loop at itab where doctype = 'XXX' or
                           doctype = 'YYY' or
                           doctype = 'ZZZ'.




Endloop.

Best regards,

Prashant

Former Member
0 Kudos

Hi Jayasree,

U can try this...

LOOP AT ITAB WHERE BSART IN ( 'XXXX' , 'YYYY' , 'ZZZZ' ).

This should work...

Regards,

Navin

0 Kudos

>

> 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!!

0 Kudos

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?

Former Member
0 Kudos

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

naveen_inuganti2
Active Contributor
0 Kudos

Hi...

You cantry like this..,

loop at itab Field1 = A or Field1 = B or Field1 = C

Thanks,

Naveen.I

Former Member
0 Kudos

Hi Jayasri,

Use :

Loop at itab where BSART = 'XXX' or BSART = 'YYY' or

BSART = 'ZZZ'.

Regards,

Chandra Sekhar

former_member188685
Active Contributor
0 Kudos

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.

0 Kudos

Hi vijay,

I am new to this syntax.Let me try once.Thank u.

0 Kudos

Thank u Vijay,

my problem is solved. It's working fine.

Former Member
0 Kudos

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.