Sie sind auf Seite 1von 3

*&---------------------------------------------------------------------*

*& Report ZGSK_SELOPT_WITH_FM


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZGSK_SELOPT_WITH_FM NO STANDARD PAGE HEADING
LINE-SIZE 150.
INCLUDE ZSALES_INCLUDE.
" INCLUDE VBAP TABLE
AT SELECTION-SCREEN.
PERFORM VALIDAT_DATA CHANGING V_VBELN.

" VALIDATE USER DATA.

START-OF-SELECTION.
LW_SELOPT-SIGN = S_VBELN-SIGN.
LW_SELOPT-OPTION = S_VBELN-OPTION.
LW_SELOPT-LOW = S_VBELN-LOW.
LW_SELOPT-HIGH = S_VBELN-HIGH.
APPEND LW_SELOPT TO LT_SELOPT.
CLEAR LW_SELOPT.
PERFORM GET_DATA CHANGING LT_VBAP.
PERFORM DIS_DATA.
*&---------------------------------------------------------------------*
*&
Form VALIDAT_DATA
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
<--P_V_VBELN text
*----------------------------------------------------------------------*
FORM VALIDAT_DATA CHANGING FV_VBELN.
SELECT SINGLE VBELN FROM VBAP INTO V_VBELN
WHERE VBELN IN S_VBELN.
IF SY-SUBRC NE 0.
MESSAGE E000(ZGSK).
ENDIF.
ENDFORM.
" VALIDAT_DATA
*&---------------------------------------------------------------------*
*&
Form GET_DATA
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
<--P_LT_VBELN text
*----------------------------------------------------------------------*
FORM GET_DATA CHANGING FT_VBAP.
CALL FUNCTION 'Z_SO_SELECT_OPTIONS'
EXPORTING
IM_VBELN
= LT_SELOPT
CHANGING
EX_VBAP
= FT_VBAP
EXCEPTIONS
INVALID_INPUT = 1
NO_DATA_FOUND = 2
OTHERS
= 3.
CASE SY-SUBRC.
WHEN 1.

MESSAGE E000(ZTH).
ENDCASE .
BREAK USER2.
ENDFORM.

" GET_DATA

*&---------------------------------------------------------------------*
*&
Form dis_data
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM DIS_DATA .
IF NOT LT_VBAP IS INITIAL.
LOOP AT LT_VBAP INTO LW_VBAP.
WRITE : / LW_VBAP-VBELN, LW_VBAP-POSNR, LW_VBAP-MATNR, LW_VBAP-NETPR.
ENDLOOP.
ENDIF.
ENDFORM.
" dis_data
################################################################################
#################
*&---------------------------------------------------------------------*
*& Include
ZSALES_INCLUDE
*&---------------------------------------------------------------------*
TABLES : VBAP.
TYPES : BEGIN OF T_VBAP,
VBELN TYPE VBELN_VA,
POSNR TYPE POSNR_VA,
MATNR TYPE MATNR,
NETPR TYPE NETPR,
END OF T_VBAP.

"
"
"
"

SALES ORDER NO
ITEM NO
MATERIAL
NET PRICE

TYPES : TT_VBAP TYPE STANDARD TABLE OF T_VBAP.


DATA : LW_VBAP TYPE T_VBAP,
LT_VBAP TYPE TT_VBAP,
V_VBELN TYPE VBELN_VA.
DATA : LT_SELOPT TYPE ZTT_SELOPT,
LW_SELOPT TYPE ZSSELOPT.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN .
SELECTION-SCREEN END OF BLOCK B1.
################################################################################
#################
*&---------------------------------------------------------------------*
*& Function Module
"Z_SO_SELECT_OPTIONS"
*&---------------------------------------------------------------------*
*"---------------------------------------------------------------------*"*"Local Interface:
*" IMPORTING
*"
REFERENCE(IM_VBELN) TYPE ZTT_SELOPT
" IM_VBELN TYPE ZTT_SELOPT<(TABL

E/STRUCTURE)TYPE FIELDS : SIGN,OPTION,LOW,HIGH>


*" EXPORTING
*"
REFERENCE(EX_VBAP) TYPE ZTT_VBAP
" EX_VBAP TYPE ZTT_VBAP<(TABLE/S
TRUCTURE)TYPE FIELDS : VBELN,POSNR,MATNR,NETPR>
*" EXCEPTIONS
*"
NO_DATA_FOUND
*"---------------------------------------------------------------------IF NOT IM_VBELN IS INITIAL.
SELECT VBELN POSNR MATNR NETPR FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE EX_VBAP
WHERE VBELN IN IM_VBELN.
IF SY-SUBRC NE 0.
RAISE NO_DATA_FOUND.
ENDIF.
ENDIF.
ENDFUNCTION.