Passing a SELECT-OPTIONS table as a parameter to a subroutine?
-
22-06-2021 - |
Pregunta
So i have this:
SELECT-OPTIONS gr_saord FOR gv_sales_order OBLIGATORY.
then
PERFORM check_values CHANGING gr_saord.
then
FORM check_values CHANGING p_gr_saord TYPE selopt.
What i also tried was instead of the structure SELOPT
to use the Table Type piq_selopt_t
and instead of passing gr_saord
to pass gr_saord[]
.
The presented version of the code and the alternative result both in the same error message:
in PERFORM or CALL FUNCTION "CHECK_VALUES", the actual parameter "GS_SAORD" is incompatible with the formal parameter "P_GR_SAORD".
Basically i want to simply pass a SELECT-OPTIONS
table as a parameter and can't manage to do it.
Solución
It's because selopt and piq_selopt_t are not for vbak-vbeln. Low and High are typed differently in those data types compared to your select option.
This should work
data: gv_sales_order type vbap-vbeln.
types: tr_vbeln like RANGE OF gv_sales_order.
SELECT-OPTIONS: gs_saord for gv_sales_order.
perform check_values CHANGING gs_saord[].
form check_values CHANGING p_gr_saord TYPE tr_vbeln.
endform.
Otros consejos
If you are lazy (and have a lot select options to pass) and you onyl need to pass them to a select statement within your FORM, you can skip the type definition and define you form with
perform check_values CHANGING gs_saord[].
form check_values CHANGING p_gr_saord TYPE standard table.
endform.