Skip to Content
author's profile photo Former Member
Former Member

alv output

Is it possible to place two grids in a single output list (in a same page) using normal alv fms?

if possible how?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 24, 2008 at 07:19 PM

    hi,

    Use the fm REUSE_ALV_BLOCK_LIST_APPEND to print multiple grids.....

    See the sample program BALVBT01 for more details.........

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 24, 2008 at 09:18 PM

    Hi Samatha,

    It is possible to display two grids in a single output .

    Refer to below program which is quite simple to understand and reply me if u have any doubts.

    REPORT ZMK_TEST.

    tables: vbak, vbap.

    type-pools: slis.

    data: begin of i_vbak occurs 0,

    vbeln type vbeln,

    kunnr type kunnr,

    date type audat,

    end of i_vbak.

    data: begin of i_vbak1 occurs 0,

    vbeln type vbeln,

    kunnr type kunnr,

    date type audat,

    end of i_vbak1.

    data: begin of i_vbap occurs 0,

    matnr type matnr,

    end of i_vbap.

    data : i_fieldcat type slis_t_fieldcat_alv,

    w_fieldcat type slis_fieldcat_alv,

    i_fieldcat1 type slis_t_fieldcat_alv,

    w_fieldcat1 type slis_fieldcat_alv,

    i_fieldcat2 type slis_t_fieldcat_alv,

    w_fieldcat2 type slis_fieldcat_alv,

    i_event type slis_t_event with header line.

    data: w_layout TYPE slis_layout_alv.

    DATA: w_PRINT TYPE SLIS_PRINT_ALV.

    selection-screen begin of block b1.

    select-options: cust for vbak-kunnr.

    selection-screen end of block b1.

    select vbeln from vbak into table i_vbak UP TO 3 ROWS. " where kunnr in cust.

    select vbeln from vbak into table i_vbak1 UP TO 5 ROWS.

    perform fieldcat.

    perform layout.

    perform fieldcat1.

    perform display.

    form display .

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

    EXPORTING

    i_callback_program = sy-repid

    I_CALLBACK_USER_COMMAND = 'CLICK'.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

    is_layout = w_layout

    it_fieldcat = i_fieldcat

    i_tabname = 'I_VBAK'

    it_events = i_event[]

    tables

    t_outtab = i_vbak[].

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

    is_layout = w_layout

    it_fieldcat = i_fieldcat1

    i_tabname = 'I_VBAK1'

    it_events = i_event[]

    tables

    t_outtab = i_vbak1[].

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

    EXPORTING

    I_INTERFACE_CHECK = ' '

    IS_PRINT = w_PRINT.

    endform. " display

    form fieldcat .

    w_fieldcat-fieldname = 'VBELN'.

    w_fieldcat-tabname = 'W_VBAK'.

    w_fieldcat-ref_fieldname = 'VBELN'.

    w_fieldcat-seltext_m = 'Doc no'.

    append w_fieldcat to i_fieldcat.

    endform. " fieldcat

    form fieldcat1.

    w_fieldcat1-fieldname = 'VBELN'.

    w_fieldcat1-tabname = 'W_VBAK1'.

    w_fieldcat1-ref_fieldname = 'VBELN'.

    w_fieldcat1-seltext_m = 'Doc no'.

    append w_fieldcat1 to i_fieldcat1.

    endform. " fieldcat

    &----


    *& Form layout

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form layout .

    w_layout-zebra = 'X'.

    w_layout-get_selinfos = 'X'.

    endform. " layout

    FORM CLICK USING V_UCOMM LIKE SY-UCOMM HIDEV TYPE slis_selfield.

    SELECT MATNR FROM VBAP INTO TABLE I_VBAP WHERE VBELN = HIDEV-value.

    perform layout.

    perform fieldcat2.

    PERFORM GRID.

    ENDFORM.

    form fieldcat2 .

    CLEAR I_FIELDCAT1[].

    w_fieldcat2-fieldname = 'MATNR'.

    w_fieldcat2-tabname = 'I_VBAP'.

    w_fieldcat2-seltext_m = 'Material No'.

    append w_fieldcat2 to i_fieldcat2.

    clear w_fieldcat2.

    endform. " fieldcat1

    form GRID .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_INTERFACE_CHECK = sy-repid

    I_CALLBACK_PROGRAM = SY-REPID

    IS_LAYOUT = w_LAYOUT

    IT_FIELDCAT = I_FIELDCAT2

    • IT_EXCLUDING =

    TABLES

    t_outtab = i_vbap[].

    endform. " GRID

    Thanks & Regards,

    AMK

    Please reply if u have any doubts,

    REWARD POINTS IF USEFUL.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2008 at 03:50 AM

    Hai.

    check the example codes.

    REPORT z_alv_list_block.

    TYPE-POOLS: slis. " ALV Global types

    SELECTION-SCREEN :

    SKIP,

    BEGIN OF LINE,

    COMMENT 5(27) v_1 FOR FIELD p_max.

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

    SELECTION-SCREEN END OF LINE.

    DATA:

    • 1st Table

    BEGIN OF gt_kna1 OCCURS 0, " Data displayed

    kunnr LIKE kna1-kunnr, " Customer number

    ernam LIKE kna1-ernam, " Name of Person who Created

    erdat LIKE kna1-erdat, " Creation date

    name1 LIKE kna1-name1, " Name 1

    END OF gt_kna1,

    • 2nd Table

    BEGIN OF gt_mara OCCURS 0,

    ernam LIKE mara-ernam, " Name of Person who Created

    matnr LIKE mara-matnr, " Material number

    ersda LIKE mara-e rsda, " Creation date

    brgew LIKE mara-brgew, " Gross weight

    END OF gt_mara,

    • 3rd Table

    BEGIN OF gt_vbak OCCURS 0,

    vkorg LIKE vbak-vkorg, " Sales organization

    kunnr LIKE vbak-kunnr, " Sold-to party

    vbeln LIKE vbak-vbeln, " Sales document

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

    waerk LIKE vbak-waerk, " SD document currency

    END OF gt_vbak.

    ----


    INITIALIZATION.

    v_1 = 'Maximum of records to read'.

    ----


    START-OF-SELECTION.

    • Read data

    SELECT * FROM kna1

    UP TO p_max ROWS

    INTO CORRESPONDING FIELDS OF TABLE gt_kna1.

    SELECT * FROM mara

    UP TO p_max ROWS

    INTO CORRESPONDING FIELDS OF TABLE gt_mara.

    SELECT * FROM vbak

    UP TO p_max ROWS

    INTO CORRESPONDING FIELDS OF TABLE gt_vbak.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

    EXPORTING

    i_callback_program = sy-cprog

    i_callback_user_command = 'USER_COMMAND'.

    PERFORM list_append TABLES gt_kna1

    USING '1'

    'GT_KNA1'.

    PERFORM list_append TABLES gt_mara

    USING '2'

    'GT_MARA'.

    PERFORM list_append TABLES gt_vbak

    USING '3'

    'GT_VBAK'.

    PERFORM f_list_display.

    ----


    • FORM USER_COMMAND *

    ----


    FORM user_command USING i_ucomm LIKE sy-ucomm

    is_selfield TYPE slis_selfield. "#EC CALLED

    CASE i_ucomm.

    WHEN '&IC1'. " Pick

    CASE is_selfield-tabname.

    WHEN 'GT_MARA'.

    WHEN 'GT_KNA1'.

    WHEN 'GT_VBAK'.

    READ TABLE gt_vbak INDEX is_selfield-tabindex.

    IF sy-subrc EQ 0.

    • Sales order number

    SET PARAMETER ID 'AUN' FIELD gt_vbak-vbeln.

    • Display Sales Order

    CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

    ENDIF.

    ENDCASE.

    ENDCASE.

    ENDFORM. " USER_COMMAND

    ----


    < /div>

    • Form list_append

    ----


    FORM list_append TABLES ut_table

    USING u_no TYPE char1

    u_tabname TYPE slis_tabname.

    • Macro definition

    DEFINE m_fieldcat.

    ls_fieldcat-fieldname = &1.

    ls_fieldcat-ref_tabname = &2.

    append ls_fieldcat to lt_fieldcat.

    END-OF-DEFINITION.

    DEFINE m_sort.

    ls_sort-fieldname = &1.

    ls_sort-up = 'X'.

    append ls_sort to lt_sort.

    END-OF-DEFINITION.

    DATA :

    ls_fieldcat TYPE slis_fieldcat_alv,

    lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog

    ls_sort TYPE slis_sortinfo_alv,

    lt_sort TYPE slis_t_sortinfo_alv. " Sort table

    DATA:

    lt_events TYPE slis_t_event,

    ls_event TYPE slis_alv_event,

    ls_layout TYPE slis_layout_alv.

    ls_layout-group_change_edit = 'X'.

    ls_layout-colwidth_optimize = 'X'.

    ls_layout-zebra = 'X'.

    ls_layout-detail_popup = 'X'.

    ls_layout-get_selinfos = 'X'.

    ls_layout-max_linesize = '200'.

    CASE u_no.

    WHEN '1'.

    • Build field catalog and sort table

    m_fieldcat 'KUNNR' 'KNA1'.

    m_fieldcat 'ERNAM' 'KNA1'.

    m_fieldcat 'ERDAT' 'KNA1'.

    m_fieldcat 'NAME1' 'KNA1'.

    m_sort 'KUNNR'.

    WHEN '2'.

    m_fieldcat 'MATNR' 'MARA'.

    m_fieldcat 'ERNAM' 'MARA'.

    m_fieldcat 'ERSDA' 'MARA'.

    m_fieldcat 'BRGEW' 'MARA'.

    m_sort 'MATNR'.

    WHEN '3'.

    m_fieldcat 'VBELN' 'VBAK'.

    m_fieldcat 'VKORG' 'VBAK'.

    m_fieldcat 'KUNNR' 'VBAK'.

    m_fieldcat 'NETWR' 'VBAK'.

    m_fieldcat 'WAERK' 'VBAK'.

    m_sort 'VBELN'.

    ENDCASE.

    IF u_no CA '13'.

    MOVE 'TOP_OF_PAGE' TO ls_event-name.

    CONCATENATE 'TOP_OF_PAGE' u_no INTO ls_event-form.

    APPEND ls_event TO lt_events.

    ELSE.

    MOVE 'TOP_OF_LIST' TO ls_event-name.

    CONCATENATE 'TOP_OF_LIST' u_no INTO ls_event-form.

    APPEND ls_event TO lt_events.

    ENDIF.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

    it_fieldcat = lt_fieldcat

    is_layout = ls_layout

    i_tabname = u_tabname

    it_events = lt_events

    it_sort = lt_sort

    • i_text =

    TABLES

    t_outtab = ut_table

    EXCEPTIONS

    program_error = 1

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

    ENDIF.

    ENDFORM. " LIST_APPEND

    ----


    • Form f_list_display

    ----


    FORM f_list_display.

    DATA ls_print TYPE slis_print_alv.

    ls_print-no_print_selinfos = 'X'. " Display no selection infos

    ls_print-no_print_listinfos = 'X'. " Display no listinfos

    ls_print-reserve_lines = 2. " Lines reserved for end of page

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

    EXPORTING

    i_interface_check = ' '

    is_print = ls_print

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

    ----


    • FORM top_of_page1 *

    ----


    FORM top_of_page1. "#EC CALLED

    PERFORM top_of_page.

    ENDFORM.

    ----


    • FORM top_of_page3 *

    ----


    FORM top_of_page3. "#EC CALLED

    PERFORM top_of_page.

    ENDFORM.

    ----


    • FORM top_of_page *

    ----


    FORM top_of_page.

    ULINE.

    WRITE : sy-uname, sy-title(56) CENTERED, sy-datum.

    ULINE.

    ENDFORM.

    ----


    • FORM top_of_list2 *

    ----


    FORM top_of_list2. "#EC CALLED

    WRITE 'TOP OF LIST2'.

    ENDFORM.

    • END OF PROGRAM Z_ALV_LIST_BLOCK ***********************

    -


    REPORT YMS_BLOCKLISTALV .

    TYPE-POOLS: slis. " ALV Global types

    SELECTION-SCREEN :

    SKIP,

    BEGIN OF LINE,

    COMMENT 5(27) v_1 FOR FIELD p_max.

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

    SELECTION-SCREEN END OF LINE.

    DATA:

    • 1st Table

    BEGIN OF gt_kna1 OCCURS 0, " Data displayed

    kunnr LIKE kna1-kunnr, " Customer number

    ernam LIKE kna1-ernam, " Name of Person who Created

    erdat LIKE kna1-erdat, " Creation date

    name1 LIKE kna1-name1, " Name 1

    END OF gt_kna1,

    • 2nd Table

    BEGIN OF gt_mara OCCURS 0,

    ernam LIKE mara-ernam, " Name of Person who Created

    matnr LIKE mara-matnr, " Material number

    ersda LIKE mara-ersda, " Creation date

    brgew LIKE mara-brgew, " Gross weight

    END OF gt_mara,

    • 3rd Table

    BEGIN OF gt_vbak OCCURS 0,

    vkorg LIKE vbak-vkorg, " Sales organization

    kunnr LIKE vbak-kunnr, " Sold-to party

    vbeln LIKE vbak-vbeln, " Sales document

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

    waerk LIKE vbak-waerk, " SD document currency

    END OF gt_vbak.

    ----


    INITIALIZATION.

    v_1 = 'Maximum of records to read'.

    ----


    START-OF-SELECTION.

    • Read data

    SELECT * FROM kna1

    UP TO p_max ROWS

    INTO CORRESPONDING FIELDS OF TABLE gt_kna1.

    SELECT * FROM mara

    UP TO p_max ROWS

    INTO CORRESPONDING FIELDS OF TABLE gt_mara.

    SELECT * FROM vbak

    UP TO p_max ROWS

    INTO CORRESPONDING FIELDS OF TABLE gt_vbak.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

    EXPORTING

    i_callback_program = sy-cprog

    i_callback_user_command = 'USER_COMMAND'.

    PERFORM list_append TABLES gt_kna1

    USING '1'

    'GT_KNA1'.

    PERFORM list_append TABLES gt_mara

    USING '2'

    'GT_MARA'.

    PERFORM list_append TABLES gt_vbak

    USING '3'

    'GT_VBAK'.

    PERFORM f_list_display.

    ----


    • FORM USER_COMMAND *

    ----


    FORM user_command USING i_ucomm LIKE sy-ucomm

    is_selfield TYPE slis_selfield. "#EC CALLED

    CASE i_ucomm.

    WHEN '&IC1'. " Pick

    CASE is_selfield-tabname.

    WHEN 'GT_MARA'.

    WHEN 'GT_KNA1'.

    WHEN 'GT_VBAK'.

    READ TABLE gt_vbak INDEX is_selfield-tabindex.

    IF sy-subrc EQ 0.

    • Sales order number

    SET PARAMETER ID 'AUN' FIELD gt_vbak-vbeln.

    • Display Sales Order

    CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

    ENDIF.

    ENDCASE.

    ENDCASE.

    ENDFORM. " USER_COMMAND

    ----


    */div>

    • Form list_append

    ----


    FORM list_append TABLES ut_table

    USING u_no TYPE char1

    u_tabname TYPE slis_tabname.

    • Macro definition

    DEFINE m_fieldcat.

    ls_fieldcat-fieldname = &1.

    ls_fieldcat-ref_tabname = &2.

    append ls_fieldcat to lt_fieldcat.

    END-OF-DEFINITION.

    DEFINE m_sort.

    ls_sort-fieldname = &1.

    ls_sort-up = 'X'.

    append ls_sort to lt_sort.

    END-OF-DEFINITION.

    DATA :

    ls_fieldcat TYPE slis_fieldcat_alv,

    lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog

    ls_sort TYPE slis_sortinfo_alv,

    lt_sort TYPE slis_t_sortinfo_alv. " Sort table

    DATA:

    lt_events TYPE slis_t_event,

    ls_event TYPE slis_alv_event,

    ls_layout TYPE slis_layout_alv.

    ls_layout-group_change_edit = 'X'.

    ls_layout-colwidth_optimize = 'X'.

    ls_layout-zebra = 'X'.

    ls_layout-detail_popup = 'X'.

    ls_layout-get_selinfos = 'X'.

    ls_layout-max_linesize = '200'.

    CASE u_no.

    WHEN '1'.

    • Build field catalog and sort table

    m_fieldcat 'KUNNR' 'KNA1'.

    m_fieldcat 'ERNAM' 'KNA1'.

    m_fieldcat 'ERDAT' 'KNA1'.

    m_fieldcat 'NAME1' 'KNA1'.

    m_sort 'KUNNR'.

    WHEN '2'.

    m_fieldcat 'MATNR' 'MARA'.

    m_fieldcat 'ERNAM' 'MARA'.

    m_fieldcat 'ERSDA' 'MARA'.

    m_fieldcat 'BRGEW' 'MARA'.

    m_sort 'MATNR'.

    WHEN '3'.

    m_fieldcat 'VBELN' 'VBAK'.

    m_fieldcat 'VKORG' 'VBAK'.

    m_fieldcat 'KUNNR' 'VBAK'.

    m_fieldcat 'NETWR' 'VBAK'.

    m_fieldcat 'WAERK' 'VBAK'.

    m_sort 'VBELN'.

    ENDCASE.

    IF u_no CA '13'.

    MOVE 'TOP_OF_PAGE' TO ls_event-name.

    CONCATENATE 'TOP_OF_PAGE' u_no INTO ls_event-form.

    APPEND ls_event TO lt_events.

    ELSE.

    MOVE 'TOP_OF_LIST' TO ls_event-name.

    CONCATENATE 'TOP_OF_LIST' u_no INTO ls_event-form.

    APPEND ls_event TO lt_events.

    ENDIF.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

    it_fieldcat = lt_fieldcat

    is_layout = ls_layout

    i_tabname = u_tabname

    it_events = lt_events

    it_sort = lt_sort

    • i_text =

    TABLES

    t_outtab = ut_table

    EXCEPTIONS

    program_error = 1

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

    ENDIF.

    ENDFORM. " LIST_APPEND

    ----


    • Form f_list_display

    ----


    FORM f_list_display.

    DATA ls_print TYPE slis_print_alv.

    ls_print-no_print_selinfos = 'X'. " Display no selection infos

    ls_print-no_print_listinfos = 'X'. " Display no listinfos

    ls_print-reserve_lines = 2. " Lines reserved for end of page

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

    EXPORTING

    i_interface_check = ' '

    is_print = ls_print

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

    ----


    • FORM top_of_page1 *

    ----


    FORM top_of_page1. "#EC CALLED

    PERFORM top_of_page.

    ENDFORM.

    ----


    • FORM top_of_page3 *

    ----


    FORM top_of_page3. "#EC CALLED

    PERFORM top_of_page.

    ENDFORM.

    ----


    • FORM top_of_page *

    ----


    FORM top_of_page.

    ULINE.

    WRITE : sy-uname, sy-title(56) CENTERED, sy-datum.

    ULINE.

    ENDFORM.

    ----


    • FORM top_of_list2 *

    ----


    FORM top_of_list2. "#EC CALLED

    WRITE 'TOP OF LIST2'.

    ENDFORM.

    • END OF PROGRAM Z_ALV_LIST_BLOCK ***********************

    REPORT ZKEERTHI_ALV3 LINE-COUNT 100 .

    &----


    *& tables declaration

    &----


    tables: mara.

    &----


    *& type-pools declaration

    &----


    type-pools: slis.

    &----


    *& data declaration

    &----


    data: g_repid type sy-repid.

    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, "mara

    WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

    DATA : IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV, "makt

    WA_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV.

    DATA : IT_FIELDCAT2 TYPE SLIS_T_FIELDCAT_ALV, "marc

    WA_FIELDCAT2 TYPE SLIS_FIELDCAT_ALV.

    DATA: GT_PRINT TYPE SLIS_PRINT_ALV,

    WA_LAYOUT TYPE SLIS_LAYOUT_ALV,

    XS_EVENT TYPE SLIS_ALV_EVENT,

    GT_XEVENTS TYPE SLIS_T_EVENT,

    GT_YEVENTS TYPE SLIS_T_EVENT,

    GT_ZEVENTS TYPE SLIS_T_EVENT,

    WA_SORT TYPE SLIS_SORTINFO_ALV,

    IT_SORT TYPE SLIS_T_SORTINFO_ALV.

    DATA: BEGIN OF it_mara occurs 0,

    MATNR LIKE MARA-MATNR,

    MTART LIKE MARA-MTART,

    MATKL LIKE MARA-MATKL,

    MEINS LIKE MARA-MEINS,

    NTGEW LIKE MARA-NTGEW,

    END OF it_mara.

    DATA: BEGIN OF IT_MAKT occurs 0,

    MATNR LIKE MAKT-MATNR,

    SPRAS LIKE MAKT-SPRAS,

    MAKTX LIKE MAKT-MAKTX,

    MAKTG LIKE MAKT-MAKTG,

    END OF IT_MAKT.

    DATA: BEGIN OF IT_MARC occurs 0,

    MATNR LIKE MARC-MATNR,

    WERKS LIKE MARC-WERKS,

    LADGR LIKE MARC-LADGR,

    MTVFP LIKE MARC-MTVFP,

    dispr LIKE marc-dispr,

    dismm LIKE marc-dismm,

    dispo LIKE marc-dispo,

    END OF IT_MARC.

    &----


    *& initialisation

    &----


    initialization.

    g_repid = sy-repid.

    &----


    *& selection screen

    &----


    selection-screen begin of block b with frame title text-001.

    select-options: s_matnr for mara-matnr,

    s_mtart for mara-mtart.

    selection-screen end of block b.

    &----


    *& start of selection

    &----


    start-of-selection.

    perform get_maradetails.

    perform get_maktdetails.

    perform get_marcdetails.

    &----


    *& Form get_maradetails

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM get_maradetails .

    select matnr

    mtart

    matkl

    meins

    ntgew from mara

    into table it_mara

    where matnr in s_matnr and

    mtart in s_mtart.

    ENDFORM. " get_maradetails

    &----


    *& Form get_maktdetails

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM get_maktdetails .

    select matnr

    spras

    maktx

    maktg from makt into table it_makt

    for all entries in it_mara

    where matnr = it_mara-matnr..

    ENDFORM. " get_maktdetails

    &----


    *& Form get_marcdetails

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM get_marcdetails .

    select matnr

    werks

    ladgr

    mtvfp

    dispr

    dismm

    dispo from marc

    into table it_marc

    for all entries in it_mara

    where matnr = it_mara-matnr.

    ENDFORM. " get_marcdetails

    &----


    *& end of selection

    &----


    END-OF-SELECTION.

    perform sort_list.

    perform modify_fieldcat.

    PERFORM EVENT_LIST.

    PERFORM BLOCK_LIST.

    &----


    *& Form modify_fieldcat

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM modify_fieldcat .

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'MATNR'.

    WA_FIELDCAT-TABNAME = 'IT_MARA'.

    WA_FIELDCAT-SELTEXT_L = 'MATERIAL NUM'.

    WA_FIELDCAT-COL_POS = 1.

    WA_FIELDCAT-OUTPUTLEN = 18.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'MTART'.

    WA_FIELDCAT-TABNAME = 'IT_MARA'.

    WA_FIELDCAT-SELTEXT_L = 'MAT TYPE'.

    WA_FIELDCAT-COL_POS = 2.

    WA_FIELDCAT-OUTPUTLEN = 5.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'MATKL'.

    WA_FIELDCAT-TABNAME = 'IT_MARA'.

    WA_FIELDCAT-SELTEXT_L = 'MAT GROUP'.

    WA_FIELDCAT-COL_POS = 3.

    WA_FIELDCAT-OUTPUTLEN = 10.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'MEINS'.

    WA_FIELDCAT-TABNAME = 'IT_MARA'.

    WA_FIELDCAT-SELTEXT_L = 'UNIT'.

    WA_FIELDCAT-COL_POS = 4.

    WA_FIELDCAT-OUTPUTLEN = 5.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'NTGEW'.

    WA_FIELDCAT-TABNAME = 'IT_MARA'.

    WA_FIELDCAT-DO_SUM = 'X'.

    WA_FIELDCAT-SELTEXT_L = 'QUANTITY'.

    WA_FIELDCAT-COL_POS = 5.

    WA_FIELDCAT-OUTPUTLEN = 15.

    APPEND WA_FIELDCAT TO IT_FIELDCAT.

    CLEAR WA_FIELDCAT.

    CLEAR WA_FIELDCAT1.

    WA_FIELDCAT1-FIELDNAME = 'MATNR'.

    WA_FIELDCAT1-TABNAME = 'IT_MAKT'.

    WA_FIELDCAT1-SELTEXT_L = 'MATERIAL NUM'.

    WA_FIELDCAT1-COL_POS = 1.

    WA_FIELDCAT1-OUTPUTLEN = 18.

    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

    CLEAR WA_FIELDCAT1.

    WA_FIELDCAT1-FIELDNAME = 'SPRAS'.

    WA_FIELDCAT1-TABNAME = 'IT_MAKT'.

    WA_FIELDCAT1-SELTEXT_L = 'LANGUAGE'.

    WA_FIELDCAT1-COL_POS = 2.

    WA_FIELDCAT1-OUTPUTLEN = 2.

    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

    CLEAR WA_FIELDCAT1.

    WA_FIELDCAT1-FIELDNAME = 'MAKTX'.

    WA_FIELDCAT1-TABNAME = 'IT_MAKT'.

    WA_FIELDCAT1-SELTEXT_L = 'MAT DESC'.

    WA_FIELDCAT1-COL_POS = 3.

    WA_FIELDCAT1-OUTPUTLEN = 40.

    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

    CLEAR WA_FIELDCAT1.

    WA_FIELDCAT1-FIELDNAME = 'MAKTG'.

    WA_FIELDCAT1-TABNAME = 'IT_MAKT'.

    WA_FIELDCAT1-SELTEXT_L = 'GRP DESC'.

    WA_FIELDCAT1-COL_POS = 4.

    WA_FIELDCAT1-OUTPUTLEN = 40.

    APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

    CLEAR WA_FIELDCAT1.

    CLEAR WA_FIELDCAT2.

    WA_FIELDCAT2-FIELDNAME = 'MATNR'.

    WA_FIELDCAT2-TABNAME = 'IT_MARC'.

    WA_FIELDCAT2-SELTEXT_L = 'MATERIAL NUM'.

    WA_FIELDCAT2-COL_POS = 1.

    WA_FIELDCAT2-OUTPUTLEN = 18.

    APPEND WA_FIELDCAT2 TO IT_FIELDCAT2.

    CLEAR WA_FIELDCAT2.

    WA_FIELDCAT2-FIELDNAME = 'WERKS'.

    WA_FIELDCAT2-TABNAME = 'IT_MARC'.

    WA_FIELDCAT2-SELTEXT_L = 'PLANT'.

    WA_FIELDCAT2-COL_POS = 2.

    WA_FIELDCAT2-OUTPUTLEN = 4.

    APPEND WA_FIELDCAT2 TO IT_FIELDCAT2.

    CLEAR WA_FIELDCAT2.

    WA_FIELDCAT2-FIELDNAME = 'LADGR'.

    WA_FIELDCAT2-TABNAME = 'IT_MARC'.

    WA_FIELDCAT2-SELTEXT_L = 'LOAD GRP'.

    WA_FIELDCAT2-COL_POS = 3.

    WA_FIELDCAT2-OUTPUTLEN = 4.

    APPEND WA_FIELDCAT2 TO IT_FIELDCAT2.

    CLEAR WA_FIELDCAT2.

    WA_FIELDCAT2-FIELDNAME = 'MTVFP'.

    WA_FIELDCAT2-TABNAME = 'IT_MARC'.

    WA_FIELDCAT2-SELTEXT_L = 'GRP CHK'.

    WA_FIELDCAT2-COL_POS = 4.

    WA_FIELDCAT2-OUTPUTLEN = 4.

    APPEND WA_FIELDCAT2 TO IT_FIELDCAT2.

    CLEAR WA_FIELDCAT2.

    WA_FIELDCAT2-FIELDNAME = 'DISPR'.

    WA_FIELDCAT2-TABNAME = 'IT_MARC'.

    WA_FIELDCAT2-SELTEXT_L = 'MRP PROFILE'.

    WA_FIELDCAT2-COL_POS = 5.

    WA_FIELDCAT2-OUTPUTLEN = 4.

    APPEND WA_FIELDCAT2 TO IT_FIELDCAT2.

    CLEAR WA_FIELDCAT2.

    WA_FIELDCAT2-FIELDNAME = 'DISMM'.

    WA_FIELDCAT2-TABNAME = 'IT_MARC'.

    WA_FIELDCAT2-SELTEXT_L = 'MRP TYPE'.

    WA_FIELDCAT2-COL_POS = 6.

    WA_FIELDCAT2-OUTPUTLEN = 4.

    APPEND WA_FIELDCAT2 TO IT_FIELDCAT2.

    CLEAR WA_FIELDCAT2.

    WA_FIELDCAT2-FIELDNAME = 'DISPO'.

    WA_FIELDCAT2-TABNAME = 'IT_MARC'.

    WA_FIELDCAT2-SELTEXT_L = 'MRP CON'.

    WA_FIELDCAT2-COL_POS = 7.

    WA_FIELDCAT2-OUTPUTLEN = 4.

    APPEND WA_FIELDCAT2 TO IT_FIELDCAT2.

    CLEAR WA_FIELDCAT2.

    ENDFORM. " modify_fieldcat

    &----


    *& Form BLOCK_LIST

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM BLOCK_LIST .

    CLEAR WA_LAYOUT.

    WA_LAYOUT-ZEBRA = 'X'.

    WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

    EXPORTING

    I_CALLBACK_PROGRAM = G_REPID

    I_CALLBACK_PF_STATUS_SET = ' '

    I_CALLBACK_USER_COMMAND = 'user_command'.

    • IT_EXCLUDING =

    .

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

    IS_LAYOUT = WA_LAYOUT

    IT_FIELDCAT = IT_FIELDCAT[]

    I_TABNAME = 'IT_MARA'

    IT_EVENTS = GT_XEVENTS

    IT_SORT = IT_SORT

    • I_TEXT = ' '

    TABLES

    T_OUTTAB = IT_MARA

    • EXCEPTIONS

    • PROGRAM_ERROR = 1

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

    ENDIF.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

    IS_LAYOUT = WA_LAYOUT

    IT_FIELDCAT = IT_FIELDCAT1

    I_TABNAME = 'IT_MAKT'

    IT_EVENTS = GT_YEVENTS

    • IT_SORT =

    • I_TEXT = ' '

    TABLES

    T_OUTTAB = IT_MAKT

    • EXCEPTIONS

    • PROGRAM_ERROR = 1

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

    ENDIF.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

    IS_LAYOUT = WA_LAYOUT

    IT_FIELDCAT = IT_FIELDCAT2

    I_TABNAME = 'IT_MARC'

    IT_EVENTS = GT_ZEVENTS

    • IT_SORT =

    • I_TEXT = ' '

    TABLES

    T_OUTTAB = IT_MARC

    • EXCEPTIONS

    • PROGRAM_ERROR = 1

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

    ENDIF.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    IS_PRINT = GT_PRINT

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

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

    &----


    *& Form EVENT_LIST

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM EVENT_LIST .

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.

    XS_EVENT-FORM = 'XTOP_OF_PAGE'.

    APPEND XS_EVENT TO GT_XEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_END_OF_PAGE.

    XS_EVENT-FORM = 'XEND_OF_PAGE'.

    APPEND XS_EVENT TO GT_XEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.

    XS_EVENT-FORM = 'XTOP_OF_LIST'.

    APPEND XS_EVENT TO GT_XEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_END_OF_LIST.

    XS_EVENT-FORM = 'XEND_OF_LIST'.

    APPEND XS_EVENT TO GT_XEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_END_OF_PAGE.

    XS_EVENT-FORM = 'YEND_OF_PAGE'.

    APPEND XS_EVENT TO GT_YEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.

    XS_EVENT-FORM = 'YTOP_OF_PAGE'.

    APPEND XS_EVENT TO GT_YEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.

    XS_EVENT-FORM = 'YTOP_OF_LIST'.

    APPEND XS_EVENT TO GT_YEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_END_OF_LIST.

    XS_EVENT-FORM = 'YEND_OF_LIST'.

    APPEND XS_EVENT TO GT_YEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_END_OF_PAGE.

    XS_EVENT-FORM = 'ZEND_OF_PAGE'.

    APPEND XS_EVENT TO GT_ZEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.

    XS_EVENT-FORM = 'ZTOP_OF_PAGE'.

    APPEND XS_EVENT TO GT_ZEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.

    XS_EVENT-FORM = 'ZTOP_OF_LIST'.

    APPEND XS_EVENT TO GT_ZEVENTS.

    CLEAR XS_EVENT.

    XS_EVENT-NAME = SLIS_EV_END_OF_LIST.

    XS_EVENT-FORM = 'ZEND_OF_LIST'.

    APPEND XS_EVENT TO GT_ZEVENTS.

    CLEAR XS_EVENT.

    ENDFORM. " EVENT_LIST

    FORM XTOP_OF_PAGE.

    WRITE:/ 'TOP OF PAGE FOR MARA'.

    ENDFORM.

    FORM YTOP_OF_PAGE.

    WRITE:/ 'TOP OF PAGE FOR MAKT'.

    ENDFORM.

    FORM ZTOP_OF_PAGE.

    WRITE:/ 'TOP OF PAGE FOR MARC'.

    ENDFORM.

    FORM XEND_OF_PAGE.

    WRITE:/ 'END OF PAGE FOR MARA'.

    ENDFORM.

    FORM YEND_OF_PAGE.

    WRITE:/ 'END OF PAGE FOR MAKT'.

    ENDFORM.

    FORM ZEND_OF_PAGE.

    WRITE:/ 'END OF PAGE FOR MARC'.

    ENDFORM.

    FORM XTOP_OF_LIST.

    WRITE:/ 'TOP OF LIST FOR MARA'.

    ENDFORM.

    FORM YTOP_OF_LIST.

    WRITE:/ 'TOP OF LIST FOR MAKT'.

    ENDFORM.

    FORM ZTOP_OF_LIST.

    WRITE:/ 'TOP OF LIST FOR MARC'.

    ENDFORM.

    FORM XEND_OF_LIST.

    WRITE:/ 'END OF LIST FOR MARA'.

    ENDFORM.

    FORM YEND_OF_LIST.

    WRITE:/ 'END OF LIST FOR MAKT'.

    ENDFORM.

    FORM ZEND_OF_LIST.

    WRITE:/ 'END OF LIST FOR MARC'.

    ENDFORM.

    &----


    *& Form sort_list

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM sort_list .

    CLEAR WA_SORT.

    WA_SORT-FIELDNAME = 'MTART'.

    WA_SORT-SUBTOT = 'X'.

    APPEND WA_SORT TO IT_SORT.

    CLEAR WA_SORT.

    WA_SORT-FIELDNAME = 'MATKL'.

    WA_SORT-SUBTOT = 'X'.

    APPEND WA_SORT TO IT_SORT.

    CLEAR WA_SORT.

    ENDFORM. " sort_list

    regards.

    sowjanya.b

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.