GoodleAds

oops abap local class program on inheritance


PARAMETERS p_matnr TYPE mcha-matnr.
DATA wa_mchb TYPE mchb.                 
DATA wa_mcha TYPE mcha.
*----------------------------------------------------------------------*
*       CLASS LCL_ABAP_SUPER DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_abap_super DEFINITION.

  
PUBLIC SECTION.
    
METHODS my_method
    
IMPORTING im_matnr TYPE mcha-matnr
   
EXPORTING ex_mcha TYPE mcha.

ENDCLASS.                                    "LCL_ABAP DEFINITION

*----------------------------------------------------------------------*
*       CLASS LCL_ABAP_CHILD DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*


CLASS lcl_abap_child DEFINITION INHERITING FROM lcl_abap_super.

  
PUBLIC SECTION.
    
METHODS my_method REDEFINITION.
ENDCLASS.                                       "LCL_ABAP_CHILD DEFINITION

DATA oops TYPE REF TO lcl_abap_child.
CREATE OBJECT oops.
CALL METHOD oops->my_method
  
EXPORTING
    im_matnr 
p_matnr
  
IMPORTING
    ex_mcha  =
 wa_mcha.

WRITE:/ wa_mcha-matnr,wa_mcha-werks,
        wa_mcha-charg,wa_mcha-ernam
.
ULINE.
WRITE:/ wa_mchb-matnr,wa_mchb-werks,
        wa_mchb-lgort,wa_mchb-ersda
,
        wa_mchb-lfgja,wa_mchb-lfmon
.
*----------------------------------------------------------------------*
*       CLASS LCL_ABAP_SUPER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*


CLASS lcl_abap_super IMPLEMENTATION.

  
METHOD my_method.
    
SELECT SINGLE *
    
FROM mcha INTO
    ex_mcha 
WHERE matnr im_matnr.
  
ENDMETHOD.                    "MY_METHOD
ENDCLASS.
                    "LCL_ABAP_SUPER IMPLEMENTATION
*----------------------------------------------------------------------*
*       CLASS LCL_ABAP_CHILD IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_abap_child IMPLEMENTATION.

  
METHOD my_method.
    
CALL METHOD super->my_method
      
EXPORTING
        im_matnr 
p_matnr
      
IMPORTING
        ex_mcha  =
 wa_mcha.

    
SELECT SINGLE *
      
FROM mchb INTO wa_mchb
      
WHERE matnr p_matnr.
  
ENDMETHOD.                    "MY_METHOD
ENDCLASS.
                    "LCL_ABAP_CHILD  IMPLEMENTATION
****************************************************************
"WE NEED TO CALL ONLY CHILD  CLASS BECAUSE WE HAVE MADE SOME CHANGES TO
"SUPER CLASS METHOD I.E IT IS REDEFINIED.
****************************************************************
****************************************************************
" TO COPY SUPER CLASS METHOD TO CHILD CLASS
" WE NEED TO USE THE STATEMENT
" CLASS LCL_ABAP_CHILD DEFINITION INHERITING FROM LCL_ABAP_SUPER.



OUTPUT






No comments:

Post a Comment