*& Report ZOOABAP_CL5
*& Local class Methods with Importing and Exporting Parameters
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zooabap_cl5.
CLASS LCL_CUSTOMER DEFINITION.
PUBLIC SECTION.
METHODS : GET_DETAILS IMPORTING IM_KUNNR TYPE KUNNR
EXPORTING EX_NAME TYPE NAME1
EX_STCD1 TYPE STCD1.
ENDCLASS.
CLASS LCL_CUSTOMER IMPLEMENTATION.
METHOD : GET_DETAILS.
SELECT SINGLE NAME1 STCD1
FROM KNA1 INTO (EX_NAME,EX_STCD1)
WHERE KUNNR = IM_KUNNR.
ENDMETHOD.
ENDCLASS.
PARAMETERS : p_kunnr TYPE kna1-kunnr.
START-OF-SELECTION.
data: ob type ref to lcl_customer.
create object ob.
DATA : v_name1 TYPE name1,
v_stcd1 TYPE stcd1.
*---------Case 1 : when exporting nothing --------------------*
format color 3.
write :/ 'Customer name :',v_name1,
/ 'Customer city :',v_stcd1.
format color off.
uline.
call METHOD ob->get_details
exporting
im_kunnr = p_kunnr.
*----------case 2 : when exporting just name1 attribute---------*
call method ob->GET_DETAILS
EXPORTING
im_kunnr = p_kunnr
IMPORTING
ex_name = v_name1.
format color 7.
write :/ 'Customer name :',v_name1,
/ 'Customer city :',v_STCD1.
format color off.
uline.
*---------Case 3 : when you want to export both the attribute-------*
call method ob->get_details
EXPORTING
im_kunnr = p_kunnr
IMPORTING
ex_name = v_name1
ex_stcd1 = v_stcd1.
format color 1.
write :/ 'Customer name :',v_name1,
/ 'Customer city :',v_stcd1.
format color off.
O/P: Image of Output.