on 06-20-2018 4:46 PM
Hello experts,
I have a function module with 7 input parameters, 4 of these are mandatory but 3 are optional. In WHERE of select statement i need a condition like:
SELECT *
FROM knvh
WHERE vkorg = in_vkorg AND vtweg = in_vtweg AND spart = in_spart AND hkunnr eq IN_hkunnr AND name1 = in_name1 AND ort01 = in_ort01 AND kunnr = in_kunnr.
* name1, ort01 and kunnr are optional
It works if user insert all import parameters. But If user doesnt insert optional parameters the function module return an empty table. I need something where if user dont insert optional parameters the funct module return a table with every possible value of name1, ort01 and kunnr.
It's possible to achieve this setting * (all values) in default values of optional parameters? Or via abap? If via abap how i can change the WHERE clause?
Thanks!
What Nic said. Though you could define some ranges for the fields name1, ort01 and kunnr and fill these prior to the execution of the SQL statement (depending of course whether the parameters are supplied or not).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Eugenio
You could use a "Dynamic Where Clause" for that, adding Syntax to your Where-Clause depending on which Parameters are filled ...
For an Example see this link ...
"Create a String-Table LT_WHERE_CLAUSE
"Add the SQL-Syntax whenever data from Parameters is provided
SELECT *
FROM knvh
WHERE vkorg = in_vkorg
AND vtweg = in_vtweg
AND spart = in_spart
AND hkunnr = in_hkunnr
AND ( lt_where_clause ).
See some examples on the Web for this to get an idea on how you can make this work ...
Hope this helps.
Nic T.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.