2007 May 22 5:27 PM
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
2007 May 22 5:35 PM
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
2007 May 22 5:30 PM
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
2007 May 22 5:35 PM
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