Working with Interfaces

...Previous

Create a program in SE38.

Provide the code.

*&---------------------------------------------------*
*& Report  ZCL_INTERFACE                             *
*&---------------------------------------------------*
REPORT  ZCL_INTERFACE .
*provide mara table
DATA: MARA TYPE MARA.
*provide data objects
DATA: OBJ TYPE REF TO ZCL_INTERFACE,
      IT_MARA TYPE Z_MARA,
      WA_MARA TYPE MARA.
*provide selection screen
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
*provide object
START-OF-SELECTION.
  CREATE OBJECT OBJ.
*call the method.
  CALL METHOD OBJ->ZIF_INTERFACE~SELECT_METHOD
    EXPORTING
      P_MATNR_LOW  = S_MATNR-LOW
      P_MATNR_HIGH = S_MATNR-HIGH
    IMPORTING
      IT_MARA      = IT_MARA
      WA_MARA      = WA_MARA.
*display the data
  LOOP AT IT_MARA INTO WA_MARA.
    WRITE:/ WA_MARA-MATNR,
            WA_MARA-ERSDA,
            WA_MARA-ERNAM,
            WA_MARA-MATKL,
            WA_MARA-MEINS.
  ENDLOOP.

Then save it, check it ,activate it then execute it the output is like this.

The output is see in the list.

 

What is the use of aliases.

ALIASES:

This is the aliases name. it is only for interfaces.

Go to se24.

Then go to aliases tab.

Then provide another name for the interface method.

Then provide public.

Save it, check it, activate it.

Then go to SE38.

Change the method name also.

*&---------------------------------------------------------------------*
*& Report  ZCL_INTERFACE                                               *
*&                                                                     *
*&---------------------------------------------------------------------*
REPORT  ZCL_INTERFACE .
*provide mara table
DATA: MARA TYPE MARA.
*provide data objects
DATA: OBJ TYPE REF TO ZCL_INTERFACE,
      IT_MARA TYPE Z_MARA,
      WA_MARA TYPE MARA.
*provide selection screen
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
*provide object
START-OF-SELECTION.
  CREATE OBJECT OBJ.
*call the method.
*  CALL METHOD OBJ->ZIF_INTERFACE~SELECT_METHOD
  CALL METHOD OBJ->SEL
    EXPORTING
      P_MATNR_LOW  = S_MATNR-LOW
      P_MATNR_HIGH = S_MATNR-HIGH
    IMPORTING
      IT_MARA      = IT_MARA
      WA_MARA      = WA_MARA.
*display the data
  LOOP AT IT_MARA INTO WA_MARA.
    WRITE:/ WA_MARA-MATNR,
            WA_MARA-ERSDA,
            WA_MARA-ERNAM,
            WA_MARA-MATKL,
            WA_MARA-MEINS.
  ENDLOOP.

The output would be as shown below:.

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image