- 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.
Main Program
- Go to Transaction Code SE38.
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
.
ReplyDeleteExcellent article, I had been looking for this information for days, Congratulations