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

Parameters in Open SQL

Former Member
0 Likes
505

Hi,

I have defined a parameter:

PARAMETERS: p_param1 LIKE table-cod_param1

I need to use this parameter in a SQL Sentence and this parameter isn´t obligatory.

How I can build de sentence ?? I don´t have problems if the parameter is defined as select-options.

(this is an example, my sql sentence has many parameters)

Select * into it_table

from table

where cod_param1 = p_param1

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
424

Hi

Since this parameter is not an obligatory field it is always better to declare this as select options

SELECT-OPTIONS: p_param1 for table-cod_param1

if not p_param1[] is initial.

Select * into it_table

from table

where cod_param1 in p_param1.

endif.

If it is declared as parameter, when you don't enter a value it will take space as default value and fetch the wrong data.

where as in select options, even if you don't enter any value it will take all values and fetches the correct values.

Reward points if useful

Regards

Anji

2 REPLIES 2
Read only

Former Member
0 Likes
424

Hello,



PARAMETERS: p_param1 LIKE table-cod_param1

if p_param1 is initial.
Select * into it_table
from table .  " No where condition
else.
Select * into it_table
from table
where cod_param1 = p_param1
endif.

Regards,

Deepu.K

Read only

Former Member
0 Likes
425

Hi

Since this parameter is not an obligatory field it is always better to declare this as select options

SELECT-OPTIONS: p_param1 for table-cod_param1

if not p_param1[] is initial.

Select * into it_table

from table

where cod_param1 in p_param1.

endif.

If it is declared as parameter, when you don't enter a value it will take space as default value and fetch the wrong data.

where as in select options, even if you don't enter any value it will take all values and fetches the correct values.

Reward points if useful

Regards

Anji