ALV INTERACTIVE REPORT
*& Report ZR_ALV_INTER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZR_ALV_INTER.
TABLES: KNA1,VBAK,VBAP.
TYPE-POOLS: SLIS.
*********************************internal table*************************
TYPES: BEGIN OF ST_VBAK,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
ERNAM TYPE VBAK-ERNAM,
AUART TYPE VBAK-AUART,
VKORG TYPE VBAK-VKORG,
END OF ST_VBAK.
TYPES: BEGIN OF ST_VBAP,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
NETWR TYPE VBAP-NETWR,
END OF ST_VBAP.
DATA: IT_VBAP TYPE TABLE OF ST_VBAP,
WA_VBAP TYPE ST_VBAP.
DATA: IT_VBAK TYPE TABLE OF ST_VBAK,
WA_VBAK TYPE ST_VBAK.
******************************************fieldcatalog & layout*********************
DATA: IT_FC1 TYPE SLIS_T_FIELDCAT_ALV,
WA_FC1 TYPE SLIS_FIELDCAT_ALV,
LAY1 TYPE SLIS_LAYOUT_ALV.
DATA: IT_FC2 TYPE SLIS_T_FIELDCAT_ALV,
WA_FC2 TYPE SLIS_FIELDCAT_ALV,
LAY2 TYPE SLIS_LAYOUT_ALV.
***************************************variable**************************************
DATA: V_REPID TYPE SY-REPID.
DATA: V_VBELN TYPE VBAK-VBELN.
****************************************events ****************************************
DATA: IT_EVE TYPE SLIS_T_EVENT,
WA_EVE TYPE SLIS_ALV_EVENT.
**************************************selection screen******************************
PARAMETERS: P_VBELN TYPE VBAK-VBELN.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM FIELDCAT.
START-OF-SELECTION.
PERFORM DATA_RET.
PERFORM LAYOUT.
PERFORM DISPLAY.
************************************basic list vbak details **************************
*&---------------------------------------------------------------------*
*& Form fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM FIELDCAT.
CLEAR WA_FC1.
WA_FC1-FIELDNAME = 'VBELN'.
WA_FC1-TABNAME = 'IT_VBAK'.
WA_FC1-COL_POS = 0.
WA_FC1-SELTEXT_L = 'SALSE DOC NO'.
APPEND WA_FC1 TO IT_FC1.
CLEAR WA_FC1.
WA_FC1-FIELDNAME = 'ERDAT'.
WA_FC1-TABNAME = 'IT_VBAK'.
WA_FC1-COL_POS = 1.
WA_FC1-SELTEXT_L = 'CREATED DATE'.
APPEND WA_FC1 TO IT_FC1.
CLEAR WA_FC1.
WA_FC1-FIELDNAME = 'ERNAM'.
WA_FC1-TABNAME = 'IT_VBAK'.
WA_FC1-COL_POS = 2.
WA_FC1-SELTEXT_L = 'CREATED BY'.
APPEND WA_FC1 TO IT_FC1.
CLEAR WA_FC1.
WA_FC1-FIELDNAME = 'AUART'.
WA_FC1-TABNAME = 'IT_VBAK'.
WA_FC1-COL_POS = 3.
WA_FC1-SELTEXT_L = 'DOC TYPE'.
APPEND WA_FC1 TO IT_FC1.
CLEAR WA_FC1.
WA_FC1-FIELDNAME = 'VKORG'.
WA_FC1-TABNAME = 'IT_VBAK'.
WA_FC1-COL_POS = 4.
WA_FC1-SELTEXT_L = 'SALSE ORGANIZATION'.
APPEND WA_FC1 TO IT_FC1.
ENDFORM. "fieldcat
*&---------------------------------------------------------------------*
*& Form data_ret
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DATA_RET.
SELECT VBELN ERDAT ERNAM AUART VKORG FROM VBAK INTO TABLE IT_VBAK WHERE VBELN = P_VBELN.
ENDFORM. "data_ret
*&---------------------------------------------------------------------*
*& Form LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM LAYOUT.
LAY1-NO_INPUT = 'X'.
ENDFORM. "LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ''
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'Salse header details(ALV BASIC LIST)'
* I_GRID_SETTINGS =
IS_LAYOUT = LAY1
IT_FIELDCAT = IT_FC1
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'X'
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
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
**************************************secondary list vbap details ****************************************
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->R_COMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING R_COMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD.
* V_VBELN = RS_SELFIELD-VALUE.
CASE R_COMM.
WHEN '&IC1'.
* IF RS_SELFIELD-FIELDNAME = 'VBELN'.
READ TABLE IT_VBAK INTO WA_VBAK INDEX RS_SELFIELD-TABINDEX.
* ENDIF.
PERFORM GETDATA.
PERFORM FIDCAT2.
PERFORM DISPLAY2.
ENDCASE.
ENDFORM. "USER_COMMAND
*&---------------------------------------------------------------------*
*& Form GETDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GETDATA.
SELECT VBELN POSNR MATNR NETWR FROM VBAP INTO TABLE IT_VBAP WHERE VBELN = WA_VBAK-VBELN.
ENDFORM. "GETDATA
*&---------------------------------------------------------------------*
*& Form FIDCAT2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM FIDCAT2.
CLEAR WA_FC2.
WA_FC2-FIELDNAME = 'VBELN'.
WA_FC2-TABNAME = 'IT_VBAP'.
WA_FC2-COL_POS = 0.
WA_FC2-SELTEXT_L = 'SALSE DOC NO'.
APPEND WA_FC2 TO IT_FC2.
CLEAR WA_FC2.
WA_FC2-FIELDNAME = 'POSNR'.
WA_FC2-TABNAME = 'IT_VBAP'.
WA_FC2-COL_POS = 1.
WA_FC2-SELTEXT_L = 'SALSE DOC ITM'.
APPEND WA_FC2 TO IT_FC2.
CLEAR WA_FC2.
WA_FC2-FIELDNAME = 'MATNR'.
WA_FC2-TABNAME = 'IT_VBAP'.
WA_FC2-COL_POS = 2.
WA_FC2-SELTEXT_L = 'METIRIAL NO'.
APPEND WA_FC2 TO IT_FC2.
CLEAR WA_FC2.
WA_FC2-FIELDNAME = 'NETWR'.
WA_FC2-TABNAME = 'IT_VBAP'.
WA_FC2-COL_POS = 3.
WA_FC2-SELTEXT_L = 'NET VALUE CURR'.
APPEND WA_FC2 TO IT_FC2.
ENDFORM. "FIDCAT2
*&---------------------------------------------------------------------*
*& Form DISPLAY2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY2.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'V_REPID'
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'Salse item details(SECONDARY LIST)'
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = IT_FC2
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS = IT_EVE
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
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.
refresh it_fc2.
clear wa_fc2.
ENDFORM. "DISPLAY2
RESULT:
Then after the output list (VBAK) is displayed.
If we are double clicking the sales doc no ,
the secondary list ( VBAP) is displayed.
This is secondary list vbap details.
nice post thank you so much
ReplyDelete