2009 Nov 24 12:39 PM
Hi,
I have a method which is potentially slow (due to remote RFC connections).
Therefore I want to check which of the export parameters the caller actually requested. I found IS SUPPLIED for this purpose.
Unfortunately the method is also long and I would like to split it into some private method calls inside. But when I make a nested call into a submethod, the IS SUPPLIED method in there does not work anymore, since from the main method it is always requested.
Is there any easy way to come around this problem? Otherwise I will have to remember some booleans "XXX_IS_SUPPLIED" in the main method and pass them into the sub methods.
Thanks
Bruno
Edited by: Bruno Haller on Nov 24, 2009 1:39 PM
2009 Nov 24 1:13 PM
Is it possible to split into methods in which every (sub)method uses exactly one parameter. This way, per method you can check the via IS SUPPLIED.
IF p1 IS SUPPLIED
CALL METHOD m1
ENDIF.
IF p2 IS SUPPLIED
CALL METHOD m2
ENDIF.
If this is not possible I would go for some booleans defined in the attributes of the class itself. That way you don't have to pass to every (sub)method or even submethod within a (sub)method.
Hi,
I have a method which is potentially slow (due to remote RFC connections).
Therefore I want to check which of the export parameters the caller actually requested. I found IS SUPPLIED for this purpose.
Unfortunately the method is also long and I would like to split it into some private method calls inside. But when I make a nested call into a submethod, the IS SUPPLIED method in there does not work anymore, since from the main method it is always requested.
Is there any easy way to come around this problem? Otherwise I will have to remember some booleans "XXX_IS_SUPPLIED" in the main method and pass them into the sub methods.
Thanks
Bruno
Edited by: Bruno Haller on Nov 24, 2009 1:39 PM
2009 Nov 24 1:13 PM
Is it possible to split into methods in which every (sub)method uses exactly one parameter. This way, per method you can check the via IS SUPPLIED.
IF p1 IS SUPPLIED
CALL METHOD m1
ENDIF.
IF p2 IS SUPPLIED
CALL METHOD m2
ENDIF.
If this is not possible I would go for some booleans defined in the attributes of the class itself. That way you don't have to pass to every (sub)method or even submethod within a (sub)method.
2009 Nov 24 2:14 PM
What I think you can do is:
- check if parameter is not initial in submethod -> this however will not always be true as you might pass empty param on purpose
- make importing parameter of submethod optional , then write two calls of submethod, one with passing you parameter when in method it is supplied , the other one without the parameter - if not supplied.
class lcl1 DEFINITION.
public SECTION.
methods: m1 importing i_par type c optional,
m2 IMPORTING i_par type c OPTIONAL.
endclass.
class lcl1 IMPLEMENTATION.
method m1.
if i_par is SUPPLIED.
m2( i_par = i_par ).
else.
m2( ).
endif.
ENDMETHOD.
method m2.
if i_par is SUPPLIED.
write: / 'Parameter is supplied'.
else.
write / 'Parameter is not supplied'.
endif.
endmethod.
ENDCLASS.
data:r type ref to lcl1.
START-OF-SELECTION.
CREATE OBJECT r.
write: / 'First call'.
r->m1( ).
write / 'Second call'.
r->m1( 'X' ).
Regards
Marcin
2009 Nov 24 2:17 PM
Hi,
yes will work also. Unfortunately the "combinations" of supplied or not supplied parameters are high and therefore calling the method differently is not really an option.
I suppose it will be best to remember this from the main method.
Thanks
Bruno
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |