This program has a class, C1 with a method: meth1. This method has only one import parameter (input1). Look at the method implementation for details. The main purpose of this program is to demonstrate the different ways of calling a method with single import parameter.
------------------------------------------------------------------------------------------
REPORT YSUBDEL.
CLASS C1 DEFINITION.
PUBLIC SECTION.
DATA: NUM TYPE I VALUE 5.
METHODS: METH1 IMPORTING INPUT1 TYPE I .
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD: METH1.
num = NUM * INPUT1 .
WRITE:/5 NUM .
num = 5.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA: OREF1 TYPE REF TO C1.
CREATE OBJECT: OREF1.
* Different ways of calling the method with one import parameter
CALL METHOD OREF1->METH1 EXPORTING INPUT1 = 4.
CALL METHOD OREF1->METH1( INPUT1 = 5 ).
CALL METHOD OREF1->METH1( 6 ).
Output 20
25
30
------------------------------------------------------------------------------------------
REPORT YSUBDEL.
CLASS C1 DEFINITION.
PUBLIC SECTION.
DATA: NUM TYPE I VALUE 5.
METHODS: METH1 IMPORTING INPUT1 TYPE I .
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD: METH1.
num = NUM * INPUT1 .
WRITE:/5 NUM .
num = 5.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA: OREF1 TYPE REF TO C1.
CREATE OBJECT: OREF1.
* Different ways of calling the method with one import parameter
CALL METHOD OREF1->METH1 EXPORTING INPUT1 = 4.
CALL METHOD OREF1->METH1( INPUT1 = 5 ).
CALL METHOD OREF1->METH1( 6 ).
Output 20
25
30
excellent boss thank you for all these examples
ReplyDeleteThe events example is so sweet thnq once again
Regards,
Amar
very good examples for o abap . thanks alot
ReplyDelete