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: 

paremeters in selection screen

Former Member
0 Kudos

Hi,

i have 3 parameters p1 p2 p3

p1 is OBLIGATORY and p2 p3 is not

select *

into wa

from link

where f1 = p1 and

f2 = p2 and

f3 = p3.

the sy-bubrc = 4.

but in table link ,there are values .

how to write this. i don't want to write this select laguage several times

9 REPLIES 9

Former Member
0 Kudos

because in input screen ,i have not input p2 p3

and in select ,it read p2 p3 as 0.

so i can't got values,the sy-subrc = 4

but i no if it is select-options

we can use

select

..

..

where f1 in s1.

because the parameters which is optional to input can't use this

Edited by: hongtan zhang on Sep 20, 2008 5:16 AM

Edited by: hongtan zhang on Sep 20, 2008 5:16 AM

Former Member
0 Kudos

hi,

your parameter defintion is not proper

what are all the field u r giving it as reference to these parameters

and then in select query for f1,f2,f3 you are giving 3 combinations

it should be ther

just check it

Former Member
0 Kudos

Hi,

Here so many constraints are to be considered.

Use the following code.

parameters: p1 type link-f1,

p2 type link-f2,

p3 type link-f3.

data: wa type standard table of link.

select *

into wa

from link

where f1 = p1

and f2 = p2

and f3 = p3.

Former Member
0 Kudos

Hello,

If you use paramers in the selcetion screen if no values passed then it will consider as SPACE.

PARAMETERS: p_vkorg TYPE vkorg,

p_vkbur TYPE VKBUR.

SELECT SINGLE * FROM Zxxx

INTO Zxxx

where bukrs = '0434'

AND vkorg = p_vkorg " 'CHAA'

AND VKBUR = p_vkbur. "'CHR0'.

Try this type of query.

U can use SELECT-OPTIONS in these cases..

Former Member
0 Kudos

Hi

Try declaring P2 and P3 as

SELECT-OPTIONS: p2 for field2 NO-INTERVAL NO-EXTENSION,

p2 for field3 NO-INTERVAL NO-EXTENSION.

select *

into wa

from link

where f1 = p1 and

f2 IN p2 and

f3 IN p3.

Former Member
0 Kudos

Hi,

Create dynamic where condition based upon user input.

Try like this....



IF NOT p1 IS INITIAL.
CLEAR : lv_p1_condition.
CONCATENATE 'F1' ' = ' '''' p1 '''' INTO
lv_p1_condition.
ENDIF.

IF NOT p2 IS INITIAL.
CLEAR : lv_p2_condition.
CONCATENATE 'F2' ' = ' '''' p2 '''' INTO
lv_p2_condition.
ENDIF.

IF NOT p3 IS INITIAL.
CLEAR : lv_p3_condition.
CONCATENATE 'F3' ' = ' '''' p3 '''' INTO
lv_p3_condition.
ENDIF.


IF NOT lv_p1_condition IS INITIAL.
CONCATENATE lv_p1_condition lv_condition
INTO lv_condition SEPARATED BY space.
ENDIF.

IF NOT lv_p2_condition IS INITIAL.
IF lv_condition IS INITIAL.
CONCATENATE lv_p2_condition lv_condition
INTO lv_condition SEPARATED BY space.
ELSE.
CONCATENATE lv_condition 'AND' lv_p2_condition
INTO lv_condition SEPARATED BY space.
ENDIF.
ENDIF.

IF NOT lv_p3_condition IS INITIAL.
IF lv_condition IS INITIAL.
CONCATENATE lv_p3_condition lv_condition
INTO lv_condition SEPARATED BY space.
ELSE.
CONCATENATE lv_condition 'AND' lv_p3_condition
INTO lv_condition SEPARATED BY space.
ENDIF.
ENDIF.


SELECT * FROM link INTO wa
WHERE lv_condition . " Dynamic where condition

Hope it will helps

Former Member
0 Kudos

declare internal table vbak .

PARAMETERS: P_VKORG TYPE VBAK-VKORG OBLIGATORY,

P_VTWEG TYPE VBAK-VTWEG ,

P_SPART TYPE VBAK-SPART .

SELECT VBELN

AUART

NETWR

VKORG

VTWEG

SPART

KNUMV

KUNNR FROM VBAK INTO TABLE ITAB_VBAK WHERE VKORG = P_VKORG

AND VTWEG = P_VTWEG

AND SPART = P_SPART.

Former Member
0 Kudos

hi,

the problem seems to be with the query .

as from the paramters theres only one field P1 thats obligatory

and the values of P2 and P3 might not be fetched.

In the select query you are using 'AND'

thats y sy-subrc = 4.

so change the select query to

select single *

into wa

from link

where c1 = P1 or

c2 = P2 or

c3 = P3.

OR

you can put all the 3 parameters as obligatory.

former_member212653
Active Contributor
0 Kudos

Try this simple code:


data: wa_tab1 type tab1.
select-options: 
s_p1 for wa_tab1-f1 NO-EXTENSION NO INTERVALS obligatory,
s_p2 for wa_tab1-f2 NO-EXTENSION NO INTERVALS,
s_p3 for wa_tab1-f3 NO-EXTENSION NO INTERVALS.

select * tab1 into itab1
where f1 in s_p1 and
         f2 in s_p2 and
         f3 in s_p3.
if sy-subrc = 0.

endif.