I have an ABAP-OO class where I want to call a function module inside a method foo( ). There are two cases (A & B) where I have to use method foo( ). Lets say case A is default and uses requires the function module like this:
METHOD foo.
CALL FUNCTION 'A_FUNCTION'
EXPORTING
required_param_x = something
required_param_y = something_else.
" optional_param = " i am commented out and only need for case B
ENDMETHOD.
Case B "is special" and also requires the optional_param above to be set. My current situation is to have a second method like that:
METHOD foo_b_case.
CALL FUNCTION 'A_FUNCTION'
EXPORTING
required_param_x = something
required_param_y = something_else
optional_param = case_b_stuff.
ENDMETHOD.
Of course, this is very redundant. My real life coding is also much more complex as shown above. My question is, how can I get rid of that method foo_b_case( ) and make foo( ) suitable for both cases?
Lets say, I make the paramter "case_b_stuff" optional and just pass it in each case. How does ABAP handle the "optional_param" if "case_b_stuff" is initial?