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

ALV List

Hi,

I need an output in the following way in an ALV list.

Vendor ID : A0002 Name : UMS SEMICONDUCTOR PTE LTD.,

sNO po no item Price Qty

1. 10001 10 12.30 10

2. 10002 20 30.30 50

3. 10003 30 40.30 150

Vendor ID : X0012 Name : ALPHA PTE LTD.,

sNO po no item Price Qty

1. 10004 10 1.30 10

2. 10005 20 50.30 50

3. 10006 30 620.30 150

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2009 at 07:43 AM

    Hi...

    You have to use...REUSE_ALV_BLOCK_LIST_APPEND for getting multiple internal table display..

    Regards

    Debarshi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2009 at 07:50 AM

    Hi,

    Use Fm this.

    REUSE_ALV_BLOCK_LIST_APPEND

    that Append Simple List in Block Mode

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2009 at 08:12 AM

    REPORT ZBLOCK_ALV.

    CONSTANTS :

    c_x VALUE 'X'.

    DEFINE m_fieldcat.

    ls_fieldcat-fieldname = &1.

    ls_fieldcat-ref_tabname = &2.

    ls_fieldcat-tabname = &3.

    append ls_fieldcat to lt_fieldcat.

    END-OF-DEFINITION.

    DEFINE m_sort.

    ls_sort-fieldname = &1.

    ls_sort-up = c_x.

    append ls_sort to lt_sort.

    END-OF-DEFINITION.

    TYPE-POOLS: slis. " ALV Global types

    TYPES:

    BEGIN OF ty_kna1,

    kunnr TYPE kna1-kunnr, " Customer number

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

    erdat TYPE kna1-erdat, " Creation date

    name1 TYPE kna1-name1, " Name 1 .

    END OF ty_kna1,

    BEGIN OF ty_mara,

    matnr TYPE mara-matnr, " Material number

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

    ersda TYPE mara-ersda, " Creation date

    mtart TYPE mara-mtart, " Material type

    matkl TYPE mara-matkl, " Material group

    END OF ty_mara,

    BEGIN OF ty_vbak,

    vbeln TYPE vbak-vbeln, " Sales document

    vkorg TYPE vbak-vkorg, " Sales organization

    vtweg TYPE vbak-vtweg, " Distribution channel

    kunnr TYPE vbak-kunnr, " Sold-to party

    erdat TYPE vbak-erdat, " Creation date

    END OF ty_vbak.

    DATA:

    gs_layout TYPE slis_layout_alv,

    gt_kna1 TYPE TABLE OF ty_kna1,

    gt_mara TYPE TABLE OF ty_mara,

    gt_vbak TYPE TABLE OF ty_vbak.

    SELECTION-SCREEN :

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

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

    SELECTION-SCREEN END OF LINE.

    INITIALIZATION.

    v_1 = 'Maximum of records to read'.

    START-OF-SELECTION.

    SELECT kunnr ernam erdat name1

    FROM kna1

    UP TO p_max ROWS

    INTO TABLE gt_kna1.

    SELECT matnr ernam ersda mtart matkl

    FROM mara

    UP TO p_max ROWS

    INTO TABLE gt_mara.

    SELECT vbeln vkorg vtweg kunnr erdat

    FROM vbak

    UP TO p_max ROWS

    INTO TABLE gt_vbak.

    END-OF-SELECTION.

    PERFORM f_display_data.

    FORM user_command USING u_ucomm TYPE sy-ucomm

    us_selfield TYPE slis_selfield. "#EC CALLED

    DATA:

    ls_vbak TYPE ty_vbak.

    CASE u_ucomm.

    WHEN '&IC1'. " Pick

    CASE us_selfield-tabname.

    WHEN 'GT_MARA'.

    WHEN 'GT_KNA1'.

    WHEN 'GT_VBAK'.

    READ TABLE gt_vbak INDEX us_selfield-tabindex INTO ls_vbak.

    IF sy-subrc EQ 0.

    SET PARAMETER ID 'AUN' FIELD ls_vbak-vbeln.

    CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

    ENDIF.

    ENDCASE.

    ENDCASE.

    ENDFORM. " USER_COMMAND

    FORM f_display_data.

    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

    lt_events TYPE slis_t_event,

    ls_event TYPE slis_alv_event.

    gs_layout-group_change_edit = c_x.

    gs_layout-colwidth_optimize = c_x.

    gs_layout-zebra = c_x.

    gs_layout-detail_popup = c_x.

    gs_layout-get_selinfos = c_x.

    m_fieldcat 'KUNNR' 'KNA1' 'GT_KNA1'.

    m_fieldcat 'ERNAM' 'KNA1' 'GT_KNA1'.

    m_fieldcat 'ERDAT' 'KNA1' 'GT_KNA1'.

    m_fieldcat 'NAME1' 'KNA1' 'GT_KNA1'.

    m_sort 'KUNNR'.

    MOVE 'TOP_OF_PAGE' TO ls_event-name.

    MOVE 'TOP_OF_PAGE' TO ls_event-form.

    APPEND ls_event TO lt_events.

    MOVE 'END_OF_LIST' TO ls_event-name.

    MOVE 'END_OF_LIST' TO ls_event-form.

    APPEND ls_event TO lt_events.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    i_callback_program = sy-cprog

    i_callback_user_command = 'USER_COMMAND'

    it_fieldcat = lt_fieldcat

    is_layout = gs_layout

    it_events = lt_events

    it_sort = lt_sort

    i_save = 'A'

    TABLES

    t_outtab = gt_kna1.

    ENDFORM. " F_DISPLAY_DATA

    FORM top_of_page. "#EC CALLED

    ULINE.

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

    ULINE.

    ENDFORM. " TOP_OF_PAGE

    FORM end_of_list. "#EC CALLED

    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

    lt_events TYPE slis_t_event,

    ls_event TYPE slis_alv_event.

    m_fieldcat 'MATNR' 'MARA' 'GT_MARA'.

    m_fieldcat 'ERNAM' 'MARA' 'GT_MARA'.

    m_fieldcat 'ERSDA' 'MARA' 'GT_MARA'.

    m_fieldcat 'MTART' 'MARA' 'GT_MARA'.

    m_fieldcat 'MATKL' 'MARA' 'GT_MARA'.

    m_sort 'MATNR'.

    MOVE 'END_OF_LIST' TO ls_event-name.

    MOVE 'END_OF_LIST_2' TO ls_event-form.

    APPEND ls_event TO lt_events.

    gs_layout-list_append = c_x.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    i_callback_program = sy-cprog

    it_fieldcat = lt_fieldcat

    is_layout = gs_layout

    it_sort = lt_sort

    it_events = lt_events

    i_save = 'A'

    TABLES

    t_outtab = gt_mara.

    ENDFORM. " END_OF_LIST

    FORM end_of_list_2. "#EC CALLED

    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

    lt_events TYPE slis_t_event,

    ls_event TYPE slis_alv_event.

    m_fieldcat 'VBELN' 'VBAK' 'GT_VBAK'.

    m_fieldcat 'VKORG' 'VBAK' 'GT_VBAK'.

    m_fieldcat 'VTWEG' 'VBAK' 'GT_VBAK'.

    m_fieldcat 'KUNNR' 'VBAK' 'GT_VBAK'.

    m_fieldcat 'ERDAT' 'VBAK' 'GT_VBAK'.

    m_sort 'VBELN'.

    MOVE 'TOP_OF_PAGE' TO ls_event-name.

    MOVE 'TOP_OF_PAGE' TO ls_event-form.

    APPEND ls_event TO lt_events.

    gs_layout-list_append = c_x.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    i_callback_program = sy-cprog

    it_fieldcat = lt_fieldcat

    is_layout = gs_layout

    it_sort = lt_sort

    it_events = lt_events

    i_save = 'A'

    TABLES

    t_outtab = gt_vbak.

    ENDFORM. " END_OF_LIST_2

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2009 at 08:57 AM

    this code is more then 5000 cahrs so i post in two part

    PART - 1

    REPORT ZBLOCK_ALV.

    CONSTANTS :

    c_x VALUE 'X'.

    DEFINE m_fieldcat.

    ls_fieldcat-fieldname = &1.

    ls_fieldcat-ref_tabname = &2.

    ls_fieldcat-tabname = &3.

    append ls_fieldcat to lt_fieldcat.

    END-OF-DEFINITION.

    DEFINE m_sort.

    ls_sort-fieldname = &1.

    ls_sort-up = c_x.

    append ls_sort to lt_sort.

    END-OF-DEFINITION.

    TYPE-POOLS: slis. " ALV Global types

    TYPES:

    BEGIN OF ty_kna1,

    kunnr TYPE kna1-kunnr, " Customer number

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

    erdat TYPE kna1-erdat, " Creation date

    name1 TYPE kna1-name1, " Name 1 .

    END OF ty_kna1,

    BEGIN OF ty_mara,

    matnr TYPE mara-matnr, " Material number

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

    ersda TYPE mara-ersda, " Creation date

    mtart TYPE mara-mtart, " Material type

    matkl TYPE mara-matkl, " Material group

    END OF ty_mara,

    BEGIN OF ty_vbak,

    vbeln TYPE vbak-vbeln, " Sales document

    vkorg TYPE vbak-vkorg, " Sales organization

    vtweg TYPE vbak-vtweg, " Distribution channel

    kunnr TYPE vbak-kunnr, " Sold-to party

    erdat TYPE vbak-erdat, " Creation date

    END OF ty_vbak.

    DATA:

    gs_layout TYPE slis_layout_alv,

    gt_kna1 TYPE TABLE OF ty_kna1,

    gt_mara TYPE TABLE OF ty_mara,

    gt_vbak TYPE TABLE OF ty_vbak.

    SELECTION-SCREEN :

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

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

    SELECTION-SCREEN END OF LINE.

    INITIALIZATION.

    v_1 = 'Maximum of records to read'.

    START-OF-SELECTION.

    SELECT kunnr ernam erdat name1

    FROM kna1

    UP TO p_max ROWS

    INTO TABLE gt_kna1.

    SELECT matnr ernam ersda mtart matkl

    FROM mara

    UP TO p_max ROWS

    INTO TABLE gt_mara.

    SELECT vbeln vkorg vtweg kunnr erdat

    FROM vbak

    UP TO p_max ROWS

    INTO TABLE gt_vbak.

    END-OF-SELECTION.

    PERFORM f_display_data.

    FORM user_command USING u_ucomm TYPE sy-ucomm

    us_selfield TYPE slis_selfield. "#EC CALLED

    DATA:

    ls_vbak TYPE ty_vbak.

    CASE u_ucomm.

    WHEN '&IC1'. " Pick

    CASE us_selfield-tabname.

    WHEN 'GT_MARA'.

    WHEN 'GT_KNA1'.

    WHEN 'GT_VBAK'.

    READ TABLE gt_vbak INDEX us_selfield-tabindex INTO ls_vbak.

    IF sy-subrc EQ 0.

    SET PARAMETER ID 'AUN' FIELD ls_vbak-vbeln.

    CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

    ENDIF.

    ENDCASE.

    ENDCASE.

    ENDFORM. " USER_COMMAND

    FORM f_display_data.

    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

    lt_events TYPE slis_t_event,

    ls_event TYPE slis_alv_event.

    gs_layout-group_change_edit = c_x.

    gs_layout-colwidth_optimize = c_x.

    gs_layout-zebra = c_x.

    gs_layout-detail_popup = c_x.

    gs_layout-get_selinfos = c_x.

    m_fieldcat 'KUNNR' 'KNA1' 'GT_KNA1'.

    m_fieldcat 'ERNAM' 'KNA1' 'GT_KNA1'.

    m_fieldcat 'ERDAT' 'KNA1' 'GT_KNA1'.

    m_fieldcat 'NAME1' 'KNA1' 'GT_KNA1'.

    m_sort 'KUNNR'.

    MOVE 'TOP_OF_PAGE' TO ls_event-name.

    MOVE 'TOP_OF_PAGE' TO ls_event-form.

    APPEND ls_event TO lt_events.

    MOVE 'END_OF_LIST' TO ls_event-name.

    MOVE 'END_OF_LIST' TO ls_event-form.

    APPEND ls_event TO lt_events.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    i_callback_program = sy-cprog

    i_callback_user_command = 'USER_COMMAND'

    it_fieldcat = lt_fieldcat

    is_layout = gs_layout

    it_events = lt_events

    it_sort = lt_sort

    i_save = 'A'

    TABLES

    t_outtab = gt_kna1.

    ENDFORM. " F_DISPLAY_DATA

    FORM top_of_page. "#EC CALLED

    ULINE.

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

    ULINE.

    ENDFORM. " TOP_OF_PAGE

    Edited by: krupa jani on Mar 31, 2009 10:58 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 31, 2009 at 08:58 AM

    PART - 2

    FORM end_of_list. "#EC CALLED

    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

    lt_events TYPE slis_t_event,

    ls_event TYPE slis_alv_event.

    m_fieldcat 'MATNR' 'MARA' 'GT_MARA'.

    m_fieldcat 'ERNAM' 'MARA' 'GT_MARA'.

    m_fieldcat 'ERSDA' 'MARA' 'GT_MARA'.

    m_fieldcat 'MTART' 'MARA' 'GT_MARA'.

    m_fieldcat 'MATKL' 'MARA' 'GT_MARA'.

    m_sort 'MATNR'.

    MOVE 'END_OF_LIST' TO ls_event-name.

    MOVE 'END_OF_LIST_2' TO ls_event-form.

    APPEND ls_event TO lt_events.

    gs_layout-list_append = c_x.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    i_callback_program = sy-cprog

    it_fieldcat = lt_fieldcat

    is_layout = gs_layout

    it_sort = lt_sort

    it_events = lt_events

    i_save = 'A'

    TABLES

    t_outtab = gt_mara.

    ENDFORM. " END_OF_LIST

    FORM end_of_list_2. "#EC CALLED

    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

    lt_events TYPE slis_t_event,

    ls_event TYPE slis_alv_event.

    m_fieldcat 'VBELN' 'VBAK' 'GT_VBAK'.

    m_fieldcat 'VKORG' 'VBAK' 'GT_VBAK'.

    m_fieldcat 'VTWEG' 'VBAK' 'GT_VBAK'.

    m_fieldcat 'KUNNR' 'VBAK' 'GT_VBAK'.

    m_fieldcat 'ERDAT' 'VBAK' 'GT_VBAK'.

    m_sort 'VBELN'.

    MOVE 'TOP_OF_PAGE' TO ls_event-name.

    MOVE 'TOP_OF_PAGE' TO ls_event-form.

    APPEND ls_event TO lt_events.

    gs_layout-list_append = c_x.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    i_callback_program = sy-cprog

    it_fieldcat = lt_fieldcat

    is_layout = gs_layout

    it_sort = lt_sort

    it_events = lt_events

    i_save = 'A'

    TABLES

    t_outtab = gt_vbak.

    ENDFORM. " END_OF_LIST_2

    Edited by: krupa jani on Mar 31, 2009 10:58 AM

    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.