I want to avoid copy+paste in my function and want to create a subroutine.
But this fails.
Here is the function (I removed unimportant parts):
FUNCTION /foo/bar .
*"----------------------------------------------------------------------
*" IMPORTING
*" VALUE(IV_STATIC_PARAMETER_LIST) TYPE WDY_KEY_VALUE_LIST
*"----------------------------------------------------------------------
data selection_table TYPE TABLE OF RSPARAMS.
PERFORM GET_REPORT_READ_PARAMETER
USING IV_DYNAMIC_PARAMETER_LIST
CHANGING selection_table.
I get this error message:
Different number of parameters in FORM and PERFORM (routine: GET_REPORT_READ_PARAMETER, number of formal parameters: 4, number of actual parameters: 2)
The subroutine looks like this:
FORM GET_REPORT_READ_PARAMETER
USING parameter_list TYPE WDY_KEY_VALUE_LIST
CHANGING sel_table TYPE TABLE OF RSPARAMS.
....
ENDFORM
Any idea why ABAP thinks that there are 4 and not 2 parameters?
The error is in this line:
CHANGING sel_table TYPE TABLE OF RSPARAMS
By typing the parameter the above syntax is not valid, "OF
" and "RSPARAMS
" are interpreted as separate CHANGING
parameters.
You have to type the parameter directly with a table type (like you do for the USING
parameter). In this case it can be:
CHANGING sel_table TYPE RSPARAMS_TT.
RSPARAMS_TT is table type of RSPARAMS (you can check in SE11)