Application Development and Automation 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: 
Read only

Using "IN" Statement in LOOP

Former Member
0 Likes
4,481

Dear all experts,

When I try to do the below statement, i hit an error.

LOOP T_GLT0 WHERE RACCT IN ( '0001234567' , '0001233333' ) AND

BUKRS = S_BURKS.

Is this in LOOP statement I can't use "IN". If no, what is the alternate way to write this similiar statement ?

Many thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,068

LOOP T_GLT0 WHERE BUKRS = S_BURKS.

and (RACCT = '0001234567'

or RAACT = '0001233333').

11 REPLIES 11
Read only

Former Member
0 Likes
4,068

LOOP at T_GLT0 WHERE RACCT IN ( '0001234567' , '0001233333' ) AND

BUKRS = S_BURKS.

regds

Read only

Former Member
0 Likes
4,069

LOOP T_GLT0 WHERE BUKRS = S_BURKS.

and (RACCT = '0001234567'

or RAACT = '0001233333').

Read only

Former Member
0 Likes
4,068

Hi

Move these values '0001234567' , '0001233333' into a range and you can use that with IN statement

LOOP T_GLT0 WHERE RACCT IN r_racct AND BUKRS = S_BURKS.

or

In the Loop use if conditions for Racct and Bukrs.

Reward points if useful

Regards

Anji

Read only

Former Member
0 Likes
4,068

In a loop command this is not possible.

Try this.

LOOP at T_GLT0 where BUKRS = S_BURKS.

check RACCT IN ( '0001234567' , '0001233333' ).

.....

.......

endloop.

Reward points if helpfull.

Regards

Sachin

Read only

Former Member
0 Likes
4,068

Hi,

The In keyword inside the loop will work with Ranges. You declare a range and fill the two values in the range and use in the LOOP. Alternatively you can use

LOOP T_GLT0 WHERE ( RACCT EQ '0001234567' or RACCT EQ '0001233333' ) AND BUKRS = S_BURKS.

ENDLOOP.

Note : if SBUKRS is not a parameter then you have to use IN S_BUKRS instead of EQ SBUKRS.

Hope this helps.

Read only

dev_parbutteea
Active Contributor
0 Likes
4,068

LOOP T_GLT0 WHERE ( RACCT > 0001234567 ) and ( RACCT <'0001233333 ) ANDBUKRS = S_BURKS.

Regards ,

Sooness.

Read only

0 Likes
4,068

LOOP T_GLT0 WHERE ( RACCT < 0001234567 ) and ( RACCT > '0001233333 ) ANDBUKRS = S_BURKS.

Read only

Former Member
0 Likes
4,068

Hi Hong,

You can use IN operator for select options and ranges. you can not use in loop where clause.

You can achieve by create internaal table with all values in the given range by incrementing the value. Write nested loop for every racct.

do

increment racct starting from '0001234567'

and update it_racct.

enddo.

loop at it_racct.

loop at t_glto where racct it_racct-racct.

endloop.

endloop.

Thanks

Venkat

Read only

Former Member
0 Likes
4,068

Refer the following code:

REPORT  z_82235_test4                           .

data: gt_mara type table of mara,
      wa_mara like line of gt_mara.

RANGES: r_matnr FOR mara_matnr.


 r_matnr-SIGN = 'I'.
 r_matnr-OPTION = 'EQ'.
 r_matnr-LOW = '1'.
 r_matnr-HIGH = '1000'.


 select * from mara into table gt_mara up to 10 rows.


 LOOP AT gt_mara INTO wa_mara WHERE matnr in r_matnr.
     WRITE: wa_mara-matnr.
     clear: wa_mara.
ENDLOOP.

Read only

Former Member
0 Likes
4,068

Hi Hong Ming Tan,

U can use ranges to do so.

put these two value in range table R_RACCT.

refer this code :

**-- Initialization of ranges

R_RACCT-SIGN = 'I'.

R_RACCT-OPTION = 'EQ'.

R_RACCT-LOW = '0001234567'.

APPEND R_RACCT.

CLEAR R_RACCT.

R_RACCT-SIGN = 'I'.

R_RACCT-OPTION = 'EQ'.

R_RACCT-LOW = '0001233333'.

APPEND R_RACCT.

CLEAR R_RACCT.

loop at glt0 whrere bukrs = s_bukrs and racct in R_RACCT.

.........

.........

endloop.

Reward points if helpful.

Regards,

Hemant

Read only

Former Member
0 Likes
4,068

ranges : r_racct for <tablename>-racct.

*declare the tablename in which racct field is found

r_racct-sign = 'I'.

r_racct-option = 'EQ'.

r_racct-low = '0001234567'.

r_racct-high = ''.

append r_racct.

clear r_racct.

r_racct-sign = 'I'.

r_racct-option = 'EQ'.

r_racct-low = '0001233333'.

r_racct-high = ''.

append r_racct.

clear r_racct.

loop at t_glto

where racct in r_racct AND

burks in s_burks.

  • if burks u have declared in select option.

  • if s_burks is declared under parameter then use burks = s_burks.

if useful reward with points .