Wednesday 7 September 2016

Global Class : Types


  • Types are used to define structure , Table type etc.

Ex :-

Steps :-

  • Go to Transaction Code SE24.
  • Enter the class name start's with ZCL_< Class name > and click on Create.
  • Pop-up will appear.
  • Enter the description.
  • Click on SAVE.
  • Save it in either local Package or Package.
  • Click on Types Tab.


  • Enter the Type , select the Visibility.

  • Click on " Direct Type Entry ".
  • Pop-up will appear.
  • Click on Yes.
  • Create a structure for SELECT-OPTIONS.

  • Create a structure , internal table type for selected fields.
  • Click on Save.
  • Click on Back.


  • Click on Method Tab.
  • Enter the method name , Level , Visibility.
  • To pass parameters , place the cursor on method name and click on Parameters.
  • Enter the parameter name  , Type  and Associated Type.
  • Save.
  • Click on Back button.
  • Double click on Method name.

  • Enter the Logic.
  • Click on Save and click and back button.
  • Create a method for display data.

  • To pass parameters, place the cursor on method name and click on Parameters.
  • Enter parameter , Type and Associated Type.


  • Click on Save and click on Back Button.
  • To implement the method double click on method name.
  • Enter the logic.
  • Click on Save and click on Back.
  • Save -> Check -> Activate.
  • Copy the Class name.


Main Program

  • Go to Transaction Code SE38.
  • Enter the program name which start's with Y or Z < program name > and click on Create.
  • Enter the Title.
  • Select the Attribute Type as Executable Program.
  • Click on Save.
  • Source Code.



types:BEGIN OF TY_SO,
        VBELN TYPE VBAK-VBELN,
        ERNAM TYPE VBAK-ERNAM,
        VKORG TYPE VBAK-VKORG,
        KUNNR TYPE VBAK-KUNNR,
        POSNR TYPE VBAP-POSNR,
        MATNR TYPE VBAP-MATNR,
        ARKTX TYPE VBAP-ARKTX,
        NETWR TYPE VBAP-NETWR,
        END OF TY_SO .

 DATA :IT_SO TYPE TABLE OF TY_SO ,
       WA_SO TYPE TY_SO.

 DATA : OBJ TYPE REF TO ZCL_TYPES1.

 SELECT-OPTIONS : S_VBELN FOR WA_SO-VBELN.

 START-OF-SELECTION.

 CREATE OBJECT OBJ.

 CALL METHOD OBJ->FETCH_DATA
   EXPORTING
     IM_VBELN = S_VBELN
   CHANGING
     CH_ITAB  = IT_SO
     .
 CALL METHOD OBJ->DISPLAY
   EXPORTING
     IM_ITAB = IT_SO
     .


  • Save -> Check -> Activate.
  • Execute.

Input

  • Enter the input.

Output

  • Execute ( F8 ).



No comments:

Post a Comment