OOPS ABAP- CREATING METHODS IN SE24 TCODE



                               CREATING METHODS

Steps:

•          Go to TCODE se24.
•          Give the class name as ZCL_METHOD.
•          Click on the ‘methods’ tab.
•          Give the method name as GET_MAT_DET


 

•        Click on the ‘parameters’ button and & specify the parameters as below….
•                    IM_MATNR      IMPORTING    TYPE    MARA-MATNR.
•                    EX_MARA   EXPORTING   TYPE    MARA.






•        Click on the button ‘code’.  
                            (or) 
•        Double click on the method name &write the below code.
•        METHOD GET_MAT_DET.



 

•        Save and activate the class.

•        Testing the Method   

•        Click on ‘execute’ button.
•        Click on ‘create Instance’ button.
•         All the instance members will be visible now.’
•         Click on the ‘execute’ button for the method GET_MAT_DET.
•         The output  will be displayed.





•                  Calling the Method  from the program 

•        Data: wa_mara type mara.

•        Data:  OBJ1 type ref to zcl_method.
•        Create object OBJ1.

•        PARAMETERS   :   P_MATNR TYPE MARA-MATNR. 

•          Click on PATTERN button.

•          Select ‘ABAP object patterns’.

•        select the radio button call method  and  provide the values as below.

•        Call method
•                  Instance :  OBJ1
•                  Class      :   ZCL_METHOD
•                  Method   :  GET_MAT_DET,  and press enter

•           code will be displayed automatically.

•        Call method OBJ1   GET_MAT_DET.
•                    EXPORTING
•                                IM_MATNR =  P_MATNR.
•                    IMPORTING
•                                EX_MARA = WA_MARA.

•        WRITE : / WA_MARA-MATNR ,
•                         WA_MARA-MBRSH,WA_MARA-MTART.

 
•        SaveActivateTest it.

•        OUTPUT: