CLASS lcx_1 DEFINITION INHERITING FROM cx_static_check.
ENDCLASS.
CLASS C1 DEFINITION.
PUBLIC SECTION.
TYPES : BEGIN OF TY_SEL,
SIGN TYPE RSDSSELOPT-SIGN,
OPTION TYPE RSDSSELOPT-OPTION,
LOW TYPE VBAK-VBELN,
HIGH TYPE VBAK-VBELN,
END OF TY_SEL.
DATA : R_VBELN TYPE TY_SEL,
IT_VBAP TYPE TABLE OF VBAP.
METHODS : CONSTRUCTOR IMPORTING S_VBELN TYPE TY_SEL RAISING lcx_1,
GET_DATA ,
display.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD constructor.
IF s_vbeln is INITIAL.
RAISE EXCEPTION TYPE lcx_1.
else.
r_vbeln-sign = s_vbeln-sign.
r_vbeln-option = s_vbeln-option.
r_vbeln-low = s_vbeln-low.
r_vbeln-high = s_vbeln-high.
ENDIF.
ENDMETHOD.
METHOD GET_DATA.
SELECT * FROM VBAP
INTO TABLE IT_VBAP
WHERE VBELN BETWEEN R_VBELN-LOW AND R_VBELN-HIGH.
ENDMETHOD.
METHOD display.
DATA : wa_vbap TYPE vbap.
LOOP AT it_vbap INTO wa_vbap.
WRITE : / wa_vbap-vbeln , wa_vbap-posnr, wa_vbap-matnr, wa_vbap-netpr.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
TABLES : vbap.
DATA : o_bj TYPE REF TO c1.
SELECT-OPTIONS : s_vbeln for vbap-vbeln.
START-OF-SELECTION.
TRY.
CREATE OBJECT o_bj EXPORTING s_vbeln = s_vbeln.
call METHOD o_bj->get_data.
CALL METHOD o_bj->display.
CATCH lcx_1.
MESSAGE i555(bc_bor) WITH 'No data found'.
ENDTRY.
Serkan AKKAVAK
Computer Engineer BSc
SAP Department Deputy Manager
Contact : serkurumsal@yandex.com
0 Comments