You are on page 1of 7

Case Study: OOABAP-Global Interface.

Business Requirement:
To create a global interface and display the vendor details using global interface.

numbers on selection screen.


Based on the input ,The vendor details will be displayed.
To have a very simple scenario on this, Lets enter vendor

Solution:
Go to se24 Tcode

Provide the global interface name as ZCL_GLOBAL_INTERFACE.

Page 1

02/28/2015

Click on the Create Button.


Select the radio button Interface.

Provide the Description.

Press Save button .Then we can view the scree like this

Page 2

02/28/2015

Provide method name as GET_VENDORS.

Save Check and Activate .

Go to SE38 and create program with name ZGLOBAL_INTERFACE.

Page 3

02/28/2015

Provide the description.

Save Check and Activate .

Write the following logic.


*Local class Definition
CLASS lcl_vendor DEFINITION.
PUBLIC SECTION.
INTERFACES zif_global_interface.
TYPES:
BEGIN OF t_vendor,
lifnr TYPE lifnr,

Page 4

02/28/2015

land1 TYPE land1_gp,


name1 TYPE name1_gp,
ort01 TYPE ort01_gp,
END OF t_vendor.
METHODS:display_vendors.
DATA: i_lfa1
TYPE TABLE OF t_vendor,
wa_lfa1
TYPE t_vendor,
s_lifnr_low TYPE lifnr,
s_lifnr_high TYPE lifnr.
.
ENDCLASS.

*Local class implementation


CLASS lcl_vendor IMPLEMENTATION.
*Implementing the interface method
METHOD zif_global_interface~get_vendors.
SELECT lifnr
land1
name1
ort01 FROM lfa1
INTO TABLE i_lfa1
WHERE lifnr BETWEEN s_lifnr_low AND s_lifnr_high.
ENDMETHOD.
*Implementing the local class method
METHOD display_vendors.
LOOP AT i_lfa1 INTO wa_lfa1.
WRITE:/ wa_lfa1-lifnr,
wa_lfa1-land1,
wa_lfa1-name1,
wa_lfa1-ort01.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
DATA:lfa1 TYPE lfa1.
*Select Options
SELECT-OPTIONS:s_lifnr FOR lfa1-lifnr.
*Declaration of object reference variable
DATA:obj TYPE REF TO lcl_vendor.
START-OF-SELECTION.
*Create Object
CREATE OBJECT obj.
*Provide attribute values
obj->s_lifnr_low = s_lifnr-low.
obj->s_lifnr_high = s_lifnr-high.
*Calling the interface method to get data.
CALL METHOD obj->zif_global_interface~get_vendors.
*Calling the local class method to display data.
CALL METHOD obj->display_vendors.

Page 5

02/28/2015

Save Check and Activate .


Execute the program.

Provide the vendor numbers in selection screen.

Execute it.

Page 6

02/28/2015

Output:

Page 7

02/28/2015

You might also like