2023 Feb 20 6:38 PM
Hi!
I have the use case that I want to modify an importing parameter of a standard method.
I created in Enhancement Mode an overwrite method, where I move the importing parameter to a local structure, change the relevant field and then call me->core_object->method.
But there is an ugly recursion.
Is there a chance to call the original method directly skipping the replacement?
2023 Feb 20 8:05 PM
I would call it an endless failing recursion rather than just "ugly".
You can use an implicit source code enhancement at the beginning of the method instead of an overwrite method.
You need to define an attribute CALLED_BY_MYSELF in the class which has the initial value abap_false.
There will be a 2-times recursive call, which I would find the words "ugly recursion" better suited 😉 so I would of course try to find another solution if possible.
METHOD ...
""""""""""""""""""""
ENHANCEMENT ...
IF called_by_myself = abap_false.
called_by_myself = abap_true.
CALL METHOD the_method ... " myself with changed input parameters
RETURN.
ENDIF.
called_by_myself = abap_false.
ENDENHANCEMENT.
2023 Feb 20 8:05 PM
I would call it an endless failing recursion rather than just "ugly".
You can use an implicit source code enhancement at the beginning of the method instead of an overwrite method.
You need to define an attribute CALLED_BY_MYSELF in the class which has the initial value abap_false.
There will be a 2-times recursive call, which I would find the words "ugly recursion" better suited 😉 so I would of course try to find another solution if possible.
METHOD ...
""""""""""""""""""""
ENHANCEMENT ...
IF called_by_myself = abap_false.
called_by_myself = abap_true.
CALL METHOD the_method ... " myself with changed input parameters
RETURN.
ENDIF.
called_by_myself = abap_false.
ENDENHANCEMENT.
2023 Feb 24 3:17 PM
Thank you! Simple and ingenious! That I had not thought of that...