Ex :-
Steps :-
- Go to Transaction Code SE38.
Source Code
CLASS C1 DEFINITION.
PUBLIC SECTION.
TYPES : BEGIN OF S_VBELN,
SIGN TYPE RSDSSELOPT-SIGN,
OPTION TYPE RSDSSELOPT-OPTION,
LOW TYPE VBAK-VBELN,
HIGH TYPE VBAK-VBELN,
END OF S_VBELN.
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.
TYPES : IT_SO TYPE TABLE OF TY_SO.
METHODS : FETCH_DATA IMPORTING IM_VBELN TYPE S_VBELN
CHANGING CH_ITAB TYPE IT_SO,
DISPLAY IMPORTING IM_ITAB TYPE IT_SO.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD FETCH_DATA .
SELECT A~VBELN A~ERNAM VKORG KUNNR POSNR MATNR ARKTX B~NETWR
FROM VBAK AS A INNER JOIN VBAP AS B ON B~VBELN = A~VBELN INTO
TABLE CH_ITAB WHERE A~VBELN BETWEEN IM_VBELN-LOW AND IM_VBELN-HIGH.
ENDMETHOD.
METHOD DISPLAY.
DATA : WA_SO TYPE TY_SO.
LOOP AT IM_ITAB INTO WA_SO.
WRITE : / WA_SO-VBELN,
WA_SO-ERNAM,
WA_SO-VKORG,
WA_SO-KUNNR,
WA_SO-POSNR,
WA_SO-MATNR,
WA_SO-ARKTX,
WA_SO-NETWR.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
" MAIN PROGRAM
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 C1.
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 .
No comments:
Post a Comment