标签:raise methods amp red esc hand describe 不同 ase
*&---------------------------------------------------------------------*
*& Report Z_TEST1_CLASSLI
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z_TEST1_CLASSLI.
**********************************************************************
*REPORT DESCRIBE:李顾问讲的面向对象
*DEVELOPER:SALAH
*DEVELOP DATE:20191020
*MODIFY DATE:
*FUNCTION SPEC:
*KEY USER:
**********************************************************************
CLASS CL1 DEFINITION.
PUBLIC SECTION.
CLASS-DATA I TYPE I.""第一个应用变量改变静态变量的之后,第二个应用变量调用静态变量时,使用的仍是它改变后的值。
* DATA I TYPE I.
METHODS:M1.
METHODS:M2.
PRIVATE SECTION.
DATA J TYPE I VALUE 2.
ENDCLASS.
CLASS CL1 IMPLEMENTATION.
METHOD M1 .
DO J TIMES.
ADD 1 TO I.
WRITE :/ I.
ENDDO.
ENDMETHOD.
METHOD M2.
WRITE:‘FIRST‘.
ENDMETHOD.
ENDCLASS.
DATA ZCL1 TYPE REF TO CL1.
DATA ZCL11 TYPE REF TO CL1.
START-OF-SELECTION.
CREATE OBJECT ZCL1.
CALL METHOD ZCL1->M1.
CALL METHOD ZCL1->M2.
*CREATE OBJECT ZCL11.
*CALL METHOD ZCL11->M1.
*CALL METHOD ZCL11->M2.
WRITE CL1=>I."只能调用静态变量
CLASS CL2 DEFINITION.
PUBLIC SECTION .
METHODS:M1 IMPORTING I TYPE I
RETURNING VALUE(J) TYPE I.
ENDCLASS.
CLASS CL2 IMPLEMENTATION.
METHOD M1.
J = I ** 2.
ENDMETHOD.
ENDCLASS.
DATA GV_INT TYPE I.
DATA ZCL2 TYPE REF TO CL2.
START-OF-SELECTION.
CREATE OBJECT ZCL2 .
GV_INT = ZCL2->M1( 3 ).
WRITE:/ GV_INT.
CLASS CL3 DEFINITION.
PUBLIC SECTION.
DATA TE TYPE I.
METHODS:CONSTRUCTOR."构造方法:一般可以对属性的值进行修改
METHODS:OUT.
ENDCLASS.
CLASS CL3 IMPLEMENTATION.
METHOD CONSTRUCTOR .
TE = 100.
ENDMETHOD.
METHOD OUT.
WRITE:SY-ULINE.
WRITE :TE.
ENDMETHOD.
ENDCLASS.
DATA ZCL3 TYPE REF TO CL3.
START-OF-SELECTION.
CREATE OBJECT ZCL3.
CALL METHOD ZCL3->OUT.
CLASS CL4 DEFINITION INHERITING FROM OBJECT.
PUBLIC SECTION.
DATA: PUB TYPE C VALUE ‘X‘..
METHODS ME_PUB.
PROTECTED SECTION.
DATA: PRO TYPE I VALUE 1.
PRIVATE SECTION.
DATA