*&---------------------------------------------------------------------*
*& Report ZOOABAP_CL7
*&
*&---------------------------------------------------------------------*
*& use of Return statement : limitation over exporting
*& if returning is used then no export/changing is allowed
*& only one returning is allowed
*&---------------------------------------------------------------------*
REPORT zooabap_cl7.
CLASS zlcl_customer DEFINITION.
PUBLIC SECTION.
METHODS : get_data IMPORTING im_kunnr TYPE kunnr
RETURNING VALUE(ex_name) TYPE kna1-name1. "returning parameter
ENDCLASS.
CLASS zlcl_customer IMPLEMENTATION.
METHOD get_data.
SELECT SINGLE name1 FROM kna1 INTO (ex_name) WHERE kunnr = im_kunnr.
ENDMETHOD.
ENDCLASS.
PARAMETERS : p_kunnr TYPE kunnr.
DATA : v_name1 TYPE name1.
START-OF-SELECTION.
DATA : ob TYPE REF TO zlcl_customer.
CREATE OBJECT ob.
CALL METHOD ob->get_data
EXPORTING
im_kunnr = p_kunnr.
WRITE : /'Customer Name .......',v_name1.
CLEAR : v_name1.
CALL METHOD ob->get_data
EXPORTING
im_kunnr = p_kunnr
RECEIVING
ex_name = v_name1.
WRITE : /'Customer Name .......',v_name1.
ULINE.
CLEAR : v_name1.
v_name1 = ob->get_data( EXPORTING im_kunnr = p_kunnr ).
WRITE : / 'Customer Name.....',v_name1.