Steps:
- Enter the transaction code : SE38.
- Enter the program name , start's with Y or Z<program name > and click on create.
- Enter the Title,
- Enter attribute Type as : Executable program.
- Click on Save .
Note :
- Instance methods are defined using METHODS key word.
- Static methods are defined using CLASS-METHODS key word.
- Class definition and declaration of methods as follows.
CLASS C1 DEFINITION.
PUBLIC SECTION.
METHODS : M1.
CLASS-METHODS :M2.
PROTECTED SECTION.
METHODS : M3.
CLASS-METHODS : M4.
PRIVATE SECTION.
METHODS : M5.
CLASS-METHODS : M6.
ENDCLASS.
Note :
- M1 method is known as instance public method.
- M2 method is known as static public method.
- M3 method is known as instance protected method.
- M4 method is known as static protected method.
- M5 method is known as instance private method.
- M6 method is known as static private method.
- Implement the methods.
CLASS C1 IMPLEMENTATION.
METHOD M1.
WRITE : / 'AM M1'.
ENDMETHOD.
METHOD M2.
WRITE : / 'AM M2'.
ENDMETHOD.
METHOD M3.
WRITE : / 'AM M3'.
ENDMETHOD.
METHOD M4.
WRITE : / 'AM M4'.
ENDMETHOD.
METHOD M5.
WRITE : / 'AM M5'.
ENDMETHOD.
METHOD M6.
WRITE : / 'AM M6'.
ENDMETHOD.
ENDCLASS.
- Save -> Check -> Activate.
- Local class is created.
Usage of Class.
Source code
CLASS C1 DEFINITION.
PUBLIC SECTION.
METHODS : M1.
CLASS-METHODS :M2.
PROTECTED SECTION.
METHODS : M3.
CLASS-METHODS : M4.
PRIVATE SECTION.
METHODS : M5.
CLASS-METHODS : M6.
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD M1.
WRITE : / 'AM M1'.
ENDMETHOD.
METHOD M2.
WRITE : / 'AM M2'.
ENDMETHOD.
METHOD M3.
WRITE : / 'AM M3'.
ENDMETHOD.
METHOD M4.
WRITE : / 'AM M4'.
ENDMETHOD.
METHOD M5.
WRITE : / 'AM M5'.
ENDMETHOD.
METHOD M6.
WRITE : / 'AM M6'.
ENDMETHOD.
ENDCLASS.
DATA : OBJ TYPE REF TO C1.
START-OF-SELECTION.
CREATE OBJECT OBJ.
CALL METHOD OBJ->M1.
CALL METHOD C1=>M2.
No comments:
Post a Comment