Using aliases for interface methods in SAP OOABAP

Using aliases concept in SAP classes, provide alternate names for interface methods in SAP classes

+ -
Aliases is a concept of providing alternate method names for interface methods in implemented class(where interface is implemented).

Whenever we implement an interface in a class, the method will be copied with INTERFACENAME~METHODNAME, see below example.

aliases in interface method By using aliases concept we can provide alternate name for interface methods and we can call methods with that name, to add alternate names click on aliases tab and provide altternate names.

aliase names in SAP Classes

Calling alias method is same as normal method CALL METHOD OBJECT->ALIASMETHDO NAME, see below example.

Please refer previous lesson Using interface class in SAP Classes for better understanding.
REPORT ZSAPN_CLASS_INTERFACE.
DATA : LO_CLASS TYPE REF TO ZCL_SAPN_CLASS_EX. "declare class

DATA : WA_MARA TYPE MARA. "mara decleration
DATA : WA_MAKT TYPE MAKT. "makt decleration

PARAMETERS P_MATNR TYPE MARA-MATNR.

CREATE OBJECT LO_CLASS. "create object for the class

START-OF-SELECTION.
  CALL METHOD LO_CLASS->GET_MATERIAL_DETAILS "alias name 
    EXPORTING
      IM_MATNR = P_MATNR
    IMPORTING
      EX_MARA  = WA_MARA.
  CALL METHOD LO_CLASS->GET_MATERIAL_DESCRIPTIONS "alias name
    EXPORTING
      IM_MATNR = P_MATNR
    IMPORTING
      EX_MAKT  = WA_MAKT.
  WRITE :/ 'Material Details - ' COLOR 5, WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MBRSH, WA_MARA-MATKL.
  WRITE :/ 'Material Descriptions - 'COLOR 6, WA_MAKT-MATNR, WA_MAKT-MAKTX, WA_MAKT-SPRAS.


Learner Questions


No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 30 People out of 30 think this lesson helpful


    Lesson Navigation

    ←Previous Chapter
    Next Lesson → Inheritance in SAP OOABAP