Hi, In this Post you can find an example for Interactive ALV report.
The scenario is, to display the Sales Header data based on user input of sales order number and order type. When user double clicks on any sales order number, display the item wise details.
This Interactive ALV report uses tables VBAK, VBAP, LIPS, LIKP, VBRK. And based on the Order type viz Inquiry (A), Quotation (B), Order (C), Delivery (J), Returns(M), Invoice (H) retrieves the Header and Item Details.
*&---------------------------------------------------------------------*
*& Report ZTEST_ALV2_RE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST_ALV2_RE NO STANDARD PAGE HEADING MESSAGE-ID ZPARTH_MESSAGE.
*INCLUDE ZTEST_ALV2_DECL.
*&---------------------------------------------------------------------*
*& Include ZTEST_ALV2_DECL
*&---------------------------------------------------------------------*
TYPE-POOLS : SLIS.
TABLES: VBAK, VBAP, LIPS, LIKP, VBRK.
TYPES : BEGIN OF TY_VBAK ,
VBELN TYPE VBELN,
VBTYP TYPE VBTYP,
VKORG TYPE VKORG,
VTWEG TYPE VTWEG,
SPART TYPE SPART,
ERDAT TYPE ERDAT,
END OF TY_VBAK.
TYPES: BEGIN OF TY_VBAP,
VBELN TYPE VBELN,
POSNR TYPE POSNR,
MATNR TYPE MATNR,
PSTYV TYPE PSTYV,
MATKL TYPE MATKL,
WERKS TYPE WERKS_EXT,
POSAR TYPE POSAR,
WAERK TYPE WAERK,
MEINS TYPE MEINS,
NETPR TYPE NETPR,
AUFNR TYPE AUFNR,
END OF TY_VBAP,
BEGIN OF TY_VBRK,
VBELN TYPE VBELN,
VBTYP TYPE VBTYP,
VKORG TYPE VKORG,
VTWEG TYPE VTWEG,
FKART TYPE FKART,
FKTYP TYPE FKTYP,
END OF TY_VBRK,
BEGIN OF TY_VBRP,
VBELN TYPE VBELN_VF,
POSNR TYPE POSNR_VF,
VRKME TYPE VRKME,
FKIMG TYPE FKIMG,
AUBEL TYPE VBELN_VA,
AUPOS TYPE POSNR_VA,
MATNR TYPE MATNR,
PMATN TYPE PMATN,
CHARG TYPE CHARG_D,
MATKL TYPE MATKL,
END OF TY_VBRP,
BEGIN OF TY_LIKP,
VBELN TYPE VBELN_VL,
VKORG TYPE VKORG,
ERDAT TYPE ERDAT,
LFART TYPE LFART,
LDDAT TYPE LDDAT,
LFDAT TYPE LFDAT_V,
END OF TY_LIKP,
BEGIN OF TY_LIPS,
VBELN TYPE VBELN_VL,
POSNR TYPE POSNR_VL,
MATNR TYPE MATNR,
PSTYV TYPE PSTYV_VL,
WERKS TYPE WERKS_D,
WAVWR TYPE WAVWR,
CHARG TYPE CHARG_D,
VRKME TYPE VRKME,
NETPR TYPE NETPR,
HSDAT TYPE HSDAT,
END OF TY_LIPS.
DATA: IT_VBAK TYPE TABLE OF TY_VBAK,
WA_VBAK TYPE TY_VBAK,
IT_VBAP TYPE TABLE OF TY_VBAP,
WA_VBAP TYPE TY_VBAP,
IT_VBRK TYPE TABLE OF TY_VBRK,
WA_VBRK TYPE TY_VBRK,
IT_VBRP TYPE TABLE OF TY_VBRP,
WA_VBRP TYPE TY_VBRP,
IT_LIKP TYPE TABLE OF TY_LIKP,
WA_LIKP TYPE TY_LIKP,
IT_LIPS TYPE TABLE OF TY_LIPS,
WA_LIPS TYPE TY_LIPS.
DATA: IT_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FLDCAT TYPE SLIS_FIELDCAT_ALV,
TABLNAME(20),
FLDNAME(20),
SLTXT_L(20).
DATA: IT_ALVEVNT TYPE SLIS_T_EVENT,
WA_ALVEVNT TYPE SLIS_ALV_EVENT.
DATA: IT_LISTHEAD TYPE SLIS_T_LISTHEADER,
WA_LISTHEAD TYPE SLIS_LISTHEADER.
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA : REPID LIKE SY-REPID.
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
PARAMETERS: P_VBTYP TYPE VBTYP OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK B1.
AT SELECTION-SCREEN.
IF NOT ( P_VBTYP EQ 'C'
OR P_VBTYP EQ 'J'
OR P_VBTYP EQ 'M'
OR P_VBTYP EQ 'A'
OR P_VBTYP EQ 'B'
OR P_VBTYP EQ 'H' ) .
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-002.
ENDIF.
START-OF-SELECTION.
IF P_VBTYP EQ 'C' OR P_VBTYP EQ 'A' OR P_VBTYP EQ 'B' OR P_VBTYP EQ 'H'.
REFRESH IT_FLDCAT.
CLEAR WA_FLDCAT.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VBELN' 'DOC NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'ERDAT' 'DOC CREATION DATE'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VBTYP' 'DOC TYPE'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VKORG' 'SALES ORG'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VTWEG' 'DISTRIBUTION CHNL'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'SPART' 'DIVISION'.
PERFORM POPULATE_EVENT.
PERFORM DATA_RETRIEVE.
PERFORM DISPLAY_GRID.
ELSEIF P_VBTYP EQ 'M'.
REFRESH IT_FLDCAT.
CLEAR WA_FLDCAT.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VBELN' 'DOC NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'FKART' 'BILLING TYPE'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VBTYP' 'DOC TYPE'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VKORG' 'SALES ORG'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VTWEG' 'DISTRIBUTION CHNL'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'FKTYP' 'BILLING CATG'.
PERFORM POPULATE_EVENT.
PERFORM DATA_RETRIEVE_M.
PERFORM DISPLAY_GRID_M.
ELSEIF P_VBTYP EQ 'J'.
REFRESH IT_FLDCAT.
CLEAR WA_FLDCAT.
PERFORM PREP_FLDCAT USING 'IT_LIKP' 'VBELN' 'DOC NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_LIKP' 'ERDAT' 'DOC CREATION DATE'.
PERFORM PREP_FLDCAT USING 'IT_LIKP' 'VKORG' 'SALES ORG'.
PERFORM PREP_FLDCAT USING 'IT_LIKP' 'LFART' 'DELIVERY TYPE'.
PERFORM PREP_FLDCAT USING 'IT_LIKP' 'LDDAT' 'LOADING DATE'.
PERFORM PREP_FLDCAT USING 'IT_LIKP' 'LFDAT' 'DELIVERY DATE'.
PERFORM POPULATE_EVENT.
PERFORM DATA_RETRIEVE_J.
PERFORM DISPLAY_GRID_J TABLES IT_LIKP .
ENDIF.
*&---------------------------------------------------------------------*
*& Form PREP_FLDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PREP_FLDCAT USING TABLNAME FLDNAME SLTXT_L.
WA_FLDCAT-TABNAME = TABLNAME.
WA_FLDCAT-FIELDNAME = FLDNAME.
WA_FLDCAT-SELTEXT_L = SLTXT_L.
APPEND WA_FLDCAT TO IT_FLDCAT.
CLEAR WA_FLDCAT.
ENDFORM. " PREP_FLDCAT
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVE .
SELECT VBELN
VBTYP
VKORG
VTWEG
SPART
ERDAT
FROM VBAK
INTO CORRESPONDING FIELDS OF TABLE IT_VBAK
WHERE VBELN IN S_VBELN
AND VBTYP EQ P_VBTYP.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-003.
ENDIF.
ENDFORM. " DATA_RETRIEVE
*&---------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM POPULATE_EVENT .
READ TABLE IT_ALVEVNT INTO WA_ALVEVNT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_ALVEVNT-FORM = 'TOP_OF_PAGE'.
MODIFY IT_ALVEVNT FROM WA_ALVEVNT TRANSPORTING FORM WHERE NAME = WA_ALVEVNT-FORM.
ENDIF.
READ TABLE IT_ALVEVNT INTO WA_ALVEVNT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_ALVEVNT-FORM = 'USER_INPUT'.
MODIFY IT_ALVEVNT FROM WA_ALVEVNT TRANSPORTING FORM WHERE NAME = WA_ALVEVNT-NAME.
ENDIF.
ENDFORM. " POPULATE_EVENT
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_INPUT'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FLDCAT
IT_EVENTS = IT_ALVEVNT
I_SAVE = 'A'
TABLES
T_OUTTAB = IT_VBAK
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_GRID
FORM TOP_OF_PAGE. "#EC CALLED
REFRESH IT_LISTHEAD.
WA_LISTHEAD-TYP = 'H'.
WA_LISTHEAD-INFO = TEXT-004.
APPEND WA_LISTHEAD TO IT_LISTHEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEAD
.
ENDFORM.
FORM USER_INPUT USING CMD LIKE SY-UCOMM SEL_FLD TYPE SLIS_SELFIELD.
IF P_VBTYP EQ 'C' OR P_VBTYP EQ 'A' OR P_VBTYP EQ 'B' OR P_VBTYP EQ 'H'.
READ TABLE IT_VBAK INTO WA_VBAK INDEX SEL_FLD-TABINDEX.
CASE CMD.
WHEN '&IC1'.
REFRESH IT_FLDCAT.
CLEAR WA_FLDCAT.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'VBELN' 'DOC NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'POSNR' 'DELIVERY ITEM'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'MATNR' 'MATERIAL NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'PSTYV' 'ITEM CATG'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'MATKL' 'MATERIAL GRP'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'WERKS' 'PLANT'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'POSAR' 'ITEM TYPE'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'WAERK' 'CURRENCY'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'MEINS' 'MATRL WT '.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'NETPR' 'NET PRICE'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'AUFNR' 'ORDER NUMBER'.
PERFORM DATA_RETRIEVE_1.
PERFORM DISPLAY_GRID_1.
ENDCASE.
ELSEIF P_VBTYP EQ 'M'.
READ TABLE IT_VBRK INTO WA_VBRK INDEX SEL_FLD-TABINDEX.
CASE CMD.
WHEN '&IC1'.
REFRESH IT_FLDCAT.
CLEAR WA_FLDCAT.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'VBELN' 'DOC NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'POSNR' 'DELIVERY ITEM'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'MATNR' 'MATERIAL NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'VRKME' 'SALES UNIT'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'MATKL' 'MATERIAL GRP'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'FKIMG' 'INVOICED QTY'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'AUBEL' 'SALES DOC'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'AUPOS' 'DOC ITEM'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'PMATN' 'PRICE REF '.
* PERFORM PREP_FLDCAT USING 'IT_VBRP' 'NETPR' 'NET PRICE'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'CHARG' 'BATCH NUMBER'.
PERFORM DATA_RETRIEVE_M1.
PERFORM DISPLAY_GRID_M1.
ENDCASE.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSEIF P_VBTYP EQ 'J'.
READ TABLE IT_LIKP INTO WA_LIKP INDEX SEL_FLD-TABINDEX.
CASE CMD.
WHEN '&IC1'.
REFRESH IT_FLDCAT.
CLEAR WA_FLDCAT.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'VBELN' 'DOC NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'POSNR' 'DELIVERY ITEM'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'MATNR' 'MATERIAL NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'VRKME' 'SALES UNIT'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'WERKS' 'PLANT'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'PSTYV' 'ITEM CATG'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'WAVWR' 'COST'.
* PERFORM PREP_FLDCAT USING 'IT_LIPS' 'AUPOS' 'DOC ITEM'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'NETPR' 'NET PRICE'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'CHARG' 'BATCH NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'HSDAT' 'MFG DATE '.
PERFORM DATA_RETRIEVE_J1.
PERFORM DISPLAY_GRID_J1.
ENDCASE.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVE_1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVE_1 .
SELECT VBELN
POSNR
MATNR
PSTYV
MATKL
WERKS
POSAR
WAERK
MEINS
AUFNR
NETPR
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
WHERE VBELN EQ WA_VBAK-VBELN.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-005.
ENDIF.
ENDFORM. " DATA_RETRIEVE_1
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID_1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID_1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE_1'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FLDCAT
TABLES
T_OUTTAB = IT_VBAP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_GRID_1
FORM TOP_OF_PAGE_1.
REFRESH IT_LISTHEAD.
WA_LISTHEAD-TYP = 'H'.
WA_LISTHEAD-INFO = TEXT-006.
APPEND WA_LISTHEAD TO IT_LISTHEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEAD
.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVE_M
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVE_M .
SELECT VBELN
VBTYP
VKORG
VTWEG
FKART
FKTYP
FROM VBRK
INTO CORRESPONDING FIELDS OF TABLE IT_VBRK
WHERE VBELN IN S_VBELN
AND VBTYP EQ P_VBTYP.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-003.
ENDIF.
ENDFORM. " DATA_RETRIEVE_M
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID_M
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID_M .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_INPUT'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FLDCAT
IT_EVENTS = IT_ALVEVNT
TABLES
T_OUTTAB = IT_VBRK
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_GRID_M
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVE_M1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVE_M1 .
SELECT VBELN
POSNR
VRKME
FKIMG
AUBEL
AUPOS
MATNR
PMATN
CHARG
MATKL
INTO CORRESPONDING FIELDS OF TABLE IT_VBRP
FROM VBRP
WHERE VBELN EQ WA_VBRK-VBELN .
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-003.
ENDIF.
ENDFORM. " DATA_RETRIEVE_M1
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID_M1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID_M1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE_1'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FLDCAT
TABLES
T_OUTTAB = IT_VBRP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_GRID_M1
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVE_J
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVE_J .
SELECT VBELN
VKORG
ERDAT
LFART
LDDAT
LFDAT
FROM LIKP
INTO CORRESPONDING FIELDS OF TABLE IT_LIKP
WHERE VBELN IN S_VBELN
AND VBTYP EQ P_VBTYP.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-003.
ENDIF.
ENDFORM. " DATA_RETRIEVE_J
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID_J
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID_J TABLES IT_LIKP_1 LIKE IT_LIKP .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_INPUT'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FLDCAT
IT_EVENTS = IT_ALVEVNT
TABLES
T_OUTTAB = IT_LIKP_1
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_GRID_J
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVE_J1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVE_J1 .
SELECT VBELN
POSNR
MATNR
PSTYV
WERKS
WAVWR
CHARG
VRKME
NETPR
HSDAT
FROM LIPS
INTO CORRESPONDING FIELDS OF TABLE IT_LIPS
WHERE VBELN EQ WA_LIKP-VBELN.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-003.
ENDIF.
ENDFORM. " DATA_RETRIEVE_J1
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID_J1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID_J1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE_1'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FLDCAT
TABLES
T_OUTTAB = IT_LIPS
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_GRID_J1
The scenario is, to display the Sales Header data based on user input of sales order number and order type. When user double clicks on any sales order number, display the item wise details.
This Interactive ALV report uses tables VBAK, VBAP, LIPS, LIKP, VBRK. And based on the Order type viz Inquiry (A), Quotation (B), Order (C), Delivery (J), Returns(M), Invoice (H) retrieves the Header and Item Details.
*&---------------------------------------------------------------------*
*& Report ZTEST_ALV2_RE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST_ALV2_RE NO STANDARD PAGE HEADING MESSAGE-ID ZPARTH_MESSAGE.
*INCLUDE ZTEST_ALV2_DECL.
*&---------------------------------------------------------------------*
*& Include ZTEST_ALV2_DECL
*&---------------------------------------------------------------------*
TYPE-POOLS : SLIS.
TABLES: VBAK, VBAP, LIPS, LIKP, VBRK.
TYPES : BEGIN OF TY_VBAK ,
VBELN TYPE VBELN,
VBTYP TYPE VBTYP,
VKORG TYPE VKORG,
VTWEG TYPE VTWEG,
SPART TYPE SPART,
ERDAT TYPE ERDAT,
END OF TY_VBAK.
TYPES: BEGIN OF TY_VBAP,
VBELN TYPE VBELN,
POSNR TYPE POSNR,
MATNR TYPE MATNR,
PSTYV TYPE PSTYV,
MATKL TYPE MATKL,
WERKS TYPE WERKS_EXT,
POSAR TYPE POSAR,
WAERK TYPE WAERK,
MEINS TYPE MEINS,
NETPR TYPE NETPR,
AUFNR TYPE AUFNR,
END OF TY_VBAP,
BEGIN OF TY_VBRK,
VBELN TYPE VBELN,
VBTYP TYPE VBTYP,
VKORG TYPE VKORG,
VTWEG TYPE VTWEG,
FKART TYPE FKART,
FKTYP TYPE FKTYP,
END OF TY_VBRK,
BEGIN OF TY_VBRP,
VBELN TYPE VBELN_VF,
POSNR TYPE POSNR_VF,
VRKME TYPE VRKME,
FKIMG TYPE FKIMG,
AUBEL TYPE VBELN_VA,
AUPOS TYPE POSNR_VA,
MATNR TYPE MATNR,
PMATN TYPE PMATN,
CHARG TYPE CHARG_D,
MATKL TYPE MATKL,
END OF TY_VBRP,
BEGIN OF TY_LIKP,
VBELN TYPE VBELN_VL,
VKORG TYPE VKORG,
ERDAT TYPE ERDAT,
LFART TYPE LFART,
LDDAT TYPE LDDAT,
LFDAT TYPE LFDAT_V,
END OF TY_LIKP,
BEGIN OF TY_LIPS,
VBELN TYPE VBELN_VL,
POSNR TYPE POSNR_VL,
MATNR TYPE MATNR,
PSTYV TYPE PSTYV_VL,
WERKS TYPE WERKS_D,
WAVWR TYPE WAVWR,
CHARG TYPE CHARG_D,
VRKME TYPE VRKME,
NETPR TYPE NETPR,
HSDAT TYPE HSDAT,
END OF TY_LIPS.
DATA: IT_VBAK TYPE TABLE OF TY_VBAK,
WA_VBAK TYPE TY_VBAK,
IT_VBAP TYPE TABLE OF TY_VBAP,
WA_VBAP TYPE TY_VBAP,
IT_VBRK TYPE TABLE OF TY_VBRK,
WA_VBRK TYPE TY_VBRK,
IT_VBRP TYPE TABLE OF TY_VBRP,
WA_VBRP TYPE TY_VBRP,
IT_LIKP TYPE TABLE OF TY_LIKP,
WA_LIKP TYPE TY_LIKP,
IT_LIPS TYPE TABLE OF TY_LIPS,
WA_LIPS TYPE TY_LIPS.
DATA: IT_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FLDCAT TYPE SLIS_FIELDCAT_ALV,
TABLNAME(20),
FLDNAME(20),
SLTXT_L(20).
DATA: IT_ALVEVNT TYPE SLIS_T_EVENT,
WA_ALVEVNT TYPE SLIS_ALV_EVENT.
DATA: IT_LISTHEAD TYPE SLIS_T_LISTHEADER,
WA_LISTHEAD TYPE SLIS_LISTHEADER.
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA : REPID LIKE SY-REPID.
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
PARAMETERS: P_VBTYP TYPE VBTYP OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK B1.
AT SELECTION-SCREEN.
IF NOT ( P_VBTYP EQ 'C'
OR P_VBTYP EQ 'J'
OR P_VBTYP EQ 'M'
OR P_VBTYP EQ 'A'
OR P_VBTYP EQ 'B'
OR P_VBTYP EQ 'H' ) .
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-002.
ENDIF.
START-OF-SELECTION.
IF P_VBTYP EQ 'C' OR P_VBTYP EQ 'A' OR P_VBTYP EQ 'B' OR P_VBTYP EQ 'H'.
REFRESH IT_FLDCAT.
CLEAR WA_FLDCAT.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VBELN' 'DOC NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'ERDAT' 'DOC CREATION DATE'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VBTYP' 'DOC TYPE'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VKORG' 'SALES ORG'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VTWEG' 'DISTRIBUTION CHNL'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'SPART' 'DIVISION'.
PERFORM POPULATE_EVENT.
PERFORM DATA_RETRIEVE.
PERFORM DISPLAY_GRID.
ELSEIF P_VBTYP EQ 'M'.
REFRESH IT_FLDCAT.
CLEAR WA_FLDCAT.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VBELN' 'DOC NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'FKART' 'BILLING TYPE'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VBTYP' 'DOC TYPE'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VKORG' 'SALES ORG'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'VTWEG' 'DISTRIBUTION CHNL'.
PERFORM PREP_FLDCAT USING 'IT_VBAK' 'FKTYP' 'BILLING CATG'.
PERFORM POPULATE_EVENT.
PERFORM DATA_RETRIEVE_M.
PERFORM DISPLAY_GRID_M.
ELSEIF P_VBTYP EQ 'J'.
REFRESH IT_FLDCAT.
CLEAR WA_FLDCAT.
PERFORM PREP_FLDCAT USING 'IT_LIKP' 'VBELN' 'DOC NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_LIKP' 'ERDAT' 'DOC CREATION DATE'.
PERFORM PREP_FLDCAT USING 'IT_LIKP' 'VKORG' 'SALES ORG'.
PERFORM PREP_FLDCAT USING 'IT_LIKP' 'LFART' 'DELIVERY TYPE'.
PERFORM PREP_FLDCAT USING 'IT_LIKP' 'LDDAT' 'LOADING DATE'.
PERFORM PREP_FLDCAT USING 'IT_LIKP' 'LFDAT' 'DELIVERY DATE'.
PERFORM POPULATE_EVENT.
PERFORM DATA_RETRIEVE_J.
PERFORM DISPLAY_GRID_J TABLES IT_LIKP .
ENDIF.
*&---------------------------------------------------------------------*
*& Form PREP_FLDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PREP_FLDCAT USING TABLNAME FLDNAME SLTXT_L.
WA_FLDCAT-TABNAME = TABLNAME.
WA_FLDCAT-FIELDNAME = FLDNAME.
WA_FLDCAT-SELTEXT_L = SLTXT_L.
APPEND WA_FLDCAT TO IT_FLDCAT.
CLEAR WA_FLDCAT.
ENDFORM. " PREP_FLDCAT
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVE .
SELECT VBELN
VBTYP
VKORG
VTWEG
SPART
ERDAT
FROM VBAK
INTO CORRESPONDING FIELDS OF TABLE IT_VBAK
WHERE VBELN IN S_VBELN
AND VBTYP EQ P_VBTYP.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-003.
ENDIF.
ENDFORM. " DATA_RETRIEVE
*&---------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM POPULATE_EVENT .
READ TABLE IT_ALVEVNT INTO WA_ALVEVNT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_ALVEVNT-FORM = 'TOP_OF_PAGE'.
MODIFY IT_ALVEVNT FROM WA_ALVEVNT TRANSPORTING FORM WHERE NAME = WA_ALVEVNT-FORM.
ENDIF.
READ TABLE IT_ALVEVNT INTO WA_ALVEVNT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_ALVEVNT-FORM = 'USER_INPUT'.
MODIFY IT_ALVEVNT FROM WA_ALVEVNT TRANSPORTING FORM WHERE NAME = WA_ALVEVNT-NAME.
ENDIF.
ENDFORM. " POPULATE_EVENT
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_INPUT'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FLDCAT
IT_EVENTS = IT_ALVEVNT
I_SAVE = 'A'
TABLES
T_OUTTAB = IT_VBAK
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_GRID
FORM TOP_OF_PAGE. "#EC CALLED
REFRESH IT_LISTHEAD.
WA_LISTHEAD-TYP = 'H'.
WA_LISTHEAD-INFO = TEXT-004.
APPEND WA_LISTHEAD TO IT_LISTHEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEAD
.
ENDFORM.
FORM USER_INPUT USING CMD LIKE SY-UCOMM SEL_FLD TYPE SLIS_SELFIELD.
IF P_VBTYP EQ 'C' OR P_VBTYP EQ 'A' OR P_VBTYP EQ 'B' OR P_VBTYP EQ 'H'.
READ TABLE IT_VBAK INTO WA_VBAK INDEX SEL_FLD-TABINDEX.
CASE CMD.
WHEN '&IC1'.
REFRESH IT_FLDCAT.
CLEAR WA_FLDCAT.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'VBELN' 'DOC NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'POSNR' 'DELIVERY ITEM'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'MATNR' 'MATERIAL NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'PSTYV' 'ITEM CATG'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'MATKL' 'MATERIAL GRP'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'WERKS' 'PLANT'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'POSAR' 'ITEM TYPE'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'WAERK' 'CURRENCY'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'MEINS' 'MATRL WT '.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'NETPR' 'NET PRICE'.
PERFORM PREP_FLDCAT USING 'IT_VBAP' 'AUFNR' 'ORDER NUMBER'.
PERFORM DATA_RETRIEVE_1.
PERFORM DISPLAY_GRID_1.
ENDCASE.
ELSEIF P_VBTYP EQ 'M'.
READ TABLE IT_VBRK INTO WA_VBRK INDEX SEL_FLD-TABINDEX.
CASE CMD.
WHEN '&IC1'.
REFRESH IT_FLDCAT.
CLEAR WA_FLDCAT.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'VBELN' 'DOC NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'POSNR' 'DELIVERY ITEM'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'MATNR' 'MATERIAL NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'VRKME' 'SALES UNIT'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'MATKL' 'MATERIAL GRP'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'FKIMG' 'INVOICED QTY'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'AUBEL' 'SALES DOC'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'AUPOS' 'DOC ITEM'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'PMATN' 'PRICE REF '.
* PERFORM PREP_FLDCAT USING 'IT_VBRP' 'NETPR' 'NET PRICE'.
PERFORM PREP_FLDCAT USING 'IT_VBRP' 'CHARG' 'BATCH NUMBER'.
PERFORM DATA_RETRIEVE_M1.
PERFORM DISPLAY_GRID_M1.
ENDCASE.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSEIF P_VBTYP EQ 'J'.
READ TABLE IT_LIKP INTO WA_LIKP INDEX SEL_FLD-TABINDEX.
CASE CMD.
WHEN '&IC1'.
REFRESH IT_FLDCAT.
CLEAR WA_FLDCAT.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'VBELN' 'DOC NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'POSNR' 'DELIVERY ITEM'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'MATNR' 'MATERIAL NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'VRKME' 'SALES UNIT'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'WERKS' 'PLANT'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'PSTYV' 'ITEM CATG'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'WAVWR' 'COST'.
* PERFORM PREP_FLDCAT USING 'IT_LIPS' 'AUPOS' 'DOC ITEM'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'NETPR' 'NET PRICE'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'CHARG' 'BATCH NUMBER'.
PERFORM PREP_FLDCAT USING 'IT_LIPS' 'HSDAT' 'MFG DATE '.
PERFORM DATA_RETRIEVE_J1.
PERFORM DISPLAY_GRID_J1.
ENDCASE.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVE_1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVE_1 .
SELECT VBELN
POSNR
MATNR
PSTYV
MATKL
WERKS
POSAR
WAERK
MEINS
AUFNR
NETPR
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
WHERE VBELN EQ WA_VBAK-VBELN.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-005.
ENDIF.
ENDFORM. " DATA_RETRIEVE_1
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID_1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID_1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE_1'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FLDCAT
TABLES
T_OUTTAB = IT_VBAP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_GRID_1
FORM TOP_OF_PAGE_1.
REFRESH IT_LISTHEAD.
WA_LISTHEAD-TYP = 'H'.
WA_LISTHEAD-INFO = TEXT-006.
APPEND WA_LISTHEAD TO IT_LISTHEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEAD
.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVE_M
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVE_M .
SELECT VBELN
VBTYP
VKORG
VTWEG
FKART
FKTYP
FROM VBRK
INTO CORRESPONDING FIELDS OF TABLE IT_VBRK
WHERE VBELN IN S_VBELN
AND VBTYP EQ P_VBTYP.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-003.
ENDIF.
ENDFORM. " DATA_RETRIEVE_M
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID_M
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID_M .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_INPUT'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FLDCAT
IT_EVENTS = IT_ALVEVNT
TABLES
T_OUTTAB = IT_VBRK
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_GRID_M
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVE_M1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVE_M1 .
SELECT VBELN
POSNR
VRKME
FKIMG
AUBEL
AUPOS
MATNR
PMATN
CHARG
MATKL
INTO CORRESPONDING FIELDS OF TABLE IT_VBRP
FROM VBRP
WHERE VBELN EQ WA_VBRK-VBELN .
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-003.
ENDIF.
ENDFORM. " DATA_RETRIEVE_M1
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID_M1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID_M1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE_1'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FLDCAT
TABLES
T_OUTTAB = IT_VBRP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_GRID_M1
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVE_J
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVE_J .
SELECT VBELN
VKORG
ERDAT
LFART
LDDAT
LFDAT
FROM LIKP
INTO CORRESPONDING FIELDS OF TABLE IT_LIKP
WHERE VBELN IN S_VBELN
AND VBTYP EQ P_VBTYP.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-003.
ENDIF.
ENDFORM. " DATA_RETRIEVE_J
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID_J
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID_J TABLES IT_LIKP_1 LIKE IT_LIKP .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_INPUT'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FLDCAT
IT_EVENTS = IT_ALVEVNT
TABLES
T_OUTTAB = IT_LIKP_1
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_GRID_J
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVE_J1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVE_J1 .
SELECT VBELN
POSNR
MATNR
PSTYV
WERKS
WAVWR
CHARG
VRKME
NETPR
HSDAT
FROM LIPS
INTO CORRESPONDING FIELDS OF TABLE IT_LIPS
WHERE VBELN EQ WA_LIKP-VBELN.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER '002' WITH TEXT-003.
ENDIF.
ENDFORM. " DATA_RETRIEVE_J1
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID_J1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID_J1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE_1'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = IT_FLDCAT
TABLES
T_OUTTAB = IT_LIPS
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_GRID_J1
On Execution:-
No comments:
Post a Comment