Reputation: 193
I am trying to build a dynamic method and I need to pass any range table to it. So I want to make sure a) only a range can be passed or b) I leave the processing if the provided table is not a range. So my question would be:
Is there a way to define a method so the importing parameter has to be a range table (any type of range table)?
If there isn't any good was I would do it like this to check if the importet table is a range.
1) I would check for a table header.
Methods: this_method
IMPORTING
i_table TYPE any table.
IF i_table IS INITIAL.
"do some code
ENDIF.
If this doesn't work I'll take the longer way.
2) I would use cl_abap_*descr classes to find out if the passed table has fields named "sign", "option", "low", high".
Upvotes: 2
Views: 3417
Reputation: 3713
There isn't an equivalent of "any range table" typed parameter.
Your second option with RTTS
would work.
Another option with a better performance that can only approve if the parameter is not of range table type, is to assign SIGN
, OPTION
etc... components of the first line if exists and then check IS NOT ASSIGNED
.
Upvotes: 3