'Customer Number:' 'Customer Name:'
'Customer Number:' 'Customer Name:'
'Customer Number:' 'Customer Name:'
*& Report ZMR_CLASS_METHODS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZMR_CLASS_METHODS.
class lc_demo DEFINITION.
PUBLIC SECTION.
methods : get_data IMPORTING i_kunnr type kunnr
EXPORTING i_name type NAME1_GP.
class-methods : get_vendor IMPORTING i_lifnr type lifnr
EXPORTING i_name type NAME1_GP.
ENDCLASS.
class lc_demo IMPLEMENTATION.
* Instance method
method get_Data.
select single name1 from kna1 into i_name where kunnr = i_kunnr.
ENDMETHOD.
* STatic method
method get_vendor.
select single name1 from lfa1 into i_name where lifnr = i_lifnr.
endmethod.
ENDCLASS.
*DATA : <REFVAR> TYPE REF TO <CLASS/INTERFACE>.
data : lr_demo type REF TO lc_demo.
data : lv_name1 type name1_gp.
PARAMETERS : p_kunnr type kunnr,
P_LIFNR TYPE LIFNR.
START-OF-SELECTION.
*CREATE OBJECT <REFVAR>.
CREATE OBJECT lr_demo.
call method lr_demo->get_data EXPORTING i_kunnr = p_kunnr
IMPORTING i_name = lv_name1.
lr_demo->get_data( EXPORTING i_kunnr = p_kunnr
IMPORTING i_name = lv_name1 ).
write :/ 'Customer Number:', p_kunnr.
write :/ 'Customer Name:', lv_name1.
* STatic method.
CALL METHOD LC_DEMO=>GET_VENDOR EXPORTING I_LIFNR = P_LIFNR
IMPORTING I_NAME = LV_NAME1.
LC_DEMO=>get_vendor( EXPORTING I_LIFNR = P_LIFNR
IMPORTING I_NAME = LV_NAME1 ).
call method lr_demo->get_vendor EXPORTING I_LIFNR = P_LIFNR
IMPORTING I_NAME = LV_NAME1.
WRITE :/ 'Vendor Number:', P_LIFNR.
write :/ 'Vendor name:', lv_name1.