2022 Jun 17 11:06 AM
hi team,
this my code,
CLASS C2 DEFINITION.
PUBLIC SECTION.
DATA : A(10) TYPE n VALUE '2',
B(10) TYPE n VALUE '8',
C(10) TYPE n.
METHODS M2.
ENDCLASS.
CLASS C2 IMPLEMENTATION.
METHOD M2.
c = a + b.
ENDMETHOD.
ENDCLASS.
*
DATA : add TYPE REF TO C2.
*
START-OF-SELECTION.
CREATE OBJECT add .
CALL METHOD c2->M2.
would please correct it and tell me correct coding for getting output for value c.
2022 Jun 17 11:20 AM
Hi,
Please correct the code as below
CLASS C2 DEFINITION.
PUBLIC SECTION.
DATA : A(10) TYPE n VALUE '2',
B(10) TYPE n VALUE '8',
C(10) TYPE n.
METHODS M2.
ENDCLASS.
CLASS C2 IMPLEMENTATION.
METHOD M2.
c = a + b.
WRITE : c.
ENDMETHOD.
ENDCLASS.
*
DATA : add TYPE REF TO C2.
*
START-OF-SELECTION.
CREATE OBJECT add .
CALL METHOD add->M2.
2022 Jun 17 12:07 PM
*This is Complete answer or Correction
CLASS C2 DEFINITION.
PUBLIC SECTION.WRITE add->c
*Now this is complete
2022 Jun 17 2:29 PM
Please use the CODE button in the question/comment/answer editor. It makes code easier to read.
CLASS C2 DEFINITION.
PUBLIC SECTION.
DATA : A(10) TYPE n VALUE '2',
B(10) TYPE n VALUE '8',
C(10) TYPE n.
METHODS M2.
ENDCLASS.
CLASS C2 IMPLEMENTATION.
METHOD M2.
c = a + b.
ENDMETHOD.
ENDCLASS.
*
DATA : add TYPE REF TO C2.
*
START-OF-SELECTION.
CREATE OBJECT add .
CALL METHOD c2->M2.
Did you syntax check your code after writing it? The syntax checker will have told you your error.