Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Access to class attributs by coding in its mother class method definition

Hi all,

How can I retrieve information about a class attributs by coding?

And is it possible to access to the attributs of the Child class from the Mother class?

REPORT  ztest_method.
 
*----------------------------------------------------------------------*
******      CLASS mother DEFINITION

CLASS mother DEFINITION.
  PUBLIC SECTION.
    METHODS: get_data.
ENDCLASS.                    "mother DEFINITION

*----------------------------------------------------------------------*
******      CLASS child DEFINITION

CLASS child DEFINITION inheriting from mother.
ENDCLASS.                    "child DEFINITION
*----------------------------------------------------------------------*
*******      CLASS mother IMPLEMENTATION

CLASS mother IMPLEMENTATION.

  METHOD get_data.
 ***Can I access to child class attributs here?
  ENDMETHOD.                    "get_data
 
ENDCLASS.                    "mother IMPLEMENTATION
 
DATA oref TYPE REF TO CHILD.
DATA: method TYPE string.
DATA: cla_name(20).
 
START-OF-SELECTION.
  
  CREATE OBJECT oref .
 
  CALL METHOD oref->method).  "Here I want to access to this class's attribut without redefine it

Not what you were looking for? View more on this topic or Ask a question