on ‎2021 Feb 26 11:43 AM
Hi all,
Any help would be appreciated!
I have a request to create Function Module with all inputs are optional.
All the inputs are from same table and I need to fetch the records accordingly.
Though, I made all the import parameters are optional but if I input anyone of the field value it is not returning with empty table.
Thank you!
Sample code snippet
SELECT * FROM VBFA INTO TABLE T_VBFA
WHERE VBELV = I_PRECEDINGDOC
AND POSNV = I_PRECEDINGITEM
AND VBELN = I_FOLLOWONDOC
AND POSNN = I_SUBSEQUENTITEM
AND VBTYP_N = I_SUBSDOCCATEG.
Request clarification before answering.
Hello vinayad
You've made them option, but that doesn't mean they don't have a value. They do, the value is empty. That's why your query is looking for a record which has fields with empty value.
What you can do in this case is create a range variable for each of the parameters. Then add a new record to the range with the parameter's value. Then use these ranges in the query.
Example in pseudo code below.
DATA:
lt_vbelv_range TYPE RANGE OF vbelv.
IF i_precedingdoc IS NOT INITIAL.
APPEND INITIAL LINE TO lt_vbelv_range REFERENCE INTO DATA(ld_vbelv).
ld_vbelv->sign = 'I'.
ld_vbelv->option = 'EQ'.
ld_vbelv->low = i_precedingdoc.
ENDIF.
SELECT * FROM vbfa INto TABLE t_vbfa WHERE vbelv IN lt_vbelv_range.
" do the same for other parameters and put them in the same queryKind regards,You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I really appreciate your help !
Convert the parameters into range, don't check value initial, for example an initial value for a flag.checkbox is a specified value and must not be ignored
Copy mateuszadamus's code and replace the IS INITIAL criteria with IS SUPPLIED.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 11 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.