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

if statement

Former Member
0 Likes
1,374

Hi,

can you please correct my code:

<b>select-options: s_werks for marc-werks.</b>

.......................

......................

form get_data.

<b>if s_werks EQ 'KNX'.</b>

*-- Here the if statement is not working. Can you please correct this IF statement, if it is wrong.

<b> select * from mdkp

where matnr = i_mara-matnr.

......................

.....................

endif.</b>

Thanks,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,344

if s_werks-LOW eq EQ 'KNX'

14 REPLIES 14
Read only

Former Member
0 Likes
1,345

if s_werks-LOW eq EQ 'KNX'

Read only

0 Likes
1,344

John,

i have a small doubt,

is the statement

if s_werks-LOW eq EQ 'KNX'

checks only the first value or the entire range?

If only first value, lets assume 'KNX' exist in middle then how ?

sailesh

Read only

0 Likes
1,344

Checks only first value... that is why I asked if you truly need a SELECT_OPTIONS statement. If the user can enter multiple values, then use "IN s_werks".

Or simply LOOP thru the internal table S_WERKS.

Read only

Former Member
0 Likes
1,344

sey,

u can't use if s_werks EQ 'KNX'.

as s_Werks is a select-option and it will be having multiple entries so can't use 'EQ'.

where u can use

<b>loop at s_werks.

if s_werks-low eq 'KNX'.

endif.

endloop.</b>

-Anu

Message was edited by: Anupama Reddy

Message was edited by: Anupama Reddy

Message was edited by: Anupama Reddy

Read only

Former Member
0 Likes
1,344

Thnx John.

It worked!!!! But still there's a problem

if I have multiple values for S_WERKS, it wont work, right?

Thnx.

Message was edited by: sey ni

Read only

0 Likes
1,344

sey,

loop at s_werks and in the loop check with each s_werks-low as given by me above post.

-Anu

Read only

0 Likes
1,344

Right you will need to loop at the select-option and check each one.

But that will only help when the user does single values, he could do ranges also, so you should take care of that as well. Suggestion, get all of the plants in the select-option from table t001w, then check each one.

data: it001w type table of t001w with header line.

select-options: s_werks for it001w-werks.

select * into table it001w from t001w
            where werks in s_werks.

loop at it001w.
<b>  if it00w1-werks = 'KNX'.
 

  endif.</b>

endloop.

Regards,

Rich Heilman

Read only

0 Likes
1,344

Thanks Folks,

Yeah. I got it now. As it is select-option, i hve to do the loop.

Thanks again for ur valuable responses, I appreciate that.

But I can give 10 points to only one of you :)-

Read only

0 Likes
1,344

Remember, just looping the select-option will not cover all of the bases, in order to cover the bases, you need to process as I show above.

Regards,

Rich Heilman

Read only

0 Likes
1,344

HI Sey,

Please give the points to appropriate person and close the thread. It also encourages the other persons.

sailesh

Read only

0 Likes
1,344

Yes, Rich. That's true. Thanks a lot for the help.

Read only

Clemenss
Active Contributor
0 Likes
1,344

Sey ni,

s_werks is a range table. It can be used with comparison operator IN.

ist it

<pre>

select * from mdkp

where PLWRK in s_werks

and matnr = i_mara-matnr.

</pre>

Sorry, I don't know your context.

Regards,

Clemens

Read only

Former Member
0 Likes
1,344

Bear in mind that SELECT-OPTIONS are range values associated with an internal table. The use of IN might be necessary... not sure of your needs. Do you need a select-options or will a parameter do the trick?

Read only

Former Member
0 Likes
1,344

I don't think I'bve seen it done this way, but try:

if 'KNX' in s_werks.

Rob