Skip to Content
avatar image
Former Member

ALV report.

Hi all,

In alv report i want basic list 5 recors and secondary list also 5 records.

same records in basic list and secondary.how to docan any body send sample codeing this.

Regards.

Krishna

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Aug 16, 2007 at 10:03 AM

    Hi,

    To display a secondary list when you click on one of the row items in an alv grid. The secondary list should also be an alv.

    Try out this code. You will have to make a structure ZSTR same as the output internal table.

    REPORT ZTEST_REP1 . 
    
    TABLES : MARA, 
             BHDGD, 
             zstr. 
    
    TYPES:     BEGIN OF T_MARA, 
                  MATNR LIKE MARA-MATNR, 
                  ERNAM LIKE MARA-ERNAM, 
               END OF T_MARA. 
      
    
    CLASS LCL_EVENT_RECEIVER DEFINITION DEFERRED. 
    *Constants for ALV Implementation 
    CONSTANTS:  C_SET                        VALUE 'X', 
                C_RESET                      VALUE '0', 
                C_SAVE                       VALUE 'A', 
                C_EXIT(4)                    VALUE 'EXIT', 
                C_BACK(4)                    VALUE 'BACK', 
                C_CANC(4)                    VALUE 'CANC', 
                C_PGTOP(5)                   VALUE 'PGTOP', 
                C_PGUP(4)                    VALUE 'PGUP', 
                C_PGDN(4)                    VALUE 'PGDN', 
                C_PGEND(5)                   VALUE 'PGEND'. 
      
      
    
    DATA : I_MARA TYPE STANDARD TABLE OF T_MARA WITH HEADER LINE, 
    
    *      Internal table for fields catalouge 
           I_FIELDCAT TYPE LVC_T_FCAT WITH HEADER LINE, 
    *       i_fieldcat2 type lvc_t_fcat with header line, 
    
    *      Internal table for cursor position 
           I_GT_SELROWS TYPE LVC_T_ROW . 
    
    DATA : WA_MARA LIKE I_MARA, 
           WA_GRIDROW LIKE LVC_S_ROW, 
           WA_GRIDCOL LIKE LVC_S_COL. 
    
    *Data for ALV Implementation. 
    DATA:  OK_CODE       LIKE SY-UCOMM, 
           W_OK_CODE     LIKE SY-UCOMM, 
           W_CALL        TYPE I VALUE 1, 
           W_TAB         LIKE SY-UCOMM VALUE 'TAB1', 
           W_SAVE,                                 "For Parameter I_SAVE 
           W_VARIANT     TYPE DISVARIANT,          "For parameter IS_VARIANT 
           W_GRID        TYPE REF TO CL_GUI_ALV_GRID, 
    *       w_grid1       type ref to cl_gui_alv_grid, 
           W_CONTAINER  TYPE REF TO CL_GUI_CUSTOM_CONTAINER, 
    
    *       w_container1  type ref to cl_gui_custom_container, 
    
           W_REPID       LIKE SY-REPID, 
           W_GS_PRINT    TYPE LVC_S_PRNT, 
           W_GS_LAYOUT   TYPE LVC_S_LAYO, 
           W_EVENT_REC   TYPE REF TO LCL_EVENT_RECEIVER, 
           W_CONT_MAIN   TYPE SCRFNAME VALUE 'CCCONTAINER', 
           W_LN          TYPE I,                            "line number 
           W_INDEX       LIKE SY-TABIX, 
           W_FLAG, 
           W_TEMP_VAL    TYPE I. 
    
    *---------------------------------------------------------------------* 
    * Definition: 
    *---------------------------------------------------------------------* 
    CLASS LCL_EVENT_RECEIVER DEFINITION. 
    
      PUBLIC SECTION. 
        METHODS: 
        HANDLE_TOP_OF_PAGE 
            FOR EVENT PRINT_TOP_OF_PAGE OF CL_GUI_ALV_GRID, 
        HANDLE_DOUBLE_CLICK 
            FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID 
                    IMPORTING E_ROW E_COLUMN. 
    ENDCLASS. 
      
    
    *---------------------------------------------------------------------* 
    * CLASS LCL_EVENT_RECEIVER IMPLEMENTATION 
    *---------------------------------------------------------------------* 
    CLASS LCL_EVENT_RECEIVER IMPLEMENTATION. 
      METHOD HANDLE_TOP_OF_PAGE. 
        PERFORM F_GET_HEADER. 
      ENDMETHOD.                           "handle_top_of_page 
    
      METHOD HANDLE_DOUBLE_CLICK. 
    
    *   The event DOUBLE_CLICK provides parameters for row and column 
    *   of the click. We use row parameter to select a line of the 
    *   corresponding internal table. 
    
    *   read selected row from internal table 
          READ TABLE I_MARA INDEX E_ROW-INDEX INTO WA_MARA. 
          IF SY-SUBRC <> 0. 
    *        message i001. " Cursor position not correct. 
          ELSE. 
    *       call dialog screen and display the details 
            call screen 200 starting at 10 5. 
          ENDIF. 
      
      
    
      ENDMETHOD.                           "handle_double_click 
    
    ENDCLASS. 
    
    *----------------------------------------------------------------------- 
    * start-of-selection. 
    *----------------------------------------------------------------------- 
    START-OF-SELECTION. 
    
    SELECT MATNR ERNAM FROM MARA INTO TABLE I_MARA. 
    
    *---------------------------------------------------------------------- 
    * End-of-Selection. 
    *---------------------------------------------------------------------- 
    END-OF-SELECTION. 
    
    * Start of ALV part. 
      W_REPID = SY-REPID. 
      W_VARIANT-REPORT = W_REPID. 
      W_SAVE = C_SAVE. 
      W_CONT_MAIN = W_CONT_MAIN. 
      W_GS_LAYOUT = W_GS_LAYOUT. 
      W_GS_PRINT  = W_GS_PRINT. 
      I_FIELDCAT  = I_FIELDCAT. 
      CALL SCREEN 100. 
    
    *&---------------------------------------------------------------------* 
    *&      Form  f_get_header 
    *&---------------------------------------------------------------------* 
    *       text 
    *----------------------------------------------------------------------* 
    *  -->  p1        text 
    *  <--  p2        text 
    *----------------------------------------------------------------------* 
    FORM F_GET_HEADER. 
    
      DATA: L_LINE1 LIKE BHDGD-LINE1, 
            L_LINE2 LIKE BHDGD-LINE2. 
      CONSTANTS LC_SPACE VALUE ' '. 
      DATA: L_F1(7), L_F2(11), L_F3(9), L_F4(6), L_F5(11), L_F6(4), L_F7(8), 
            L_F8(4),L_F9(10), L_F11(11), L_F12(24), L_F13(4), 
            L_F14(3). 
    
    * take the values of line1 and line2 into two new variables, otherwise 
    * after coming back to the first screen from the print preview, the 
    * header shows the condensed lines 
    
      L_LINE1 = BHDGD-LINE1. 
      L_LINE2 = BHDGD-LINE2. 
    
      CONDENSE L_LINE1. 
      CONDENSE L_LINE2. 
    
    *split the lines to display the whole lines within the 
    *stipulated report-width 
     SPLIT L_LINE1 AT LC_SPACE INTO L_F1 L_F2 L_F3 L_F4 L_F5 L_F6 L_F7 L_F8 
                                        L_F9 . 
    
      SPLIT L_LINE2 AT LC_SPACE INTO L_F11 L_F12 L_F13 L_F14. 
      L_F14 = SY-PAGNO. 
        WRITE:/1 L_F1, 9 L_F2, 40 L_F3, 50 L_F4, 57 L_F5, 88 L_F6, 93 L_F7 , 
               103 L_F8 , 108 L_F9 . 
        WRITE:/1 L_F11, 40 TEXT-012, 78 L_F12, 103 L_F13, 108 L_F14. 
      
    
    ENDFORM.                    " f_get_header 
    *&---------------------------------------------------------------------* 
    *&      Module  STATUS_0100  OUTPUT 
    *&---------------------------------------------------------------------* 
    *       text 
    *----------------------------------------------------------------------* 
    MODULE STATUS_0100 OUTPUT. 
      SET PF-STATUS 'STAT'. 
      SET TITLEBAR 'TITL'. 
    
    ENDMODULE.                 " STATUS_0100  OUTPUT 
    *&---------------------------------------------------------------------* 
    *&      Module  USER_COMMAND_0100  INPUT 
    *&---------------------------------------------------------------------* 
    *       text 
    *----------------------------------------------------------------------* 
    MODULE USER_COMMAND_0100 INPUT. 
      CASE SY-UCOMM . 
        WHEN C_EXIT OR C_BACK OR C_CANC. 
          IF NOT W_CONTAINER  IS INITIAL. 
            CALL METHOD W_CONTAINER->FREE. 
          ENDIF. 
    
          LEAVE TO SCREEN 0. 
    
        WHEN C_PGTOP. 
          WA_GRIDROW-INDEX = 1. 
    
        WHEN C_PGUP. 
          IF WA_GRIDROW-INDEX <= 15. 
            WA_GRIDROW-INDEX = 1. 
          ELSE. 
            WA_GRIDROW-INDEX = WA_GRIDROW-INDEX - 15. 
          ENDIF. 
    
        WHEN C_PGDN. 
          PERFORM F_GET_NO_ROWS. 
          W_TEMP_VAL = W_LN - WA_GRIDROW-INDEX. 
          IF W_TEMP_VAL < 15. 
            WA_GRIDROW-INDEX = W_LN. 
          ELSE. 
            WA_GRIDROW-INDEX = WA_GRIDROW-INDEX + 15. 
          ENDIF. 
    
        WHEN C_PGEND. 
          PERFORM F_GET_NO_ROWS. 
          WA_GRIDROW-INDEX = W_LN. 
    
      ENDCASE. 
      
    
    ENDMODULE.                 " USER_COMMAND_0100  INPUT 
    *&---------------------------------------------------------------------* 
    *&      Form  f_get_no_rows 
    *&---------------------------------------------------------------------* 
    *       text 
    *----------------------------------------------------------------------* 
    *  -->  p1        text 
    *  <--  p2        text 
    *----------------------------------------------------------------------* 
    FORM F_GET_NO_ROWS. 
    
        DESCRIBE TABLE I_MARA  LINES W_LN. 
    
    ENDFORM.                    " f_get_no_rows 
    *&---------------------------------------------------------------------* 
    *&      Module  DISPLAY_0100  OUTPUT 
    *&---------------------------------------------------------------------* 
    *       text 
    *----------------------------------------------------------------------* 
    MODULE DISPLAY_0100 OUTPUT. 
    
      IF NOT WA_GRIDROW IS INITIAL 
      AND NOT WA_GRIDCOL IS INITIAL. 
    
        CALL METHOD W_GRID->SET_SCROLL_INFO_VIA_ID 
          EXPORTING 
            IS_ROW_INFO = WA_GRIDROW 
            IS_COL_INFO = WA_GRIDCOL . 
    
        CALL METHOD W_GRID->SET_CURRENT_CELL_VIA_ID 
          EXPORTING 
            IS_ROW_ID = WA_GRIDROW 
            IS_COLUMN_ID = WA_GRIDCOL . 
    
      ENDIF. 
    
      CALL METHOD W_GRID->GET_SCROLL_INFO_VIA_ID 
      IMPORTING 
        ES_ROW_INFO = WA_GRIDROW 
        ES_COL_INFO = WA_GRIDCOL . 
    
      CALL METHOD W_GRID->GET_SELECTED_ROWS 
        IMPORTING 
          ET_INDEX_ROWS = I_GT_SELROWS[]. 
    
    * Build the fieldcat according to structure 
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' 
           EXPORTING 
                I_STRUCTURE_NAME = 'ZSTR' 
           CHANGING 
                CT_FIELDCAT      = I_FIELDCAT[]. 
    
      LOOP AT I_FIELDCAT. 
        W_INDEX = SY-TABIX. 
        CASE I_FIELDCAT-FIELDNAME. 
    
          WHEN 'MATNR'. 
            I_FIELDCAT-SCRTEXT_S = 'MATNR'. 
            I_FIELDCAT-KEY       = ' '. 
            I_FIELDCAT-COL_POS   = '1'. 
    
          WHEN 'ERNAM'. 
            I_FIELDCAT-SCRTEXT_S = 'ERDAT'. 
            I_FIELDCAT-OUTPUTLEN = '18'. 
            I_FIELDCAT-COL_POS   = '2'. 
      
      
    
        ENDCASE. 
        MODIFY I_FIELDCAT INDEX W_INDEX. 
    
      ENDLOOP. 
    
      READ TABLE I_FIELDCAT INDEX 1 . 
    
      IF W_CALL = 1. 
    
        PERFORM F_STD_HEADER. 
    
        CALL METHOD W_GRID->SET_TABLE_FOR_FIRST_DISPLAY 
                          EXPORTING 
                            IS_VARIANT                    = W_VARIANT 
                            I_SAVE                        = W_SAVE 
                          CHANGING 
                            IT_OUTTAB                     = I_MARA[] 
                            IT_FIELDCATALOG               = I_FIELDCAT[] 
                         EXCEPTIONS 
                           INVALID_PARAMETER_COMBINATION = 1 
                           PROGRAM_ERROR                 = 2 
                           OTHERS                        = 3. 
    
        IF SY-SUBRC <> 0. 
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
                     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
          EXIT. 
        ENDIF. 
    
        CREATE OBJECT W_EVENT_REC. 
        SET HANDLER W_EVENT_REC->HANDLE_TOP_OF_PAGE FOR W_GRID. 
        CREATE OBJECT W_EVENT_REC. 
        SET HANDLER W_EVENT_REC->HANDLE_DOUBLE_CLICK FOR W_GRID. 
        W_FLAG = C_RESET. 
      
    
        CALL METHOD CL_GUI_CONTROL=>SET_FOCUS EXPORTING CONTROL = W_GRID. 
        W_CALL = 0. 
      ENDIF. 
      
    
    ENDMODULE.                 " DISPLAY_0100  OUTPUT 
    *&---------------------------------------------------------------------* 
    *&      Form  f_std_header 
    *&---------------------------------------------------------------------* 
    *       text 
    *----------------------------------------------------------------------* 
    *  -->  p1        text 
    *  <--  p2        text 
    *----------------------------------------------------------------------* 
    FORM F_STD_HEADER. 
    
    ENDFORM.                    " f_std_header 
    *&---------------------------------------------------------------------* 
    *&      Module  DYNPRONR_CHECK_500  OUTPUT 
    *&---------------------------------------------------------------------* 
    *       text 
    *----------------------------------------------------------------------* 
    MODULE DYNPRONR_CHECK_500 OUTPUT. 
    *  if w_dynpronr is initial. 
    *    w_dynpronr = '0100'. 
    *  endif. 
    
      ENDMODULE.                 " DYNPRONR_CHECK_500  OUTPUT 
    *&---------------------------------------------------------------------* 
    *&      Module  create_objects_0100  OUTPUT 
    *&---------------------------------------------------------------------* 
    *       text 
    *----------------------------------------------------------------------* 
    MODULE create_objects_0100 OUTPUT. 
      check w_container is initial . 
      create object w_container 
        exporting 
           container_name = 'CC'. 
      create object w_grid 
        exporting 
           i_parent = w_container. 
      w_flag = c_set. 
      w_flag = w_flag. 
    ENDMODULE.                 " create_objects_0100  OUTPUT 
    *&---------------------------------------------------------------------* 
    *&      Module  STATUS_0200  OUTPUT 
    *&---------------------------------------------------------------------* 
    *       text 
    *----------------------------------------------------------------------* 
    MODULE STATUS_0200 OUTPUT. 
      SET PF-STATUS 'ST20'. 
      SET TITLEBAR '200'. 
      zstr-matnr    = wa_mara-matnr. 
      zstr-ernam    = wa_mara-ernam. 
    
    ENDMODULE.                 " STATUS_0200  OUTPUT 
    *&---------------------------------------------------------------------* 
    *&      Module  USER_COMMAND_0200  INPUT 
    *&---------------------------------------------------------------------* 
    *       text 
    *----------------------------------------------------------------------* 
    MODULE USER_COMMAND_0200 INPUT. 
      move ok_code to w_ok_code. 
      clear ok_code. 
      case w_ok_code. 
        when c_back or c_exit or c_canc. 
          leave to screen 0. 
      endcase. 
      clear w_ok_code. 
    ENDMODULE.                 " USER_COMMAND_0200  INPUT 
    
    *-- End of Program

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 16, 2007 at 10:05 AM

    Hi

    check this one

    &----


    *& Report ZALV_FIELD_GRID1

    *&

    &----


    *&

    *&

    &----


    REPORT ZALV_FIELD_GRID1

    NO STANDARD PAGE HEADING.

    TABLES MARA.

    type-pools :slis.

    TYPES : BEGIN OF TMARA ,

    MATNR LIKE MARA-MATNR,

    MEINS LIKE MARA-MEINS,

    ERSDA LIKE MARA-ERSDA,

    color(4) type c,

    SEL type c,

    LIGHT TYPE C,

    END OF TMARA.

    TYPES: BEGIN OF TMAKT,

    MATNR LIKE MAKT-MATNR,

    MAKTX LIKE MAKT-MAKTX,

    MAKTG LIKE MAKT-MAKTG,

    SEL TYPE C,

    COLOR(4),

    END OF TMAKT.

    DATA: ITAB TYPE TMARA OCCURS 0 WITH HEADER LINE,

    ITAB1 TYPE TMAKT OCCURS 0 WITH HEADER LINE,

    wa_fieldcat type slis_fieldcat_alv,

    fieldcat type slis_fieldcat_alv occurs 0,

    i_layout type slis_layout_alv,

    WA_LISTHEADER TYPE SLIS_LISTHEADER,

    i_LISTHEADER TYPE SLIS_LISTHEADER OCCURS 0,

    V_EVENTS TYPE SLIS_T_EVENT ,

    WA_EVENT TYPE SLIS_ALV_EVENT,

    I_TITLE_MARA TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED',

    I_TITLE_MAKT TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED',

    SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE,

    PRINT_CONT type slis_print_alv.

    *----


    • SELECTION SCREE

    *----


    selection-screen begin of block screen1 with frame title TEXT-001.

    SELECTION-SCREEN SKIP.

    SELECTION-SCREEN COMMENT /32(35) COMM1.

    SELECTION-SCREEN ULINE /27(35).

    SELECTION-SCREEN SKIP.

    SELECT-OPTIONS MATNR FOR MARA-MATNR.

    SELECTION-SCREEN SKIP.

    SELECTION-SCREEN ULINE.

    SELECTION-SCREEN COMMENT /30(50) COMM2.

    SELECTION-SCREEN ULINE /27(40).

    SELECTION-SCREEN SKIP.

    SELECT-OPTIONS ERSDA FOR MARA-ERSDA.

    SELECTION-SCREEN SKIP.

    selection-screen end of block screen1.

    *----


    • INITIALIZATION

    *----


    INITIALIZATION.

    MATNR-low = '23'.

    MATNR-high = '1000'.

    MATNR-option = 'BT'.

    MATNR-sign = 'I'.

    APPEND MATNR.

    ERSDA-low = '20030124'.

    ERSDA-high = '20050302' .

    APPEND ERSDA.

    PERFORM FILLFIELD.

    PERFORM FILLLAYOUT.

    PERFORM build_print_params.

    PERFORM FILL_SORT.

    PERFORM EVENT_CALL.

    PERFORM POPULATE_EVENT.

    *----


    • SELECTION-SCREEN OUTPUT

    *----


    AT SELECTION-SCREEN OUTPUT.

    comm1 ='SELECT MATERIAL NUMBER RANGE'.

    comm2 ='SELECT MATERIAL CREATION DATE'.

    *----


    • START-OF-SELECTION

    *----


    START-OF-SELECTION.

    PERFORM READDATA.

    PERFORM POPDATA.

    &----


    *& Form READDATA

    &----


    • text

    ----


    FORM READDATA .

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    INPUT = MATNR-LOW

    IMPORTING

    OUTPUT = MATNR-LOW.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    INPUT = MATNR-HIGH

    IMPORTING

    OUTPUT = MATNR-HIGH.

    SELECT MATNR

    ERSDA

    MEINS

    FROM MARA

    INTO CORRESPONDING FIELDS OF

    TABLE ITAB

    WHERE MATNR IN MATNR AND ERSDA IN ERSDA.

    LOOP AT ITAB.

    data id_color type i VALUE 1.

    data id_colors(2) type c.

    IF ITAB-MATNR < '000000000000000100'.

    ITAB-LIGHT = '1'.

    ELSEIF ITAB-MATNR < '000000000000000150' AND ITAB-MATNR >

    '000000000000000100' .

    ITAB-LIGHT = '2'.

    ELSE.

    ITAB-LIGHT = '3'.

    ENDIF.

    id_color = id_color + 1.

    if id_color > 7.

    id_color = 1.

    endif.

    id_colors = id_color.

    concatenate 'C' id_colors '10' into itab-color.

    modify itab.

    CLEAR ITAB.

    endloop.

    ENDFORM. " READDATA

    ----


    • Form FILLFIELD

    ----


    FORM FILLFIELD .

    WA_FIELDCAT-FIELDNAME = 'MATNR'.

    WA_FIELDCAT-KEY = 'X'.

    WA_FIELDCAT-COL_POS = '1'.

    WA_FIELDCAT-outputlen = 20.

    WA_FIELDCAT-HOTSPOT = 'X'.

    wa_fieldcat-seltext_m = 'MATERIAL NUMBER'.

    *WA_FIELDCAT-EMPHASIZE = 'C210'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'MEINS'.

    WA_FIELDCAT-COL_POS = '2'.

    *WA_FIELDCAT-EMPHASIZE = 'C510'.

    WA_FIELDCAT-outputlen = 10.

    wa_fieldcat-seltext_m = 'UNIT'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'ERSDA'.

    WA_FIELDCAT-COL_POS = '3'.

    WA_FIELDCAT-outputlen = 15.

    *WA_FIELDCAT-EDIT_MASK = 'DD.MM.YYYY'.

    *WA_FIELDCAT-EMPHASIZE = 'C710'.

    wa_fieldcat-seltext_m = 'CREAT DATE'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    ENDFORM. "FILLFIELD

    &----


    • Setup print parameters

    ----


    form build_print_params.

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

    PRINT_CONT-no_coverpage = 'X'.

    endform. " BUILD_PRINT_PARAMS

    ----


    • Form POPDATA

    ----


    FORM POPDATA .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = sy-repid

    • I_CALLBACK_PF_STATUS_SET = ' '

    I_CALLBACK_USER_COMMAND = 'USER-COMMAND'

    I_CALLBACK_TOP_OF_PAGE = 'TOPPAGE'

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    I_GRID_TITLE = I_TITLE_MARA

    • I_GRID_SETTINGS =

    IS_LAYOUT = I_LAYOUT

    IT_FIELDCAT = fieldcat

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    IT_SORT = SORT[]

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    IT_EVENTS = V_EVENTS

    • IT_EVENT_EXIT =

    IS_PRINT = PRINT_CONT

    TABLES

    T_OUTTAB = ITAB

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2

    .

    ENDFORM. " POPDATA

    ----


    • Form TOPPAGE

    ----


    FORM TOPPAGE.

    REFRESH I_LISTHEADER.

    DATA: ld_lines type i,

    ld_linesc(10) type c,

    I_DATE(10) TYPE C,

    I_INFO LIKE WA_LISTHEADER-INFO.

    WA_LISTHEADER-TYP = 'H'.

    WA_LISTHEADER-INFO = 'MATERIAL DETAIL'.

    APPEND WA_LISTHEADER TO I_LISTHEADER.

    CLEAR WA_LISTHEADER.

    WA_LISTHEADER-TYP = 'S'.

    WA_LISTHEADER-KEY = 'DATE :'.

    CONCATENATE SY-DATUM+6(2) '.'

    SY-DATUM+4(2) '.'

    SY-DATUM(4) INTO I_DATE.

    WA_LISTHEADER-INFO = I_datE.

    APPEND WA_LISTHEADER TO I_LISTHEADER.

    CLEAR WA_LISTHEADER.

    describe table ITAB lines ld_lines.

    ld_linesc = ld_lines.

    concatenate 'TOTAL NUMBER OF RECORD SELECTED: ' ld_linesc

    into I_INFO separated by space.

    WA_LISTHEADER-TYP = 'A'.

    WA_LISTHEADER-INFO = I_INFO.

    append WA_LISTHEADER to I_LISTHEADER.

    clear: WA_LISTHEADER , I_INFO.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = I_LISTHEADER

    I_LOGO = 'ENJOYSAP_LOGO'.

    ENDFORM. "TOPPAGE

    ----


    • Form FILLLAYOUT

    ----


    FORM FILLLAYOUT .

    i_layout-zebra = 'X'.

    i_layout-info_fieldname = 'COLOR'.

    i_layout-box_fieldname = 'SEL'.

    I_LAYOUT-lights_fieldname = 'LIGHT'.

    I_LAYOUT-EDIT ='X'.

    I_LAYOUT-colwidth_optimize = 'X'.

    I_LAYOUT-window_titlebar = 'EXAMPLE FOR ALV GRID'.

    I_LAYOUT-no_totalline = 'X'.

    ENDFORM. "FILLLAYOUT

    ----


    • Form FILL_SORT

    ----


    FORM FILL_SORT .

    SORT-DOWN = 'X'.

    SORT-SPOS = 1.

    SORT-FIELDNAME = 'MATNR'.

    SORT-tabname = 'MARA'.

    APPEND SORT.

    ENDFORM. " FILL_SORT

    ----


    • Form EVENT_CALL

    ----


    FORM EVENT_CALL .

    DATA: I_EVENT LIKE V_EVENTS.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = V_EVENTS.

    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 POPULATE_EVENT

    ----


    FORM POPULATE_EVENT .

    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'USER_COMMAND'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-NAME.

    READ TABLE V_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE

    INTO WA_EVENT.

    IF SY-SUBRC = 0.

    move 'END_OF_PAGE' to WA_EVENT-FORM.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-NAME.

    endif.

    ENDIF.

    ENDFORM. "POPULATE_EVENT

    *----


    FORM END_OF_PAGE.

    write: sy-uline(50).

    skip.

    write:/40 'Page:', sy-pagno .

    ENDFORM.

    &----


    *& Form USER_COMMAND

    ----


    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

    RS_SELFIELD TYPE SLIS_SELFIELD.

    CASE R_UCOMM.

    WHEN '&IC1'.

    CASE RS_SELFIELD-FIELDNAME.

    when 'MATNR'.

    read table itab with key matnr = RS_SELFIELD-VALUE.

    if sy-subrc = 0.

    PERFORM DATA_RETRIEVAL_MAKT USING RS_SELFIELD-VALUE.

    PERFORM BUILD_FIELDCATLOG_MAKT.

    PERFORM FILLLAYOUT_MAKT.

    PERFORM DISPLAY_ALV_MAKT.

    CLEAR RS_SELFIELD.

    ENDIF.

    ENDCASE.

    ENDCASE.

    ENDFORM. "user_command

    ----


    • Form DATA_RETRIEVAL_MAKT

    ----


    FORM DATA_RETRIEVAL_MAKT USING TMATNR .

    SELECT MATNR

    MAKTX

    MAKTG

    UP TO 100 ROWS

    FROM MAKT

    INTO TABLE ITAB1

    WHERE SPRAS = 'EN' AND MATNR = TMATNR.

    LOOP AT ITAB1.

    data id_color type i VALUE 1.

    data id_colors(2) type c.

    id_color = id_color + 1.

    if id_color > 7.

    id_color = 1.

    endif.

    id_colors = id_color.

    concatenate 'C' id_colors '10' into itab1-color.

    modify itab1.

    CLEAR ITAB1.

    ENDLOOP.

    ENDFORM. "DATA_RETRIEVAL_MAKT

    ----


    • Form FILLLAYOUT_MAKT

    ----


    FORM FILLLAYOUT_MAKT .

    CLEAR I_LAYOUT.

    i_layout-zebra = 'X'.

    i_layout-info_fieldname = 'COLOR'.

    i_layout-box_fieldname = 'SEL'.

    I_LAYOUT-EDIT ='X'.

    I_LAYOUT-colwidth_optimize = 'X'.

    I_LAYOUT-window_titlebar = 'EXAMPLE FOR ALV GRID'.

    ENDFORM. " LAYOUT_MAKT

    ----


    • Form BUILD_FIELDCATLOG_MAKT

    ----


    FORM BUILD_FIELDCATLOG_MAKT .

    REFRESH FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'MATNR'.

    WA_FIELDCAT-KEY = 'X'.

    WA_FIELDCAT-COL_POS = '1'.

    *WA_FIELDCAT-EDIT_MASK = 'DD.MM.YYYY'.

    WA_FIELDCAT-EMPHASIZE = 'C510'.

    wa_fieldcat-seltext_m = 'MATERIAL NUMBER'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'MAKTX'.

    WA_FIELDCAT-COL_POS = '2'.

    WA_FIELDCAT-EMPHASIZE = 'C710'.

    wa_fieldcat-seltext_m = 'MATERIAL DESCRIPTION'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'MAKTG'.

    WA_FIELDCAT-COL_POS = '3'.

    WA_FIELDCAT-EMPHASIZE = 'C210'.

    wa_fieldcat-seltext_m = 'MATERIAL DESCRIPTION'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    ENDFORM. " BUILD_FIELDCATLOG_MAKT

    ----


    • Form DISPLAY_ALV_MAKT

    ----


    FORM TOP-OF-PAGE.

    REFRESH I_LISTHEADER.

    DATA: ld_lines type i,

    ld_linesc(10) type c,

    I_DATE(10) TYPE C,

    I_INFO LIKE WA_LISTHEADER-INFO.

    WA_LISTHEADER-TYP = 'H'.

    WA_LISTHEADER-INFO = 'MATERIAL DESCRIPTION FOR SELECTED NUMBER'.

    APPEND WA_LISTHEADER TO I_LISTHEADER.

    CLEAR WA_LISTHEADER.

    WA_LISTHEADER-TYP = 'S'.

    WA_LISTHEADER-KEY = 'DATE :'.

    CONCATENATE SY-DATUM+6(2) '.'

    SY-DATUM+4(2) '.'

    SY-DATUM(4) INTO I_DATE.

    WA_LISTHEADER-INFO = I_datE.

    APPEND WA_LISTHEADER TO I_LISTHEADER.

    CLEAR WA_LISTHEADER.

    describe table ITAB1 lines ld_lines.

    ld_linesc = ld_lines.

    concatenate 'TOTAL NUMBER OF RECORD SELECTED: ' ld_linesc

    into I_INFO separated by space.

    WA_LISTHEADER-TYP = 'A'.

    WA_LISTHEADER-INFO = I_INFO.

    append WA_LISTHEADER to I_LISTHEADER.

    clear: WA_LISTHEADER , I_INFO.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = I_LISTHEADER

    I_LOGO = 'ENJOYSAP_LOGO'.

    • I_END_OF_LIST_GRID =

    • I_ALV_FORM =

    ENDFORM. "TOP-OF-PAGE

    here i am placing same data that is in basi list----


    >

    &----


    *& Form DISPLAY_ALV_MAKT

    &----


    • text

    ----


    FORM DISPLAY_ALV_MAKT .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = sy-repid

    • I_CALLBACK_PF_STATUS_SET = ' '

    I_CALLBACK_USER_COMMAND = 'USER-COMMAND'

    I_CALLBACK_TOP_OF_PAGE = 'TOPPAGE'

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    I_GRID_TITLE = I_TITLE_MARA

    • I_GRID_SETTINGS =

    IS_LAYOUT = I_LAYOUT

    IT_FIELDCAT = fieldcat

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    IT_SORT = SORT[]

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    IT_EVENTS = V_EVENTS

    • IT_EVENT_EXIT =

    IS_PRINT = PRINT_CONT

    TABLES

    T_OUTTAB = ITAB

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2

    .

    ENDFORM. " DISPLAY_ALV_MAKT

    reward points to all helpful answers

    kiran.M

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 16, 2007 at 10:10 AM

    hi,

    ITABL internal taable - fetch 5 records from mara table..

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' Or grid display

    EXPORTING

    I_CALLBACK_PROGRAM = GT_REPID

    :

    I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND' " FORM NAME

    :

    :

    IT_FIELDCAT = GT_FIELDCAT

    .....................................

    TABLES

    T_OUTTAB = ITAB

    ...........................

    FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

    RS_SELFIELD TYPE SLIS_SELFIELD.

    CASE R_UCOMM.

    When '&IC1'. " here your double occurs

    if rs_selfield-fieldname = '<your field name>' " give the field name which you want to double click.

    :

    you can REUSE_ALV_GRID_DISPLAY again for second line items

    and pass the same ITAB

    :

    endif.

    endcase.

    ENDFORM.

    rewards if useful,

    regards,

    nazeer

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 16, 2007 at 10:14 AM

    Hi

    Krishna go for this and Remember one thing most of the SDN members giving answers by checking in the site and pasting here, some of the persons are giving solutions where they faced in real time(if u find solutions by the rite way then reward points )

    &----


    *& Report ZZ_22038_22098_002 *

    *& *

    &----


    *& This is an Interactive ALV report, where on line slection we can see

    *& the secondry list

    *&

    *& *

    &----


    REPORT ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650

    MESSAGE-ID ZZ_9838 .

    TYPE-POOLS: SLIS.

    *type declaration for values from ekko

    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.

    *type declaration for values from ekpo

    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 .

    *variable for Report ID

    DATA: V_REPID LIKE SY-REPID .

    *declaration for fieldcatalog

    DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

    WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.

    • declaration for events table where user comand or set PF status will

    • be defined

    DATA: V_EVENTS TYPE SLIS_T_EVENT,

    WA_EVENT TYPE SLIS_ALV_EVENT.

    • declartion for layout

    DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.

    • declaration for variant(type of display we want)

    DATA: I_VARIANT TYPE DISVARIANT,

    I_VARIANT1 TYPE DISVARIANT,

    I_SAVE(1) TYPE C.

    *PARAMETERS : p_var TYPE disvariant-variant.

    *Title displayed when the alv list is displayed

    DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.

    DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.

    INITIALIZATION.

    V_REPID = SY-REPID.

    PERFORM BUILD_FIELDCATLOG.

    PERFORM EVENT_CALL.

    PERFORM POPULATE_EVENT.

    START-OF-SELECTION.

    PERFORM DATA_RETRIEVAL.

    PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.

    PERFORM DISPLAY_ALV_REPORT.

    &----


    *& Form BUILD_FIELDCATLOG

    &----


    • Fieldcatalog has all the field details from ekko

    ----


    FORM BUILD_FIELDCATLOG.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'EBELN'.

    WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'AEDAT'.

    WA_FIELDCAT-SELTEXT_M = 'DATE.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'BUKRS'.

    WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'BUKRS'.

    WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'LIFNR'.

    WA_FIELDCAT-NO_OUT = 'X'.

    WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    ENDFORM. "BUILD_FIELDCATLOG

    &----


    *& Form EVENT_CALL

    &----


    • we get all events - TOP OF PAGE or USER COMMAND in table v_events

    ----


    FORM EVENT_CALL.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = V_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 POPULATE_EVENT

    &----


    • Events populated for TOP OF PAGE & USER COMAND

    ----


    FORM POPULATE_EVENT.

    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'TOP_OF_PAGE'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-FORM.

    ENDIF.

    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'USER_COMMAND'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-NAME.

    ENDIF.

    ENDFORM. "POPULATE_EVENT

    &----


    *& Form data_retrieval

    &----


    • retreiving values from the database table ekko

    ----


    FORM DATA_RETRIEVAL.

    SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.

    ENDFORM. "data_retrieval

    &----


    *& Form bUild_listheader

    &----


    • text

    ----


    • -->I_LISTHEADEtext

    ----


    FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

    DATA HLINE TYPE SLIS_LISTHEADER.

    HLINE-INFO = 'this is my first alv pgm'.

    HLINE-TYP = 'H'.

    ENDFORM. "build_listheader

    &----


    *& Form display_alv_report

    &----


    • text

    ----


    FORM DISPLAY_ALV_REPORT.

    V_REPID = SY-REPID.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = V_REPID

    • I_CALLBACK_PF_STATUS_SET = ' '

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

    I_GRID_TITLE = I_TITLE_EKKO

    • I_GRID_SETTINGS =

    • IS_LAYOUT = ALV_LAYOUT

    IT_FIELDCAT = I_FIELDCAT[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • i_default = 'ZLAY1'

    I_SAVE = 'A'

    • is_variant = i_variant

    IT_EVENTS = V_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. "display_alv_report

    &----


    *& Form TOP_OF_PAGE

    &----


    • text

    ----


    FORM TOP_OF_PAGE.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = IT_LISTHEADER

    • i_logo =

    • I_END_OF_LIST_GRID =

    .

    ENDFORM. "TOP_OF_PAGE

    &----


    *& Form USER_COMMAND

    &----


    • text

    ----


    • -->R_UCOMM text

    • -->, text

    • -->RS_SLEFIELDtext

    ----


    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

    RS_SELFIELD TYPE SLIS_SELFIELD.

    CASE R_UCOMM.

    WHEN '&IC1'.

    READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.

    PERFORM BUILD_FIELDCATLOG_EKPO.

    PERFORM EVENT_CALL_EKPO.

    PERFORM POPULATE_EVENT_EKPO.

    PERFORM DATA_RETRIEVAL_EKPO.

    PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.

    PERFORM DISPLAY_ALV_EKPO.

    ENDCASE.

    ENDFORM. "user_command

    &----


    *& Form BUILD_FIELDCATLOG_EKPO

    &----


    • text

    ----


    FORM BUILD_FIELDCATLOG_EKPO.

    WA_FIELDCAT-TABNAME = 'IT_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'EBELN'.

    WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'EBELP'.

    WA_FIELDCAT-SELTEXT_M = 'LINE NO'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'MATNR'.

    WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'MENGE'.

    WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'MEINS'.

    WA_FIELDCAT-SELTEXT_M = 'UOM'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'NETPR'.

    WA_FIELDCAT-SELTEXT_M = 'PRICE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    ENDFORM. "BUILD_FIELDCATLOG_EKPO

    &----


    *& Form event_call_ekpo

    &----


    • we get all events - TOP OF PAGE or USER COMMAND in table v_events

    ----


    FORM EVENT_CALL_EKPO.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = V_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_ekpo

    &----


    *& Form POPULATE_EVENT

    &----


    • Events populated for TOP OF PAGE & USER COMAND

    ----


    FORM POPULATE_EVENT_EKPO.

    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'TOP_OF_PAGE'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-FORM.

    ENDIF.

    ENDFORM. "POPULATE_EVENT

    &----


    *& Form TOP_OF_PAGE

    &----


    • text

    ----


    FORM F_TOP_OF_PAGE.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = IT_LISTHEADER

    • i_logo =

    • I_END_OF_LIST_GRID =

    .

    ENDFORM. "TOP_OF_PAGE

    &----


    *& Form USER_COMMAND

    &----


    • text

    ----


    • -->R_UCOMM text

    • -->, text

    • -->RS_SLEFIELDtext

    ----


    *retreiving values from the database table ekko

    FORM DATA_RETRIEVAL_EKPO.

    SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.

    ENDFORM.

    FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

    DATA: HLINE1 TYPE SLIS_LISTHEADER.

    HLINE1-TYP = 'H'.

    HLINE1-INFO = 'CHECKING PGM'.

    ENDFORM.

    FORM DISPLAY_ALV_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 = 'F_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 = I_TITLE_EKPO

    • I_GRID_SETTINGS =

    • IS_LAYOUT =

    IT_FIELDCAT = I_FIELDCAT[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT =

    I_SAVE = 'A'

    • IS_VARIANT =

    IT_EVENTS = V_EVENTS

    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.

    Thanks

    Naveen khan

    Add comment
    10|10000 characters needed characters exceeded