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: 

select-options in where condition of select statement

Former Member
0 Kudos
15,524

I have to read from table vbak the vbeln and augru fields. In the where condition, I have to set the condition where the values of the fields from selection-screen(which are select-options type) must be equal to augru.

I have this statement:

SELECT vbeln

augru

FROM vbak

INTO TABLE i_vbak

WHERE augru IN s_rrets

AND augru IN s_rrefl

AND augru IN s_robst.

IF sy-subrc NE 0.

ENDIF.

s_rrets, s_rrefl and s_robst are of like vbak-augru.

Why my sy-subrc returns 4 which means I haven't retrieved any data from it?

8 REPLIES 8

Former Member
0 Kudos
3,133

hi,

try to change the and condition to or.

chk this code..

SELECT vbeln

augru

FROM vbak

INTO TABLE i_vbak

WHERE augru IN s_rrets <b>or</b> augru IN s_rrefl

<b>or</b> augru IN s_robst.

IF sy-subrc NE 0.

ENDIF.

regards,

Navneeth K.

Former Member
0 Kudos
3,133

Hi,

Hv u checked in the table VBAK if there is any data for the conditions u are specifying.

2nd thing I dont understand is that whats the need of giving three select-options for the same field AUGRU.

Regards,

Himanshu

Former Member
0 Kudos
3,133

i cant understand why 3 select options are there for a single field one select option is enough for your requirement. If you have to give three different ranges or three different single value then just click the arrow button beside the select option for giving the range(including) click the green range tab(for single(including) green single) and for excluding some ranges or value click on the red tabs.

now write your query

SELECT vbeln

augru

FROM vbak

INTO TABLE i_vbak

WHERE augru IN s_rrets.

IF sy-subrc NE 0.

ENDIF.

regards

shiba dutta

sharadendu_agrawal
Active Participant
0 Kudos
3,133

Hi Florianne,

No need to give three select options for augru. U can give it in only as one select option and can make it a range by clicking on the arrow button nxt to the right hand side selct option .

Further u shud also check whether the required data exists in the table or not.

U can write ure select query as

SELECT vbeln

augru

FROM vbak

INTO TABLE i_vbak

WHERE augru IN s_rrets.

Hope this solves ure pblem.

Reward if helpful.

Cheers,

Sharadendu

Former Member
0 Kudos
3,133

Now try the below one it was working for me .......

select-options  : s_rrets  for   vbak-augru ,
                        s_rrefl for   vbak-augru ,
                        s_robst  for   vbak-augru .

SELECT vbeln  augru     FROM vbak  INTO TABLE i_vbak
WHERE  ( augru IN s_rrets
PR  augru IN s_rrefl
OR augru IN s_robst  ). 

IF sy-subrc NE 0.
ENDIF.

reward points if it is usefull.......

Girish

Former Member
0 Kudos
3,133

I have three select-options displayed in the selection-screen. Each of which is of like vbak-augru.and answers should be checked with vbak-augru.

Well, I just changed and to or.

Thanks for your replies.

Former Member
0 Kudos
3,133

Hi ,

U can use one select option instead of three and use OR instead of AND in ur select condition.

Former Member
0 Kudos
3,133

Thanks and more power.