Skip to end of metadata
Go to start of metadata

Author: Marcelo Ramos
Submitted: 19/11/2007

Related Links:

Class Definition

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
*----------------------------------------------------------------------*
*       CLASS a_one DEFINITION
*----------------------------------------------------------------------*
CLASS a_one DEFINITION.

  PUBLIC SECTION.
*   The constructor method must be definited on Public Section
*   Here we're definig a constructor method without parameters.
    METHODS constructor.

  PROTECTED SECTION.

    DATA attribute_a_one TYPE char10.

ENDCLASS.                    "a_one DEFINITION

*----------------------------------------------------------------------*
*       CLASS b_one DEFINITION
*----------------------------------------------------------------------*
CLASS b_one DEFINITION INHERITING FROM a_one.

  PUBLIC SECTION.

    METHODS constructor.

  PROTECTED SECTION.

    DATA attribute_b_one TYPE char10.

    METHODS print_attribute IMPORTING value TYPE char10.

ENDCLASS.                    "b_one DEFINITION

Class Implementation

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
*----------------------------------------------------------------------*
*       CLASS a_one IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS a_one IMPLEMENTATION.

  METHOD constructor.
*   Inside Construcot we can initialize attributes, call othres methods, etc...
    MOVE 'A_ONE' TO me->attribute_a_one.

  ENDMETHOD.                    "CONSTRUCTOR

ENDCLASS.                    "a_one IMPLEMENTATION

*----------------------------------------------------------------------*
*       CLASS b_one IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS b_one IMPLEMENTATION.

  METHOD constructor.

*   The Constructor Method must call the constructor of the superclass
*   during inheriting using "SUPER->CONSTRUCTOR"
    super->constructor( ).

    print_attribute( me->attribute_a_one ).

    MOVE 'B_ONE' TO me->attribute_b_one.

    print_attribute( me->attribute_b_one ).

  ENDMETHOD.                    "constructor

  METHOD print_attribute.

    WRITE: / value.

  ENDMETHOD.                    "print_attribute

ENDCLASS.                    "b_one IMPLEMENTATION

Defining Objects

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
DATA o_a_one TYPE REF TO a_one.
DATA o_b_one TYPE REF TO b_one.
DATA o_two   TYPE REF TO two.
DATA o_twox  TYPE REF TO two.

Instance Creation

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
START-OF-SELECTION.

* As Constructor of class one doesn't has parameters we can create its object as follow
  CREATE OBJECT o_a_one.

* As Class b_one was inherited by a_one its we can create its objects the same way as super class
  CREATE OBJECT o_b_one.

* As parameter was definited as Optional we can pass the parameter during object instantiation.
  CREATE OBJECT o_two
    EXPORTING
      value = 'Value Y'.

* Or we can just pass a null value Like value = ' '. or value = SPACE.
  CREATE OBJECT o_two
    EXPORTING
      value = ' '.

* As parameter was definited as Optional we can miss the parameter during object instantiation.
  CREATE OBJECT o_twox.

2 Comments

  1. Unknown User (uanlq16)

    Hello Marcelo,

    Right now I played through all your examples. Your fifth program fails:

    These to References can't be referenced because there is no CLASS two in this program.

    DATA o_two   TYPE REF TO two.
    DATA o_twox  TYPE REF TO two.

    There appears a CLASS two in the sixth program. But this can hardly be implemented in the fifth!

    Overall, your 7 examples (except #1 and #5) are helpful and I very appreciate your effort (smile) .

    Cheers,

    Heinz

  2. Request to the author if he plz modify it as suggested by Heinz Horner.........Suman Karmakar