Skip to Content
avatar image
Former Member

about alv

Hi Friends,

I work on alv. I have generated a simple the alv report. but

I want click particular row of report and then generate anather report.

How can I write a code for report .

Thanks

Rahul S.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

8 Answers

  • avatar image
    Former Member
    Mar 28, 2008 at 06:57 AM

    Hi ,

    You can acheive his ALV interavtive reports.

    First you have tomake use of events

    For your requiremnt you can make use of At-user command.

    Here with i am sending a sample code ;

    -


    &----


    *& Report ZUK_WIP03_ALV1

    *&

    &----


    *&

    *&

    &----


    REPORT ZUK_WIP03_ALV1 NO STANDARD PAGE HEADING MESSAGE-ID ZMSG44 LINE-COUNT 65(3).

    TYPE-POOLS : SLIS. " GLOBAL TYPE FOR GENERIC LIST MODULES.

    TABLES : MARC.

    DATA : V_REPID LIKE SY-REPID.

    DATA : IT_LISTHEADER TYPE SLIS_T_LISTHEADER.

    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

    PARAMETERS : P_WERKS LIKE MARC-WERKS OBLIGATORY VALUE CHECK.

    PARAMETERS : P_MATNR LIKE MARC-MATNR OBLIGATORY VALUE CHECK.

    SELECTION-SCREEN END OF BLOCK B1.

    • work areas

    DATA : W_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

    W_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV,

    W_EVENTS TYPE SLIS_ALV_EVENT,

    W_EVENTS1 TYPE SLIS_ALV_EVENT.

    • LAYOUT

    DATA : I_LAYOUT TYPE SLIS_LAYOUT_ALV.

    DATA : I_LAYOUT1 TYPE SLIS_LAYOUT_ALV.

    • table bodys

    DATA : I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

    I_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,

    I_EVENTS TYPE SLIS_T_EVENT,

    I_EVENTS1 TYPE SLIS_T_EVENT,

    I_LISTHEADER TYPE SLIS_T_LISTHEADER.

    • itab

    DATA : BEGIN OF ITAB OCCURS 0,

    MATNR LIKE MARC-MATNR,

    WERKS LIKE MARC-MATNR,

    LGORT LIKE MARD-LGORT,

    PSTAT LIKE MARD-PSTAT,

    LABST LIKE MARD-LABST,

    END OF ITAB .

    DATA : BEGIN OF I_MARC OCCURS 0,

    MATNR LIKE MARC-MATNR,

    WERKS LIKE MARC-WERKS,

    PSTAT LIKE MARC-PSTAT,

    END OF I_MARC.

    INITIALIZATION.

    V_REPID = SY-REPID.

    PERFORM BUILD-FIELDCAT.

    PERFORM EVENT-CALL.

    PERFORM EVENT-TABLE-POPULATE.

    START-OF-SELECTION.

    PERFORM DATA-RETREIVAL.

    PERFORM LIST-HEADER USING IT_LISTHEADER.

    PERFORM GRID-DISPLAY.

    END-OF-SELECTION.

    PERFORM LAYOUT-BUILDER.

    ************************************************************************************************************************

                                    • sub routines **************************************************************************

                                    *********************************************************************************************************************

                                    &----


                                    *& Form BUILD-FIELDCAT

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM BUILD-FIELDCAT .

                                    W_FIELDCAT-SELTEXT_L = 'MATERIAL-NO'.

                                    W_FIELDCAT-DATATYPE = 'CHAR'.

                                    W_FIELDCAT-OUTPUTLEN = 18.

                                    W_FIELDCAT-FIELDNAME = 'MATNR'.

                                    W_FIELDCAT-KEY = 'X'.

                                    W_FIELDCAT-HOTSPOT = 'X'.

                                    APPEND W_FIELDCAT TO I_FIELDCAT.

                                    CLEAR W_FIELDCAT.

                                    W_FIELDCAT-SELTEXT_L = 'PLANT'.

                                    W_FIELDCAT-DATATYPE = 'CHAR'.

                                    W_FIELDCAT-OUTPUTLEN = 6.

                                    W_FIELDCAT-FIELDNAME = 'WERKS'.

                                    W_FIELDCAT-HOTSPOT = 'X'.

                                    APPEND W_FIELDCAT TO I_FIELDCAT.

                                    CLEAR W_FIELDCAT.

                                    W_FIELDCAT-SELTEXT_L = 'STORAGE-LOC'.

                                    W_FIELDCAT-DATATYPE = 'CHAR'.

                                    W_FIELDCAT-OUTPUTLEN = 11.

                                    W_FIELDCAT-FIELDNAME = 'MATNR'.

                                    W_FIELDCAT-HOTSPOT = 'X'.

                                    APPEND W_FIELDCAT TO I_FIELDCAT.

                                    CLEAR W_FIELDCAT.

                                    W_FIELDCAT-SELTEXT_L = 'MAINT STATUS'.

                                    W_FIELDCAT-DATATYPE = 'CHAR'.

                                    W_FIELDCAT-OUTPUTLEN = 15.

                                    W_FIELDCAT-FIELDNAME = 'PSTAT'.

                                    W_FIELDCAT-HOTSPOT = 'X'.

                                    APPEND W_FIELDCAT TO I_FIELDCAT.

                                    CLEAR W_FIELDCAT.

                                    W_FIELDCAT-SELTEXT_L = 'VAL STC UR USE'.

                                    W_FIELDCAT-DATATYPE = 'CHAR'.

                                    W_FIELDCAT-OUTPUTLEN = 16.

                                    W_FIELDCAT-FIELDNAME = 'LABST'.

                                    W_FIELDCAT-HOTSPOT = 'X'.

                                    APPEND W_FIELDCAT TO I_FIELDCAT.

                                    CLEAR W_FIELDCAT.

                                    ENDFORM. " BUILD-FIELDCAT

                                    • A list of possible events is populated into an event table (I_EVENTS) when this table is passed to the function module REUSE_ALV_EVENT_NAMES_GET.

                                    *The return table from this function module contains all the possible events.

                                    &----


                                    *& Form EVENT-CALL

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM EVENT-CALL .

                                    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

                                    EXPORTING

                                    I_LIST_TYPE = 0

                                    IMPORTING

                                    ET_EVENTS = I_EVENTS

                                    EXCEPTIONS

                                    LIST_TYPE_WRONG = 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. " EVENT-CALL

                                    &----


                                    *& Form EVENT-TABLE-POPULATE

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM EVENT-TABLE-POPULATE .

                                    READ TABLE I_EVENTS INTO W_EVENTS WITH KEY NAME = 'TOP-OF-PAGE'.

                                    IF SY-SUBRC EQ 0.

                                    W_EVENTS-FORM = 'TOP-OF-PAGE'.

                                    MODIFY I_EVENTS FROM W_EVENTS INDEX SY-TABIX.

                                    ENDIF.

                                    READ TABLE I_EVENTS INTO W_EVENTS WITH KEY NAME = 'USER-COMMAND'.

                                    IF SY-SUBRC EQ 0.

                                    W_EVENTS-FORM = 'ALV_USER_COMMAND'.

                                    MODIFY I_EVENTS FROM W_EVENTS TRANSPORTING FORM WHERE NAME = W_EVENTS-NAME.

                                    ENDIF.

                                    READ TABLE I_EVENTS INTO W_EVENTS WITH KEY NAME = 'SET-PF-STATUS'.

                                    IF SY-SUBRC EQ 0.

                                    W_EVENTS-FORM = 'ALV_SET_PF_STATUS'.

                                    MODIFY I_EVENTS FROM W_EVENTS INDEX SY-TABIX.

                                    ENDIF.

                                    • The report will contain THREE forms for the events.

                                    ENDFORM. " EVENT-TABLE-POPULATE

                                    &----


                                    *& Form DATA-RETREIVAL

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM DATA-RETREIVAL .

                                    SELECT MATNR

                                    WERKS

                                    LGORT

                                    PSTAT

                                    LABST

                                    FROM MARD

                                    INTO TABLE ITAB

                                    WHERE WERKS = P_WERKS.

                                    ENDFORM. " DATA-RETREIVAL

                                    &----


                                    *& Form TOP-OF-PAGE

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM TOP-OF-PAGE .

                                    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

                                    EXPORTING

                                    IT_LIST_COMMENTARY = IT_LISTHEADER

                                    I_LOGO = 'ENJOYSAP_LOGO'

                                    • I_END_OF_LIST_GRID =

                                    • I_ALV_FORM =

                                    .

                                    ENDFORM. " TOP-OF-PAGE

                                    &----


                                    *& Form LAYOUT-BUILDER

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM LAYOUT-BUILDER .

                                    I_LAYOUT-F2CODE = 'PICK'.

                                    I_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

                                    I_LAYOUT-WINDOW_TITLEBAR = 'X'.

                                    I_LAYOUT-KEY_HOTSPOT = 'X'.

                                    ENDFORM. " LAYOUT-BUILDER

                                    &----


                                    *& Form LIST-HEADER

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM LIST-HEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

                                    DATA : HLINE TYPE SLIS_LISTHEADER.

                                    HLINE-TYP = 'H'.

                                    HLINE-INFO = 'THIS IS MY FIRST ALV PGM'.

                                    APPEND HLINE TO I_LISTHEADER.

                                    CLEAR HLINE.

                                    ENDFORM. " LIST-HEADER

                                    &----


                                    *& Form GRID-DISPLAY

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM GRID-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 = 'ALV_SET_PF_STATUS'

                                    I_CALLBACK_USER_COMMAND = 'ALV_USER_COMMAND'

                                    I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'

                                    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

                                    • I_CALLBACK_HTML_END_OF_LIST = ' '

                                    • I_STRUCTURE_NAME =

                                    • I_BACKGROUND_ID = ' '

                                    I_GRID_TITLE = 'STORAGE LOC DETAILS'

                                    • I_GRID_SETTINGS =

                                    IS_LAYOUT = I_LAYOUT

                                    IT_FIELDCAT = I_FIELDCAT[]

                                    • IT_EXCLUDING =

                                    • IT_SPECIAL_GROUPS =

                                    • IT_SORT =

                                    • IT_FILTER =

                                    • IS_SEL_HIDE =

                                    • I_DEFAULT = 'X'

                                    • I_SAVE = ' '

                                    • IS_VARIANT =

                                    IT_EVENTS = I_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 = ITAB

                                    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. " GRID-DISPLAY

                                    &----


                                    *& Form ALV_SET_PF_STATUS

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM ALV_SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.

                                    SET PF-STATUS 'ALVIN'.

                                    ENDFORM. " ALV_SET_PF_STATUS

                                    &----


                                    *& Form ALV_USER_COMMAND

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM ALV_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

                                    RS_SELFIELD TYPE SLIS_SELFIELD.

                                    DATA : V_FCODE TYPE SY-UCOMM.

                                    V_FCODE = R_UCOMM.

                                    CLEAR R_UCOMM.

                                    CASE V_FCODE.

                                    WHEN 'PICK'.

                                    PERFORM AT-LINE-SELECTION.

                                    WHEN 'EXIT'.

                                    PERFORM EXIT.

                                    ENDCASE.

                                    ENDFORM. " ALV_USER_COMMAND

                                    &----


                                    *& Form AT-LINE-SELECTION

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM AT-LINE-SELECTION .

                                    DATA : V_SEL_LINE TYPE I.

                                    DATA : RS_SELFIELD TYPE SLIS_SELFIELD.

                                    V_SEL_LINE = RS_SELFIELD-TABINDEX.

                                    READ TABLE I_MARC INDEX V_SEL_LINE.

                                    PERFORM DATA_RETREIVAL_MARC.

                                    PERFORM BUILD_FIELDCAT_MARC.

                                    • PERFORM EVENT_CALL_MARC.

                                    • PERFORM EVENT_POPULATE_MARC.

                                    PERFORM GRID_DISP_MARC.

                                    ENDFORM. " AT-LINE-SELECTION

                                    &----


                                    *& Form EXIT

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM EXIT .

                                    DATA : RS_SELFIELD TYPE SLIS_SELFIELD.

                                    RS_SELFIELD-EXIT = 'X'.

                                    ENDFORM. " EXIT

                                    &----


                                    *& Form DATA_RETREIVAL_MARC

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM DATA_RETREIVAL_MARC .

                                    SELECT MATNR

                                    WERKS

                                    PSTAT

                                    FROM MARC

                                    INTO TABLE I_MARC.

                                    • WHERE WERKS = P_WERKS.

                                    ENDFORM. " DATA_RETREIVAL_MARC

                                    &----


                                    *& Form BUILD_FIELDCAT_MARC

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM BUILD_FIELDCAT_MARC .

                                    W_FIELDCAT1-SELTEXT_L = 'MATERIAL-NO'.

                                    W_FIELDCAT1-DATATYPE = 'CHAR'.

                                    W_FIELDCAT1-OUTPUTLEN = 18.

                                    W_FIELDCAT1-FIELDNAME = 'MATNR'.

                                    W_FIELDCAT1-KEY = 'X'.

                                    W_FIELDCAT1-HOTSPOT = 'X'.

                                    APPEND W_FIELDCAT1 TO I_FIELDCAT1.

                                    CLEAR W_FIELDCAT1.

                                    W_FIELDCAT-SELTEXT_L = 'PLANT'.

                                    W_FIELDCAT1-DATATYPE = 'CHAR'.

                                    W_FIELDCAT1-OUTPUTLEN = 6.

                                    W_FIELDCAT1-FIELDNAME = 'WERKS'.

                                    W_FIELDCAT1-HOTSPOT = 'X'.

                                    APPEND W_FIELDCAT1 TO I_FIELDCAT1.

                                    CLEAR W_FIELDCAT1.

                                    W_FIELDCAT1-SELTEXT_L = 'MAINT STATUS'.

                                    W_FIELDCAT1-DATATYPE = 'CHAR'.

                                    W_FIELDCAT1-OUTPUTLEN = 15.

                                    W_FIELDCAT1-FIELDNAME = 'PSTAT'.

                                    W_FIELDCAT1-HOTSPOT = 'X'.

                                    APPEND W_FIELDCAT1 TO I_FIELDCAT1.

                                    CLEAR W_FIELDCAT1.

                                    ENDFORM. " BUILD_FIELDCAT_MARC

                                    &----


                                    *& Form GRID_DISP_MARC

                                    &----


                                    • text

                                    ----


                                    • --> p1 text

                                    • <-- p2 text

                                    ----


                                    FORM GRID_DISP_MARC .

                                    SET PF-STATUS SPACE.

                                    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 = 'PLANT DETAILS'

                                    • I_GRID_SETTINGS =

                                    • IS_LAYOUT =

                                    IT_FIELDCAT = I_FIELDCAT1[]

                                    • IT_EXCLUDING =

                                    • IT_SPECIAL_GROUPS =

                                    • IT_SORT =

                                    • IT_FILTER =

                                    • IS_SEL_HIDE =

                                    • I_DEFAULT = 'X'

                                    • I_SAVE = ' '

                                    • 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 = I_MARC

                                    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. " GRID_DISP_MARC

                                    -


                                    reward if helpful

                                    Rgds

                                    Umakanth

                                    Add comment
                                    10|10000 characters needed characters exceeded

                                  • Mar 28, 2008 at 07:00 AM

                                    Hi,

                                    I have created a report which is using SFLIGHT table.

                                    You can modify the tables and fieldnames.

                                    Also you have to modify in the FORM USERCOMMAND.

                                    and FORM GETDATA which fetches the DATA.

                                    
                                    *&---------------------------------------------------------------------*
                                    *& Report  ZDS_ALV_3 USERCOMMAND
                                    *&
                                    *&---------------------------------------------------------------------*
                                    *&
                                    *&
                                    *&---------------------------------------------------------------------*
                                    
                                    REPORT  ZDS_ALV_3.
                                    
                                    TYPE-POOLS: SLIS.
                                    
                                    TABLES:SFLIGHT.
                                    
                                    
                                    
                                    INITIALIZATION.
                                    
                                    SELECT-OPTIONS: S_CARRID FOR SFLIGHT-CARRID DEFAULT 'AA' TO 'LH'.
                                    
                                    DATA: GT_HEADER TYPE SLIS_T_LISTHEADER.
                                    DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
                                    
                                    
                                    
                                    DATA: G_REPID TYPE SY-REPID.
                                    
                                    TYPES: BEGIN OF TY_SFLIGHT,
                                           CARRID TYPE SFLIGHT-CARRID,
                                           CONNID TYPE SFLIGHT-CONNID,
                                           PRICE TYPE SFLIGHT-PRICE,
                                           CURRENCY TYPE SFLIGHT-CURRENCY,
                                           END OF TY_SFLIGHT.
                                    
                                    DATA: WA_SFLIGHT TYPE TY_SFLIGHT.
                                    
                                    DATA: IT_SFLIGHT TYPE STANDARD TABLE OF TY_SFLIGHT.
                                    
                                    DATA: IT_SFLIGHT_UC TYPE STANDARD TABLE OF TY_SFLIGHT.
                                    
                                    G_REPID = SY-REPID.
                                    PERFORM BUILD_HEADER USING GT_HEADER.
                                    PERFORM BUILD_COMMENTRY.
                                    
                                    PERFORM FIELDCAT_INIT USING GT_FIELDCAT[].
                                    
                                    FORM BUILD_HEADER USING GT_HEADER TYPE SLIS_T_LISTHEADER.
                                    
                                    DATA: TP TYPE SLIS_LISTHEADER.
                                    
                                    DATA: TEXT(20) TYPE C,
                                            DT(10).
                                    
                                    
                                      TP-TYP = 'H'.
                                      TP-INFO = 'ALV'.
                                      APPEND TP TO GT_HEADER.
                                      CLEAR TP.
                                    
                                      WRITE SY-DATUM TO DT DD/MM/YYYY.
                                    
                                      CONCATENATE 'DATE :' DT INTO TEXT.
                                      TP-TYP = 'S'.
                                      TP-INFO = TEXT.
                                      APPEND TP TO GT_HEADER.
                                      CLEAR TP.
                                    
                                    ENDFORM.
                                    FORM BUILD_COMMENTRY.
                                    
                                        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
                                        EXPORTING
                                          IT_LIST_COMMENTARY = GT_HEADER[]
                                          I_LOGO             = 'ENJOYSAP_LOGO'.
                                    
                                    ENDFORM.
                                    
                                    FORM FIELDCAT_INIT
                                          USING IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
                                      DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
                                    *  DATA: POS TYPE I VALUE 1.
                                    
                                      clear ls_fieldcat.
                                    *  LS_FIELDCAT-COL_POS       =  1.
                                      LS_FIELDCAT-FIELDNAME     = 'CARRID'.
                                      LS_FIELDCAT-tabname = 'it_sflight'.
                                      ls_fieldcat-ref_fieldname = 'CARRID'.
                                      LS_FIELDCAT-OUTPUTLEN = 20.
                                      LS_FIELDCAT-REF_TABNAME   = 'SCARR'.
                                      LS_FIELDCAT-KEY           = 'X'.
                                      LS_FIELDCAT-KEY_SEL =  'X'.
                                    
                                      APPEND LS_FIELDCAT TO  IT_FIELDCAT.
                                      clear ls_fieldcat.
                                    
                                      LS_FIELDCAT-FIELDNAME     = 'CONNID'.
                                      APPEND LS_FIELDCAT TO  IT_FIELDCAT.
                                      clear ls_fieldcat.
                                    
                                      LS_FIELDCAT-FIELDNAME     = 'PRICE'.
                                      APPEND LS_FIELDCAT TO  IT_FIELDCAT.
                                      clear ls_fieldcat.
                                    
                                      LS_FIELDCAT-FIELDNAME     = 'CURRENCY'.
                                      APPEND LS_FIELDCAT TO  IT_FIELDCAT.
                                      clear ls_fieldcat.
                                    
                                      ENDFORM.
                                    
                                    START-OF-SELECTION.
                                    
                                    PERFORM GET_DATA.
                                    
                                    
                                    
                                    FORM GET_DATA.
                                    
                                      SELECT CARRID CONNID PRICE CURRENCY FROM SFLIGHT INTO TABLE IT_SFLIGHT
                                      WHERE CARRID IN S_CARRID.
                                    
                                    ENDFORM.
                                    END-OF-SELECTION.
                                    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
                                     EXPORTING
                                       I_CALLBACK_PROGRAM                = G_REPID
                                       I_CALLBACK_TOP_OF_PAGE          = 'BUILD_COMMENTRY'
                                       I_CALLBACK_USER_COMMAND           = 'USR_COMMAND'
                                       IT_FIELDCAT                       = GT_FIELDCAT[]
                                      TABLES
                                        T_OUTTAB                         = IT_SFLIGHT
                                     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.
                                    
                                    FORM USR_COMMAND USING UCOM TYPE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD.
                                    
                                    IF UCOM = '&IC1'.
                                      CLEAR GT_FIELDCAT[].
                                    
                                      READ TABLE IT_SFLIGHT INTO WA_SFLIGHT INDEX SELFIELD-TABINDEX.
                                      APPEND WA_SFLIGHT TO IT_SFLIGHT_UC.
                                    
                                      PERFORM FIELDCAT_INIT USING GT_FIELDCAT[].
                                      PERFORM ALV_GRID_DISPLAY_UC.
                                    
                                      CLEAR IT_SFLIGHT_UC[].
                                    ENDIF.
                                    
                                    ENDFORM.
                                    *&---------------------------------------------------------------------*
                                    *&      Form  ALV_GRID_DISPLAY_UC
                                    *&---------------------------------------------------------------------*
                                    *       text
                                    *----------------------------------------------------------------------*
                                    *  -->  p1        text
                                    *  <--  p2        text
                                    *----------------------------------------------------------------------*
                                    FORM ALV_GRID_DISPLAY_UC .
                                    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
                                     EXPORTING
                                    *   I_INTERFACE_CHECK                 = ' '
                                    *   I_BYPASSING_BUFFER                = ' '
                                    *   I_BUFFER_ACTIVE                   = ' '
                                       I_CALLBACK_PROGRAM                = G_REPID
                                    *   I_CALLBACK_PF_STATUS_SET          = ' '
                                       I_CALLBACK_USER_COMMAND           = 'USR_COMMAND'
                                       I_CALLBACK_TOP_OF_PAGE            = 'BUILD_COMMENTRY'
                                    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
                                    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
                                    *   I_STRUCTURE_NAME                  =
                                    *   I_BACKGROUND_ID                   = ' '
                                    *   I_GRID_TITLE                      =
                                    *   I_GRID_SETTINGS                   =
                                    *   IS_LAYOUT                         =
                                       IT_FIELDCAT                        = gt_fieldcat[]
                                    *   IT_EXCLUDING                      =
                                    *   IT_SPECIAL_GROUPS                 =
                                    *   IT_SORT                           =
                                    *   IT_FILTER                         =
                                    *   IS_SEL_HIDE                       =
                                    *   I_DEFAULT                         = 'X'
                                    *   I_SAVE                            = ' '
                                    *   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_SFLIGHT_UC
                                     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.                    " ALV_GRID_DISPLAY_UC
                                    
                                    
                                    
                                    

                                    HTH

                                    Regards,

                                    Dhruv Shah

                                    Add comment
                                    10|10000 characters needed characters exceeded

                                  • avatar image
                                    Former Member
                                    Mar 28, 2008 at 07:08 AM

                                    Hi ,

                                    You need to handle the event AT-USER-COMMAND.

                                    In this event use SUBMIT statement for your report.

                                    Regards

                                    Sourabh Verma

                                    Add comment
                                    10|10000 characters needed characters exceeded

                                  • avatar image
                                    Former Member
                                    Mar 28, 2008 at 07:09 AM

                                    Hi

                                    TYPE-POOLS : slis.

                                    TYPES : BEGIN OF st_ekko,

                                    ebeln TYPE ekko-ebeln, "Purchasing Document Number

                                    bstyp TYPE ekko-bstyp, "Purchasing Document Category

                                    bsart TYPE ekko-bsart, "Purchasing Document Type

                                    aedat TYPE ekko-aedat, "record created on

                                    ernam TYPE ekko-ernam, "Person who Created the Object

                                    check(1),

                                    END OF st_ekko.

                                    TYPES : BEGIN OF st_ekpo,

                                    ebeln TYPE ekko-ebeln,

                                    ebelp TYPE ekpo-ebelp, "Item Number of Purchasing Document

                                    ematn TYPE ekpo-ematn, "Material number

                                    matkl TYPE ekpo-matkl, "Material group

                                    netpr TYPE ekpo-netpr, "Net price in purchasing document

                                    END OF st_ekpo.

                                    TYPES : BEGIN OF st_ebeln,

                                    ebeln TYPE ekpo-ebeln,

                                    END OF st_ebeln.

                                    TYPES : BEGIN OF st_eine,

                                    ebeln TYPE ekko-ebeln,

                                    ekorg TYPE eine-ekorg,

                                    ekgrp TYPE eine-ekgrp,

                                    END OF st_eine.

                                    TYPES : BEGIN OF st_check,

                                    check(1),

                                    END OF st_check.

                                    DATA : it_ekpo TYPE STANDARD TABLE OF st_ekpo,

                                    it_ekko TYPE STANDARD TABLE OF st_ekko,

                                    wa_ekko LIKE LINE OF it_ekko,

                                    it_fieldcat TYPE slis_t_fieldcat_alv,

                                    wa_fieldcat LIKE LINE OF it_fieldcat,

                                    wa_layout TYPE slis_layout_alv,

                                    it_events TYPE slis_t_event,

                                    st_event LIKE LINE OF it_events,

                                    it_listheadr TYPE slis_t_listheader ,

                                    wa_listheadr LIKE LINE OF it_listheadr,

                                    st_printparams TYPE slis_print_alv,

                                    it_sortinfo TYPE slis_t_sortinfo_alv,

                                    wa_sortinfo LIKE LINE OF it_sortinfo,

                                    it_ekposortinfo TYPE slis_t_sortinfo_alv,

                                    wa_ekposortinfo LIKE LINE OF it_ekposortinfo,

                                    it_filter TYPE slis_t_filter_alv,

                                    it_ebeln TYPE STANDARD TABLE OF st_ebeln,

                                    it_eine TYPE STANDARD TABLE OF st_eine,

                                    wa_eine TYPE st_eine,

                                    it_popup TYPE STANDARD TABLE OF st_eine,

                                    wa_popup TYPE st_eine,

                                    it_check TYPE STANDARD TABLE OF st_check,

                                    wa_check TYPE st_check.

                                    DATA : v_ebeln TYPE ekko-ebeln.

                                    ----


                                    • SELECTION-SCREEN

                                    ----


                                    SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE tit.

                                    SELECT-OPTIONS: so_ebeln FOR v_ebeln OBLIGATORY.

                                    SELECTION-SCREEN END OF BLOCK b.

                                    ----


                                    • INITIALIZATION

                                    ----


                                    INITIALIZATION.

                                    tit = text-000.

                                    ----


                                    • AT SELECTION-SCREEN ON

                                    ----


                                    AT SELECTION-SCREEN ON so_ebeln.

                                    PERFORM validate_ebeln.

                                    ----


                                    • START-OF-SELECTION

                                    ----


                                    START-OF-SELECTION.

                                    PERFORM get_ekko_data.

                                    PERFORM get_eine_data.

                                    ----


                                    • END-OF-SELECTION

                                    ----


                                    END-OF-SELECTION.

                                    PERFORM populate_fieldcat1.

                                    PERFORM populate_layout.

                                    PERFORM get_eventlist.

                                    PERFORM get_ekkosortinfo.

                                    PERFORM ekkodisplay_onalv.

                                    &----


                                    *& Form POPULATE_FIELDCAT1

                                    &----


                                    FORM populate_fieldcat1.

                                    wa_fieldcat-fieldname = 'EBELN'.

                                    wa_fieldcat-seltext_l = text-004.

                                    wa_fieldcat-no_zero = 'X'.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    wa_fieldcat-fieldname = 'BSTYP'.

                                    wa_fieldcat-seltext_l = text-005.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    wa_fieldcat-fieldname = 'BSART'.

                                    wa_fieldcat-seltext_l = text-006.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    wa_fieldcat-fieldname = 'AEDAT'.

                                    wa_fieldcat-seltext_l = text-007.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    wa_fieldcat-fieldname = 'ERNAM'.

                                    wa_fieldcat-seltext_l = text-008.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    ENDFORM. "POPULATE_FIELDCAT1

                                    &----


                                    *& Form populate_fieldcat2

                                    &----


                                    FORM populate_fieldcat2 .

                                    CLEAR wa_fieldcat.

                                    CLEAR it_fieldcat.

                                    REFRESH it_fieldcat.

                                    wa_fieldcat-fieldname = 'EBELN'.

                                    wa_fieldcat-seltext_l = text-004.

                                    wa_fieldcat-hotspot = 'X'.

                                    • wa_fieldcat-no_zero = 'X'.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    wa_fieldcat-fieldname = 'EBELP'.

                                    wa_fieldcat-seltext_l = text-009.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    wa_fieldcat-fieldname = 'EMATN'.

                                    wa_fieldcat-seltext_l = text-010.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    wa_fieldcat-fieldname = 'MATKL'.

                                    wa_fieldcat-seltext_l = text-011.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    wa_fieldcat-fieldname = 'NETPR'.

                                    wa_fieldcat-seltext_l = text-012.

                                    wa_fieldcat-datatype = 'CURR'. "Obligatory to perform SUM

                                    wa_fieldcat-do_sum = 'X'.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    ENDFORM. "populate_fieldcat2

                                    &----


                                    *& Form GET_EVENTLIST

                                    &----


                                    FORM get_eventlist.

                                    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

                                    EXPORTING

                                    i_list_type = 0

                                    IMPORTING

                                    et_events = it_events[]

                                    EXCEPTIONS

                                    list_type_wrong = 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.

                                    READ TABLE it_events WITH KEY name = slis_ev_pf_status_set INTO st_event.

                                    IF sy-subrc EQ 0.

                                    st_event-form = 'SET_PF_STATUS1'.

                                    APPEND st_event TO it_events.

                                    CLEAR st_event.

                                    ENDIF.

                                    READ TABLE it_events WITH KEY name = slis_ev_end_of_page INTO st_event.

                                    IF sy-subrc EQ 0.

                                    st_event-form = 'END_OF_PAGE'.

                                    APPEND st_event TO it_events.

                                    CLEAR st_event.

                                    ENDIF.

                                    ENDFORM. "GET_EVENTLIST

                                    &----


                                    *& Form ekpodisplay_onalv

                                    &----


                                    FORM ekpodisplay_onalv .

                                    IF it_ekpo[] IS INITIAL.

                                    MESSAGE 'NO DATA FOUND' TYPE 'I'.

                                    ELSE.

                                    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

                                    EXPORTING

                                    i_callback_program = sy-repid

                                    i_callback_pf_status_set = 'SET_PF_STATUS'

                                    i_callback_user_command = 'AT_USER_COMMAND1'

                                    i_callback_top_of_page = 'TOP_OF_PAGE'

                                    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

                                    • I_CALLBACK_HTML_END_OF_LIST = ' '

                                    • I_STRUCTURE_NAME = I_STRUCTURE_NAME

                                    • I_BACKGROUND_ID = ' '

                                    • I_GRID_TITLE = I_GRID_TITLE

                                    • I_GRID_SETTINGS = I_GRID_SETTINGS

                                    is_layout = wa_layout

                                    it_fieldcat = it_fieldcat

                                    • IT_EXCLUDING = IT_EXCLUDING

                                    • IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS

                                    it_sort = it_ekposortinfo[]

                                    • IT_FILTER = IT_FILTER

                                    • IS_SEL_HIDE = IS_SEL_HIDE

                                    • I_DEFAULT = 'X'

                                    • I_SAVE = ' '

                                    • IS_VARIANT = IS_VARIANT

                                    • it_events = it_events

                                    • IT_EVENT_EXIT = IT_EVENT_EXIT

                                    • IS_PRINT = IS_PRINT

                                    • IS_REPREP_ID = 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_ALV_GRAPHICS

                                    • IT_HYPERLINK = IT_HYPERLINK

                                    • IT_ADD_FIELDCAT = IT_ADD_FIELDCAT

                                    • IT_EXCEPT_QINFO = IT_EXCEPT_QINFO

                                    • IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER

                                    • IMPORTING

                                    • E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER

                                    • ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER

                                    TABLES

                                    t_outtab = it_ekpo

                                    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.

                                    ENDIF.

                                    ENDFORM. "ekpodisplay_onalv

                                    &----


                                    *& Form SET_PF_STATUS1

                                    &----


                                    FORM set_pf_status1 USING rt_extab TYPE slis_t_extab.

                                    SET PF-STATUS 'MENU' excluding rt_extab. "Copy from SALV .

                                    ENDFORM. "SET_PF_STATUS1

                                    &----


                                    *& Form SET_PF_STATUS

                                    &----


                                    FORM set_pf_status USING rt_extab TYPE slis_t_extab.

                                    SET PF-STATUS 'STANDARD' excluding rt_extab. "Copy from SALV .

                                    ENDFORM. "SET_PF_STATUS

                                    &----


                                    *& Form AT_user_command

                                    &----


                                    FORM at_user_command USING r_ucomm LIKE sy-ucomm

                                    rs_selfield TYPE slis_selfield.

                                    CASE r_ucomm.

                                    WHEN '&IC1'.

                                    IF rs_selfield-fieldname EQ 'EBELN'.

                                    READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.

                                    SELECT ebeln ebelp ematn matkl netpr

                                    FROM ekpo

                                    INTO TABLE it_ekpo

                                    WHERE ebeln EQ wa_ekko-ebeln.

                                    PERFORM populate_fieldcat2.

                                    PERFORM populate_layout2.

                                    PERFORM get_ekposortinfo.

                                    PERFORM ekpodisplay_onalv.

                                    ELSE.

                                    MESSAGE i020(z50871msg) WITH text-013.

                                    ENDIF.

                                    WHEN 'SE16'.

                                    CALL TRANSACTION 'SE16'.

                                    WHEN 'SE37'.

                                    CALL TRANSACTION 'SE37'.

                                    WHEN 'DISP'.

                                    PERFORM get_popupdata.

                                    PERFORM get_popupfcat.

                                    PERFORM display_popup.

                                    ENDCASE.

                                    ENDFORM. "AT_user_command

                                    &----


                                    *& Form TOP_OF_PAGE

                                    &----


                                    FORM top_of_page.

                                    REFRESH it_listheadr.

                                    wa_listheadr-typ = 'H'.

                                    wa_listheadr-info = text-001.

                                    APPEND wa_listheadr TO it_listheadr.

                                    CLEAR wa_listheadr.

                                    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

                                    EXPORTING

                                    it_list_commentary = it_listheadr[]

                                    i_logo = 'ENJOYSAP_LOGO'. "From OAER transaction

                                    ENDFORM. "TOP_OF_PAGE

                                    &----


                                    *& Form build_print_params

                                    &----


                                    FORM build_print_params.

                                    st_printparams-reserve_lines = '3'. "Lines reserved for footer

                                    st_printparams-no_coverpage = 'X'.

                                    ENDFORM. "build_print_params

                                    &----


                                    *& Form end_of_page

                                    &----


                                    FORM end_of_page.

                                    REFRESH it_listheadr.

                                    wa_listheadr-typ = 'H'.

                                    wa_listheadr-info = sy-pagno.

                                    APPEND wa_listheadr TO it_listheadr.

                                    CLEAR wa_listheadr.

                                    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

                                    EXPORTING

                                    it_list_commentary = it_listheadr[].

                                    ENDFORM. "end_of_page

                                    &----


                                    *& Form GET_EKPOSORTINFO

                                    &----


                                    FORM get_ekposortinfo.

                                    wa_ekposortinfo-up = 'X'.

                                    wa_ekposortinfo-spos = 1.

                                    wa_ekposortinfo-fieldname = 'EBELP'.

                                    wa_ekposortinfo-tabname = 'EKPO'.

                                    APPEND wa_ekposortinfo TO it_ekposortinfo.

                                    CLEAR wa_ekposortinfo.

                                    wa_ekposortinfo-up = 'X'.

                                    wa_ekposortinfo-spos = 2.

                                    wa_ekposortinfo-fieldname = 'EMATN'.

                                    wa_ekposortinfo-tabname = 'EKPO'.

                                    APPEND wa_ekposortinfo TO it_ekposortinfo.

                                    CLEAR wa_ekposortinfo.

                                    ENDFORM. "GET_EKPOSORTINFO

                                    *

                                    &----


                                    *& Form POPULATE_LAYOUT

                                    &----


                                    FORM populate_layout.

                                    wa_layout-colwidth_optimize = 'X'. "column width

                                    wa_layout-zebra = 'X'.

                                    • wa_layout-no_hline = 'X'.

                                    • wa_layout-no_vline = 'X'.

                                    • wa_layout-cell_merge = 'X'.

                                    wa_layout-box_fieldname = 'CHECK'.

                                    wa_layout-box_tabname = 'IT_EKKO'.

                                    wa_layout-window_titlebar = 'PURCHASE ORDER HEADER DETAILS'.

                                    ENDFORM. "POPULATE_LAYOUT

                                    &----


                                    *& Form get_EKKOsortinfo

                                    &----


                                    FORM get_ekkosortinfo.

                                    wa_sortinfo-up = 'X'.

                                    wa_sortinfo-spos = 1.

                                    wa_sortinfo-fieldname = 'EBELN'.

                                    wa_sortinfo-tabname = 'EKKO'.

                                    APPEND wa_sortinfo TO it_sortinfo.

                                    CLEAR wa_sortinfo.

                                    wa_sortinfo-up = 'X'.

                                    wa_sortinfo-spos = 2.

                                    wa_sortinfo-fieldname = 'BSTYP'.

                                    wa_sortinfo-tabname = 'EKKO'.

                                    APPEND wa_sortinfo TO it_sortinfo.

                                    CLEAR wa_sortinfo.

                                    wa_sortinfo-up = 'X'.

                                    wa_sortinfo-spos = 3.

                                    wa_sortinfo-fieldname = 'AEDAT'.

                                    wa_sortinfo-tabname = 'EKKO'.

                                    APPEND wa_sortinfo TO it_sortinfo.

                                    CLEAR wa_sortinfo.

                                    ENDFORM. "get_EKKOsortinfo

                                    &----


                                    *& Form EKKODISPLAY_ONALV

                                    &----


                                    FORM ekkodisplay_onalv.

                                    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

                                    EXPORTING

                                    i_callback_program = sy-repid

                                    i_callback_pf_status_set = 'SET_PF_STATUS1'

                                    i_callback_user_command = 'AT_USER_COMMAND'

                                    is_layout = wa_layout

                                    it_fieldcat = it_fieldcat

                                    it_sort = it_sortinfo[]

                                    it_filter = it_filter

                                    it_events = it_events[]

                                    TABLES

                                    t_outtab = it_ekko[]

                                    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. "EKKODISPLAY_ONALV

                                    &----


                                    *& Form validate_ebeln

                                    &----


                                    FORM validate_ebeln.

                                    SELECT ebeln

                                    FROM ekpo

                                    INTO TABLE it_ebeln

                                    WHERE ebeln IN so_ebeln.

                                    IF sy-subrc NE 0.

                                    MESSAGE e020(z50871msg) WITH text-014.

                                    ENDIF.

                                    ENDFORM. "validate_ebeln

                                    &----


                                    *& Form populate_layout2

                                    &----


                                    FORM populate_layout2 .

                                    CLEAR wa_layout.

                                    wa_layout-colwidth_optimize = 'X'. "column width

                                    • wa_layout-zebra = 'X'.

                                    • wa_layout-no_hline = 'X'.

                                    • wa_layout-no_vline = 'X'.

                                    • wa_layout-cell_merge = 'X'.

                                    wa_layout-window_titlebar = 'PURCHASE ORDER DETAILS SECOND SCREEN'.

                                    ENDFORM. " populate_layout2

                                    &----


                                    *& Form GET_POPUPDATA

                                    &----


                                    FORM get_popupdata .

                                    LOOP AT it_ekko INTO wa_ekko WHERE check = 'X'.

                                    READ TABLE it_eine INTO wa_eine WITH KEY ebeln = wa_ekko-ebeln.

                                    IF sy-subrc NE 0.

                                    MESSAGE i020(z50871msg) WITH text-015 wa_ekko-ebeln .

                                    ELSE.

                                    wa_popup-ebeln = wa_eine-ebeln.

                                    wa_popup-ekorg = wa_eine-ekorg.

                                    wa_popup-ekgrp = wa_eine-ekgrp.

                                    APPEND wa_popup TO it_popup.

                                    ENDIF.

                                    ENDLOOP.

                                    ENDFORM. " GET_POPUPDATA

                                    &----


                                    *& Form GET_POPUPFCAT

                                    &----


                                    FORM get_popupfcat .

                                    CLEAR wa_fieldcat.

                                    REFRESH it_fieldcat.

                                    wa_fieldcat-fieldname = 'EBELN'.

                                    wa_fieldcat-seltext_l = text-004.

                                    wa_fieldcat-hotspot = 'X'.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    wa_fieldcat-fieldname = 'EKORG'.

                                    wa_fieldcat-seltext_l = text-016.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    wa_fieldcat-fieldname = 'EKGRP'.

                                    wa_fieldcat-seltext_l = text-017.

                                    APPEND wa_fieldcat TO it_fieldcat.

                                    ENDFORM. " GET_POPUPFCAT

                                    &----


                                    *& Form DISPLAY_POPUP

                                    &----


                                    FORM display_popup .

                                    LOOP AT it_ekko INTO wa_ekko WHERE check EQ 'X'.

                                    wa_check-check = wa_ekko-check.

                                    APPEND wa_check TO it_check.

                                    ENDLOOP.

                                    IF it_check[] IS INITIAL.

                                    MESSAGE i020(z50871msg) WITH text-018.

                                    ENDIF.

                                    IF NOT it_popup[] IS INITIAL.

                                    CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

                                    EXPORTING

                                    i_title = text-003

                                    i_allow_no_selection = 'X'

                                    i_scroll_to_sel_line = 'X'

                                    i_tabname = 'IT_POPUP'

                                    it_fieldcat = it_fieldcat

                                    i_callback_program = sy-repid

                                    TABLES

                                    t_outtab = it_popup

                                    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.

                                    ENDIF.

                                    REFRESH it_check.

                                    REFRESH it_popup.

                                    ENDFORM. " DISPLAY_POPUP

                                    &----


                                    *& Form get_ekko_data

                                    &----


                                    FORM get_ekko_data .

                                    SELECT ebeln bstyp bsart aedat ernam

                                    FROM ekko

                                    INTO CORRESPONDING FIELDS OF TABLE it_ekko

                                    WHERE ebeln IN so_ebeln.

                                    IF sy-subrc NE 0.

                                    MESSAGE e020(z50871msg) WITH text-019.

                                    ENDIF.

                                    ENDFORM. " get_ekko_data

                                    &----


                                    *& Form get_eine_data

                                    &----


                                    FORM get_eine_data .

                                    SELECT ebeln ekorg ekgrp

                                    FROM eine

                                    INTO TABLE it_eine

                                    WHERE ebeln IN so_ebeln.

                                    ENDFORM. " get_eine_data

                                    &----


                                    *& Form at_user_command1

                                    &----


                                    FORM at_user_command1 USING r_ucomm LIKE sy-ucomm

                                    rs_selfield TYPE slis_selfield.

                                    CASE r_ucomm.

                                    WHEN 'SE16'.

                                    CALL TRANSACTION 'SE16'.

                                    WHEN 'SE37'.

                                    CALL TRANSACTION 'SE37'.

                                    ENDCASE.

                                    ENDFORM. "at_user_command1

                                    Add comment
                                    10|10000 characters needed characters exceeded

                                  • avatar image
                                    Former Member
                                    Mar 28, 2008 at 07:09 AM

                                    Hai,

                                    u can try this out yaar

                                    this is interactive in ALV.

                                    DEFINE m_fieldcat.

                                    add 1 to ls_fieldcat-col_pos.

                                    ls_fieldcat-fieldname = &1.

                                    ls_fieldcat-ref_tabname = &2.

                                    ls_fieldcat-cfieldname = &3.

                                    ls_fieldcat-qfieldname = &4.

                                    append ls_fieldcat to lt_fieldcat.

                                    END-OF-DEFINITION.

                                    ----


                                    TYPE-POOLS: slis. " ALV Global types

                                    ----


                                    TYPES:

                                    BEGIN OF ty_vbak,

                                    vkorg TYPE vbak-vkorg, " Sales organization

                                    kunnr TYPE vbak-kunnr, " Sold-to party

                                    vbeln TYPE vbak-vbeln, " Sales document

                                    netwr TYPE vbak-netwr, " Net Value of the Sales Order

                                    waerk TYPE vbak-waerk, " Currency

                                    END OF ty_vbak,

                                    BEGIN OF ty_vbap,

                                    vbeln TYPE vbap-vbeln, " Sales document

                                    posnr TYPE vbap-posnr, " Sales document item

                                    matnr TYPE vbap-matnr, " Material number

                                    arktx TYPE vbap-arktx, " Short text for sales order item

                                    kwmeng TYPE vbap-kwmeng, " Order quantity

                                    vrkme TYPE vbap-vrkme, " Quantity Unit

                                    netwr TYPE vbap-netwr, " Net value of the order item

                                    waerk TYPE vbap-waerk, " Currency

                                    END OF ty_vbap.

                                    ----


                                    DATA :

                                    gs_vbak TYPE ty_vbak,

                                    • Data displayed in the first list

                                    gt_vbak TYPE TABLE OF ty_vbak,

                                    • Data displayed in the second list

                                    gt_vbap TYPE TABLE OF ty_vbap.

                                    ----


                                    SELECT-OPTIONS :

                                    s_vkorg FOR gs_vbak-vkorg, " Sales organization

                                    s_kunnr FOR gs_vbak-kunnr, " Sold-to party

                                    s_vbeln FOR gs_vbak-vbeln. " Sales document

                                    SELECTION-SCREEN :

                                    SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED

                                    PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.

                                    SELECTION-SCREEN END OF LINE.

                                    ----


                                    INITIALIZATION.

                                    v_1 = 'Maximum of records to read'.

                                    ----


                                    START-OF-SELECTION.

                                    PERFORM f_read_data_vbak.

                                    PERFORM f_display_data_vbak.

                                    ----


                                    • Form f_read_data_vbak

                                    ----


                                    FORM f_read_data_vbak.

                                    SELECT vkorg kunnr vbeln netwr waerk

                                    INTO CORRESPONDING FIELDS OF TABLE gt_vbak

                                    UP TO p_max ROWS

                                    FROM vbak

                                    WHERE kunnr IN s_kunnr

                                    AND vbeln IN s_vbeln

                                    AND vkorg IN s_vkorg

                                    and vbtyp = 'C'. " C = Sales Orders.

                                    ENDFORM. " F_READ_DATA_VBAK

                                    ----


                                    • Form f_display_data_vbak

                                    ----


                                    FORM f_display_data_vbak.

                                    DATA:

                                    ls_fieldcat TYPE slis_fieldcat_alv,

                                    lt_fieldcat TYPE slis_t_fieldcat_alv.

                                    • Build the field catalog

                                    m_fieldcat 'VKORG' 'VBAK' '' ''.

                                    m_fieldcat 'KUNNR' 'VBAK' '' ''.

                                    m_fieldcat 'VBELN' 'VBAK' '' ''.

                                    m_fieldcat 'NETWR' 'VBAK' 'WAERK' ''.

                                    m_fieldcat 'WAERK' 'VBAK' '' ''.

                                    • Display the first list

                                    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

                                    EXPORTING

                                    i_callback_program = sy-cprog

                                    i_callback_user_command = 'USER_COMMAND'

                                    it_fieldcat = lt_fieldcat

                                    TABLES

                                    t_outtab = gt_vbak.

                                    ENDFORM. " F_DISPLAY_DATA_VBAK

                                    ----


                                    • FORM USER_COMMAND *

                                    ----


                                    FORM user_command USING u_ucomm TYPE syucomm

                                    us_selfield TYPE slis_selfield. "#EC CALLED

                                    CASE u_ucomm.

                                    WHEN '&IC1'.

                                    READ TABLE gt_vbak INDEX us_selfield-tabindex INTO gs_vbak.

                                    CHECK sy-subrc EQ 0.

                                    PERFORM f_read_data_vbap. " Read data from VBAP

                                    PERFORM f_display_data_vbap.

                                    ENDCASE.

                                    ENDFORM. " USER_COMMAND

                                    ----


                                    • Form f_read_data_vbap

                                    ----


                                    FORM f_read_data_vbap.

                                    SELECT vbeln posnr matnr arktx kwmeng vrkme netwr waerk

                                    INTO CORRESPONDING FIELDS OF TABLE gt_vbap

                                    FROM vbap

                                    WHERE vbeln = gs_vbak-vbeln.

                                    ENDFORM. " F_READ_DATA_VBAP

                                    ----


                                    • Form f_display_data_vbap

                                    ----


                                    FORM f_display_data_vbap.

                                    DATA:

                                    ls_fieldcat TYPE slis_fieldcat_alv,

                                    lt_fieldcat TYPE slis_t_fieldcat_alv.

                                    • Build the field catalog

                                    m_fieldcat 'VBELN' 'VBAP' '' ''.

                                    m_fieldcat 'POSNR' 'VBAP' '' ''.

                                    m_fieldcat 'MATNR' 'VBAP' '' ''.

                                    m_fieldcat 'ARKTX' 'VBAP' '' ''.

                                    m_fieldcat 'KWMENG' 'VBAP' '' 'VRKME'.

                                    m_fieldcat 'VRKME' 'VBAP' '' ''.

                                    m_fieldcat 'NETWR' 'VBAP' 'WAERK' ''.

                                    m_fieldcat 'WAERK' 'VBAP' '' ''.

                                    • Display the second list

                                    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

                                    EXPORTING

                                    it_fieldcat = lt_fieldcat

                                    TABLES

                                    t_outtab = gt_vbap.

                                    reward if helpful

                                    raam.

                                    Add comment
                                    10|10000 characters needed characters exceeded

                                  • avatar image
                                    Former Member
                                    Mar 28, 2008 at 08:09 AM

                                    Hi

                                    this is the code.

                                    type-pools : slis.

                                    &----


                                    *& structure declaration

                                    &----


                                    types : begin of st_ekko,

                                    ebeln type ekko-ebeln, "Purchasing Document Number

                                    bstyp type ekko-bstyp, "Purchasing Document Category

                                    bsart type ekko-bsart, "Purchasing Document Type

                                    aedat type ekko-aedat, "record created on

                                    ernam type ekko-ernam, "Person who Created the Object

                                    end of st_ekko.

                                    types : begin of st_ekpo,

                                    ebeln type ekko-ebeln,

                                    ebelp type ekpo-ebelp, "Item Number of Purchasing Document

                                    ematn type ekpo-ematn, "Material number

                                    matkl type ekpo-matkl, "Material group

                                    netpr type ekpo-netpr, "Net price in purchasing document

                                    end of st_ekpo.

                                    &----


                                    *& internal table and work area declaration

                                    &----


                                    data : it_ekpo type standard table of st_ekpo,

                                    wa_ekpo type st_ekpo,

                                    it_ekko type standard table of st_ekko,

                                    wa_ekko type st_ekko,

                                    it_fieldcat type slis_t_fieldcat_alv,

                                    wa_fieldcat type slis_fieldcat_alv,

                                    wa_layout type slis_layout_alv.

                                    &----


                                    *& internal table and work area declaration

                                    &----


                                    data : v_ebeln type ekko-ebeln.

                                    data: t_header type slis_t_listheader,

                                    wa_header type slis_listheader,

                                    t_line type slis_listheader-info,

                                    nl_lines type i,

                                    nl_linesc(10) type c.

                                    &----


                                    *& start-of-selection

                                    &----


                                    start-of-selection.

                                    selection-screen begin of block a with frame title text-000.

                                    select-options : so_ebeln for v_ebeln.

                                    selection-screen end of block a.

                                    perform data_retrieval.

                                    perform build_fieldcatalog1.

                                    perform build_layout.

                                    perform ekkogriddisplay_alv.

                                    &----


                                    *& Form build_fieldcatalog2

                                    &----


                                    form build_fieldcatalog2.

                                    clear wa_fieldcat.

                                    refresh it_fieldcat.

                                    wa_fieldcat-fieldname = 'EBELN'.

                                    wa_fieldcat-seltext_l = 'PURCHASE ORDER'.

                                    wa_fieldcat-col_pos = 0.

                                    append wa_fieldcat to it_fieldcat.

                                    wa_fieldcat-fieldname = 'EBELP'.

                                    wa_fieldcat-seltext_l = 'ITEM NUMBER'.

                                    wa_fieldcat-col_pos = 1.

                                    append wa_fieldcat to it_fieldcat.

                                    wa_fieldcat-fieldname = 'EMATN'.

                                    wa_fieldcat-seltext_l = 'MATERIAL TYPE'.

                                    wa_fieldcat-col_pos = 2.

                                    append wa_fieldcat to it_fieldcat.

                                    wa_fieldcat-fieldname = 'MATKL'.

                                    wa_fieldcat-seltext_l = 'MATERIAL GROUP'.

                                    wa_fieldcat-col_pos = 3.

                                    append wa_fieldcat to it_fieldcat.

                                    wa_fieldcat-fieldname = 'NETPR'.

                                    wa_fieldcat-seltext_l = 'NET PRICE'.

                                    wa_fieldcat-col_pos = 4.

                                    wa_fieldcat-do_sum = 'X'.

                                    append wa_fieldcat to it_fieldcat.

                                    endform. "build_fieldcatalog

                                    &----


                                    *& Form build_fieldcatalog1

                                    &----


                                    form build_fieldcatalog1.

                                    wa_fieldcat-fieldname = 'EBELN'.

                                    wa_fieldcat-seltext_l = 'PURCHASE ORDER'.

                                    wa_fieldcat-col_pos = 0.

                                    append wa_fieldcat to it_fieldcat.

                                    wa_fieldcat-fieldname = 'BSTYP'.

                                    wa_fieldcat-seltext_l = 'DOCUMENT CATEGORY'.

                                    wa_fieldcat-col_pos = 1.

                                    append wa_fieldcat to it_fieldcat.

                                    wa_fieldcat-fieldname = 'BSART'.

                                    wa_fieldcat-seltext_l = 'DOCUMENT TYPE'.

                                    wa_fieldcat-col_pos = 2.

                                    append wa_fieldcat to it_fieldcat.

                                    wa_fieldcat-fieldname = 'AEDAT'.

                                    wa_fieldcat-seltext_l = 'DATE'.

                                    wa_fieldcat-col_pos = 3.

                                    append wa_fieldcat to it_fieldcat.

                                    wa_fieldcat-fieldname = 'ERNAME'.

                                    wa_fieldcat-seltext_l = 'NAME'.

                                    wa_fieldcat-col_pos = 4.

                                    append wa_fieldcat to it_fieldcat.

                                    endform. "build_fieldcatalog

                                    &----


                                    *& Form data_retrieval

                                    &----


                                    form data_retrieval.

                                    select ebeln bstyp bsart aedat ernam

                                    from ekko

                                    into table it_ekko

                                    where ebeln in so_ebeln.

                                    endform. "data_retrieval

                                    &----


                                    *& form build_layout.

                                    &----


                                    form build_layout.

                                    wa_layout-zebra ='X'.

                                    wa_layout-no_vline = 'X'.

                                    wa_layout-no_hline = 'X'.

                                    wa_layout-colwidth_optimize = 'X'.

                                    endform. "build_layout

                                    &----


                                    *& form top-of-page1

                                    &----


                                    form top-of-page1.

                                    • Title

                                    wa_header-typ = 'H'.

                                    wa_header-info = 'PURCHASE ORDER HEADER REPORT'.

                                    append wa_header to t_header.

                                    clear wa_header.

                                    • Total No. of Records Selected

                                    describe table it_ekko lines nl_lines.

                                    nl_linesc = nl_lines.

                                    concatenate 'Total No. of Records Selected: ' nl_linesc

                                    into t_line separated by space.

                                    wa_header-typ = 'A'.

                                    wa_header-info = t_line.

                                    append wa_header to t_header.

                                    clear: wa_header, t_line.

                                    call function 'REUSE_ALV_COMMENTARY_WRITE'

                                    exporting

                                    it_list_commentary = t_header

                                    i_logo = 'SUN_TEST_LOGO1'.

                                    refresh t_header.

                                    endform. "top-of-page

                                    &----


                                    *& form top-of-page2

                                    &----


                                    form top-of-page2.

                                    • Title

                                    wa_header-typ = 'H'.

                                    wa_header-info = 'PURCHASE ORDER ITEM REPORT'.

                                    append wa_header to t_header.

                                    clear wa_header.

                                    • Total No. of Records Selected

                                    describe table it_ekpo lines nl_lines.

                                    nl_linesc = nl_lines.

                                    concatenate 'Total No. of Records Selected: ' nl_linesc

                                    into t_line separated by space.

                                    wa_header-typ = 'A'.

                                    wa_header-info = t_line.

                                    append wa_header to t_header.

                                    clear: wa_header, t_line.

                                    call function 'REUSE_ALV_COMMENTARY_WRITE'

                                    exporting

                                    it_list_commentary = t_header

                                    i_logo = 'SUN_TEST_LOGO1'.

                                    refresh t_header.

                                    endform. "top-of-page

                                    &----


                                    *& form set_pf_status

                                    &----


                                    form set_pf_status using rt_extab type slis_t_extab.

                                    set pf-status 'MYMENU'.

                                    "Copy of 'STANDARD' pf_status from fgroup SALV

                                    endform. "set_pf_status

                                    &----


                                    *& Form AT_user_command

                                    &----


                                    form at_user_command using r_ucomm like sy-ucomm

                                    rs_selfield type slis_selfield.

                                    case r_ucomm.

                                    when '&IC1'.

                                    if rs_selfield-fieldname eq 'EBELN'.

                                    read table it_ekko into wa_ekko index rs_selfield-tabindex.

                                    select ebeln ebelp ematn matkl netpr

                                    from ekpo

                                    into table it_ekpo

                                    where ebeln eq wa_ekko-ebeln.

                                    perform build_fieldcatalog2.

                                    perform ekpogriddisplay_alv.

                                    else.

                                    message text-002 type 'I'.

                                    endif.

                                    endcase.

                                    endform. "AT_user_command

                                    &----


                                    *& form ekkogriddisplay_alv.

                                    &----


                                    form ekkogriddisplay_alv.

                                    if it_ekko[] is initial.

                                    message text-001 type 'I'.

                                    else.

                                    call function 'REUSE_ALV_GRID_DISPLAY'

                                    exporting

                                    i_callback_program = sy-repid

                                    i_callback_top_of_page = 'TOP-OF-PAGE1'

                                    i_callback_pf_status_set = 'SET_PF_STATUS'

                                    i_callback_user_command = 'AT_USER_COMMAND'

                                    is_layout = wa_layout

                                    it_fieldcat = it_fieldcat

                                    tables

                                    t_outtab = it_ekko

                                    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.

                                    endif.

                                    endform. "listdisplay_alv

                                    &----


                                    *& form ekpogriddisplay_alv.

                                    &----


                                    form ekpogriddisplay_alv.

                                    if it_ekpo[] is initial.

                                    message text-003 type 'I'.

                                    else.

                                    call function 'REUSE_ALV_GRID_DISPLAY'

                                    exporting

                                    i_callback_program = sy-repid

                                    i_callback_top_of_page = 'TOP-OF-PAGE2'

                                    i_callback_pf_status_set = 'SET_PF_STATUS'

                                    is_layout = wa_layout

                                    it_fieldcat = it_fieldcat

                                    tables

                                    t_outtab = it_ekpo

                                    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.

                                    endif.

                                    endform. "ekpogriddisplay_alv

                                    Add comment
                                    10|10000 characters needed characters exceeded

                                  • avatar image
                                    Former Member
                                    Mar 28, 2008 at 08:13 AM
                                    Add comment
                                    10|10000 characters needed characters exceeded

                                  • avatar image
                                    Former Member
                                    Mar 28, 2008 at 08:35 AM

                                    Hi,

                                    This is interactive report.It displays the second level report

                                    based on the field in basic list.

                                    TYPE-POOLS SLIS.

                                    TYPES: BEGIN OF I_EKKO,

                                    EBELN LIKE EKKO-EBELN,

                                    AEDAT LIKE EKKO-AEDAT,

                                    BUKRS LIKE EKKO-BUKRS,

                                    BSART LIKE EKKO-BSART,

                                    LIFNR LIKE EKKO-LIFNR,

                                    END OF I_EKKO.

                                    DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,

                                    WA_EKKO TYPE I_EKKO.

                                    TYPES: BEGIN OF I_EKPO,

                                    EBELN LIKE EKPO-EBELN,

                                    EBELP LIKE EKPO-EBELP,

                                    MATNR LIKE EKPO-MATNR,

                                    MENGE LIKE EKPO-MENGE,

                                    MEINS LIKE EKPO-MEINS,

                                    NETPR LIKE EKPO-NETPR,

                                    END OF I_EKPO.

                                    DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,

                                    WA_EKPO TYPE I_EKPO.

                                    DATA: V_REPID TYPE SY-REPID,

                                    I_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,

                                    WA_FLDCAT TYPE SLIS_FIELDCAT_ALV,

                                    I_FLDCAT1 TYPE SLIS_T_FIELDCAT_ALV,

                                    WA_FLDCAT1 TYPE SLIS_FIELDCAT_ALV.

                                    DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST ALV REPORT',

                                    I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDARY ALV REPORT'.

                                    INITIALIZATION.

                                    V_REPID = SY-REPID.

                                    PERFORM FLDCATALOG.

                                    START-OF-SELECTION.

                                    PERFORM DATA_RETRIEVAL.

                                    PERFORM DISPLAY_ALV_REPORT.

                                    FORM FLDCATALOG.

                                    WA_FLDCAT-TABNAME = 'IT_EKKO'.

                                    WA_FLDCAT-FIELDNAME = 'EBELN'.

                                    WA_FLDCAT-SELTEXT_M = 'PO NUMBER'.

                                    APPEND WA_FLDCAT TO I_FLDCAT.

                                    CLEAR WA_FLDCAT.

                                    WA_FLDCAT-TABNAME = 'IT_EKKO'.

                                    WA_FLDCAT-FIELDNAME = 'AEDAT'.

                                    WA_FLDCAT-SELTEXT_M = 'DATE'.

                                    APPEND WA_FLDCAT TO I_FLDCAT.

                                    CLEAR WA_FLDCAT.

                                    WA_FLDCAT-TABNAME = 'IT_EKKO'.

                                    WA_FLDCAT-FIELDNAME = 'BUKRS'.

                                    WA_FLDCAT-SELTEXT_M = 'DOCUMENT TYPE'.

                                    APPEND WA_FLDCAT TO I_FLDCAT.

                                    CLEAR WA_FLDCAT.

                                    WA_FLDCAT-TABNAME = 'IT_EKKO'.

                                    WA_FLDCAT-FIELDNAME = 'LIFNR'.

                                    WA_FLDCAT-SELTEXT_M = 'VENDOR CODE'.

                                    APPEND WA_FLDCAT TO I_FLDCAT.

                                    CLEAR WA_FLDCAT.

                                    ENDFORM.

                                    FORM DATA_RETRIEVAL.

                                    SELECT EBELN AEDAT BUKRS BSART LIFNR

                                    FROM EKKO INTO TABLE IT_EKKO.

                                    ENDFORM.

                                    FORM DISPLAY_ALV_REPORT.

                                    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 = I_TITLE_EKKO

                                    • I_GRID_SETTINGS =

                                    • IS_LAYOUT =

                                    IT_FIELDCAT = I_FLDCAT[]

                                    • IT_EXCLUDING =

                                    • IT_SPECIAL_GROUPS =

                                    • IT_SORT =

                                    • IT_FILTER =

                                    • IS_SEL_HIDE =

                                    • I_DEFAULT = 'X'

                                    I_SAVE = 'A'

                                    • IS_VARIANT =

                                    • IT_EVENTS = I_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_EKKO

                                    • 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.

                                    FORM USER_COMMAND USING R_COMM TYPE SY-UCOMM

                                    RS_SELFIELD TYPE SLIS_SELFIELD.

                                    CASE R_COMM.

                                    WHEN '&IC1'.

                                    IF RS_SELFIELD-FIELDNAME = 'EBELN'.

                                    SET PARAMETER ID 'BES' FIELD WA_EKKO-EBELN. " BES is data element of EBELN

                                    READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.

                                    PERFORM FLDCAT_EKPO.

                                    PERFORM DATA_RETRIEVAL_EKPO.

                                    PERFORM DISPLAY_ALV_REPORT_EKPO.

                                    ENDIF.

                                    ENDCASE.

                                    ENDFORM.

                                    FORM FLDCAT_EKPO.

                                    WA_FLDCAT1-TABNAME = 'IT_EKPO'.

                                    WA_FLDCAT1-FIELDNAME = 'EBELN'.

                                    WA_FLDCAT1-SELTEXT_M = 'PO NUMBER'.

                                    APPEND WA_FLDCAT1 TO I_FLDCAT1.

                                    CLEAR WA_FLDCAT1.

                                    WA_FLDCAT1-TABNAME = 'IT_EKPO'.

                                    WA_FLDCAT1-FIELDNAME = 'EBELP'.

                                    WA_FLDCAT1-SELTEXT_M = 'LINE NO'.

                                    APPEND WA_FLDCAT1 TO I_FLDCAT1.

                                    CLEAR WA_FLDCAT1.

                                    WA_FLDCAT1-TABNAME = 'IT_EKPO'.

                                    WA_FLDCAT1-FIELDNAME = 'MATNR'.

                                    WA_FLDCAT1-SELTEXT_M = 'MATERIAL NUMBER'.

                                    APPEND WA_FLDCAT1 TO I_FLDCAT1.

                                    CLEAR WA_FLDCAT1.

                                    WA_FLDCAT1-TABNAME = 'IT_EKPO'.

                                    WA_FLDCAT1-FIELDNAME = 'MENGE'.

                                    WA_FLDCAT1-SELTEXT_M = 'QUANTITY'.

                                    APPEND WA_FLDCAT1 TO I_FLDCAT1.

                                    CLEAR WA_FLDCAT1.

                                    WA_FLDCAT1-TABNAME = 'IT_EKPO'.

                                    WA_FLDCAT1-FIELDNAME = 'MEINS'.

                                    WA_FLDCAT1-SELTEXT_M = 'BASE UNIT OF MEASURE'.

                                    APPEND WA_FLDCAT1 TO I_FLDCAT1.

                                    CLEAR WA_FLDCAT1.

                                    WA_FLDCAT1-TABNAME = 'IT_EKPO'.

                                    WA_FLDCAT1-FIELDNAME = 'NETPR'.

                                    WA_FLDCAT1-SELTEXT_M = 'PRICE'.

                                    APPEND WA_FLDCAT1 TO I_FLDCAT1.

                                    CLEAR WA_FLDCAT1.

                                    ENDFORM.

                                    FORM DATA_RETRIEVAL_EKPO.

                                    SELECT EBELN EBELP MATNR MENGE MEINS NETPR

                                    INTO TABLE IT_EKPO

                                    FROM EKPO.

                                    ENDFORM.

                                    FORM DISPLAY_ALV_REPORT_EKPO.

                                    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 = I_TITLE_EKPO

                                    • I_GRID_SETTINGS =

                                    • IS_LAYOUT =

                                    IT_FIELDCAT = I_FLDCAT1[]

                                    • IT_EXCLUDING =

                                    • IT_SPECIAL_GROUPS =

                                    • IT_SORT =

                                    • IT_FILTER =

                                    • IS_SEL_HIDE =

                                    • I_DEFAULT = 'X'

                                    I_SAVE = 'A'

                                    • IS_VARIANT =

                                    • IT_EVENTS = I_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_EKPO

                                    • 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.

                                    Reward,if it is useful.

                                    Thanks,

                                    Chandu

                                    Add comment
                                    10|10000 characters needed characters exceeded