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

ALV:

Hi.

Is it possible to display two lists in ALV. If yes,can anyone tell me?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 12, 2006 at 06:54 AM

    Hi osk,

    1. If you want to show two lists,

    then we have to use BLOCK Alv list concept.

    2. To get a taste of it,

    just copy paste in new program.

    (It will show data from T001, T000 tables)

    (execute the program, and see there will be

    TWO DIFFERENT LISTS)

    (its quite simple)

    3.

    REPORT zam_temp54 .

    type-pools : slis.

    data : alvfc type slis_t_fieldcat_alv.

    data : alvly type slis_layout_alv.

    data : alvev type slis_t_event .

    *----


    DATA : BEGIN OF itab OCCURS 0.

    include structure t001.

    DATA: END OF itab.

    DATA : BEGIN OF ptab OCCURS 0.

    INCLUDE STRUCTURE t000.

    DATA: END OF ptab..

    *----


    PARAMETERS : a TYPE c.

    *----


    start-of-selection.

    *----


    SELECT DATA

    SELECT * FROM t001 into table itab.

    select * from t000 into table ptab.

    *----


    INIT BLOCK ALV

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

    EXPORTING

    i_callback_program = sy-repid.

    *----


    ADD INTERNAL TABLE ITAB

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    I_PROGRAM_NAME = SY-REPID

    I_INTERNAL_TABNAME = 'ITAB'

    I_INCLNAME = SY-REPID

    CHANGING

    CT_FIELDCAT = ALVFC.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

    is_layout = alvly

    it_fieldcat = alvfc

    i_tabname = 'ITAB'

    it_events = alvev

    TABLES

    t_outtab = ITAB

    EXCEPTIONS

    program_error = 1

    maximum_of_appends_reached = 2

    OTHERS = 3.

    *----


    ADD INTERNAL TABLE PTAB

    REFRESH ALVFC[].

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    I_PROGRAM_NAME = SY-REPID

    I_INTERNAL_TABNAME = 'PTAB'

    I_INCLNAME = SY-REPID

    CHANGING

    CT_FIELDCAT = ALVFC.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

    is_layout = alvly

    it_fieldcat = alvfc

    i_tabname = 'PTAB'

    it_events = alvev

    TABLES

    t_outtab = PTAB

    EXCEPTIONS

    program_error = 1

    maximum_of_appends_reached = 2

    OTHERS = 3.

    *----


    DISPLAY

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

    EXCEPTIONS

    program_error = 1

    OTHERS = 2.

    regards,

    amit m.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 12, 2006 at 06:54 AM

    If you want to display two alv grid separtely in the output then you have create two custom controls in the screen and by using class CL_GUI_ALV_GRID.

    If you want to display two different internal tables in a single alv list then use 'REUSE_ALV_BLOCK_LIST_APPEND'.

    Cheers

    VJ

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 12, 2006 at 06:56 AM

    ya u can. u can use block alv or split container to fullfill ur requirment...

    for example go through <b>DWDM transaction</b>....

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 12, 2006 at 06:56 AM

    Hi,

    yes u can do it.

    u can display 2 alv list on the same screen.

    for that u have to use OO alv .

    1) create a screen

    2) place 2 custom control on the screen.

    3) create 2 refrence of the avl using 2 custom contol.

    4) rest remains the same for single alv .

    Mark Helpful Answers

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 12, 2006 at 06:59 AM

    Hi,

    yes it is possible. you can usse BLOCK list.

    check the demo program <b>BALVBT01</b>.

    Regards

    vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 12, 2006 at 07:10 AM

    hi,

    You can use block list ALV for your requirement.

    The below function modules can be used for the same.

    REUSE_ALV_BLOCK_LIST_INIT

    REUSE_ALV_BLOCK_LIST_APPEND

    REUSE_ALV_BLOCK_LIST_DISPLAY

    Please reward for the same.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 12, 2006 at 07:10 AM

    Hai

    go through the following Code

    REPORT ZALV_SALES_HEADER_DETAIL MESSAGE-ID Z50650(MSG) .

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

    • TABLES

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

    TABLES: VBAK . "SALES DOCUMENT HEADER

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

    • DATA OBJECTS DECLARATION

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

    DATA: IT_VBAK TYPE STANDARD TABLE OF ZVBAK_STRUC,

    IT_VBAP TYPE STANDARD TABLE OF ZVBAP_STRUC,

    GS_LAYOUT TYPE LVC_S_LAYO,

    GS1_LAYOUT TYPE LVC_S_LAYO,

    GRID TYPE REF TO CL_GUI_ALV_GRID,

    CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

    VBAK_CONTAINER TYPE REF TO CL_GUI_CONTAINER,

    VBAP_CONTAINER TYPE REF TO CL_GUI_CONTAINER,

    WA_VBAK LIKE LINE OF IT_VBAK,

    WA_VBAP LIKE LINE OF IT_VBAP,

    SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER,

    TOP_OF_PAGE_CONTAINER TYPE REF TO CL_GUI_CONTAINER,

    GRID_VBAP TYPE REF TO CL_GUI_ALV_GRID,

    TOP_PAGE TYPE REF TO CL_DD_DOCUMENT,

    FLAG(1).

    .

    *"EVENT RECIEVER CLASS DEFINITION

    CLASS LCL_EVENT_RECIEVER DEFINITION DEFERRED.

    DATA: OBJ_EVENT TYPE REF TO LCL_EVENT_RECIEVER.

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

    • SELECTION-SCREEN

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

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

    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.

    PARAMETERS: P_VBTYP LIKE VBAK-VBTYP DEFAULT 'C'.

    SELECTION-SCREEN: END OF BLOCK B1.

    • CLASS DEFINITION AND DECLARATIONS

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

    CLASS LCL_EVENT_RECIEVER DEFINITION.

    PUBLIC SECTION.

    EVENTS:DOUBLE_CLICK,

    TOP_OF_PAGE.

    METHODS:HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID

    IMPORTING E_ROW .

    METHODS: HANDLE_TOP_OF_PAGE FOR EVENT TOP_OF_PAGE OF CL_GUI_ALV_GRID.

    ENDCLASS. "LCL_EVENT_RECIEVER DEFINITION

    ----


    • CLASS LCL_EVENT_RECIEVER IMPLEMENTATION

    ----


    *

    ----


    CLASS LCL_EVENT_RECIEVER IMPLEMENTATION.

    METHOD: HANDLE_DOUBLE_CLICK.

    READ TABLE IT_VBAK INDEX E_ROW-INDEX INTO WA_VBAK.

    PERFORM FETCH_ITEM_DETAILS USING WA_VBAK.

    PERFORM ALV_GRID.

    ENDMETHOD. "HANDLE_DOUBLE_CLICK

    METHOD: HANDLE_TOP_OF_PAGE.

    CALL METHOD TOP_PAGE->ADD_TEXT

    EXPORTING

    TEXT = 'SALES HEADER & ITEM DETAILS'.

    CALL METHOD TOP_PAGE->DISPLAY_DOCUMENT

    EXPORTING

    PARENT = TOP_OF_PAGE_CONTAINER.

    ENDMETHOD. "HANDLER_TOP_OF_PAGE

    ENDCLASS. "LCL_EVENT_RECIEVER IMPLEMENTATION

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

    • AT SELECTION-SCREEN

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

    AT SELECTION-SCREEN.

    IF S_VBELN IS NOT INITIAL.

    SELECT COUNT(*)

    FROM VBAK

    WHERE VBELN IN S_VBELN.

    IF SY-DBCNT = 0.

    MESSAGE E000 WITH 'NO TABLE ENTRIES FOUND FOR LOW KEY SPECIFIED'.

    ENDIF.

    ENDIF.

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

    • START-OF-SELECTION.

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

    START-OF-SELECTION.

    PERFORM FETCH_SALES_HEADER_RECORD.

    PERFORM CREATE_CALL. "CREATION OF OBJECTS & CALLING METHODS

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

    • END-OF-SELECTION.

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

    END-OF-SELECTION.

    &----


    *& Module STATUS_0100 OUTPUT

    &----


    • text

    ----


    MODULE STATUS_0100 OUTPUT.

    SET PF-STATUS 'ZSTATUS'.

    • SET TITLEBAR 'xxx'.

    ENDMODULE. " STATUS_0100 OUTPUT

    &----


    *& Form FETCH_SALES_HEADER_RECORD

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM FETCH_SALES_HEADER_RECORD .

    SELECT

    VBELN

    AUDAT

    VBTYP

    AUART

    AUGRU

    NETWR

    WAERK

    FROM VBAK

    INTO CORRESPONDING FIELDS OF TABLE IT_VBAK

    WHERE VBELN IN S_VBELN

    AND VBTYP = P_VBTYP.

    ENDFORM. " FETCH_SALES_HEADER_RECORD

    &----


    *& Form CREATE_CALL

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM CREATE_CALL .

    IF CUSTOM_CONTAINER IS INITIAL.

    CREATE OBJECT CUSTOM_CONTAINER

    EXPORTING

    • PARENT =

    CONTAINER_NAME = 'CUSTOM_CONTAINER'

    • STYLE =

    • LIFETIME = lifetime_default

    • REPID =

    • DYNNR =

    • NO_AUTODEF_PROGID_DYNNR =

    EXCEPTIONS

    CNTL_ERROR = 1

    CNTL_SYSTEM_ERROR = 2

    CREATE_ERROR = 3

    LIFETIME_ERROR = 4

    LIFETIME_DYNPRO_DYNPRO_LINK = 5

    OTHERS = 6

    .

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    CREATE OBJECT SPLITTER

    EXPORTING

    TOP = 5

    PARENT = CUSTOM_CONTAINER

    ROWS = 3

    COLUMNS = 1

    EXCEPTIONS

    CNTL_ERROR = 1

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

    ENDIF.

    CALL METHOD SPLITTER->GET_CONTAINER

    EXPORTING

    ROW = 1

    COLUMN = 1

    RECEIVING

    CONTAINER = TOP_OF_PAGE_CONTAINER.

    CALL METHOD SPLITTER->GET_CONTAINER

    EXPORTING

    ROW = 2

    COLUMN = 1

    RECEIVING

    CONTAINER = VBAK_CONTAINER.

    CALL METHOD SPLITTER->GET_CONTAINER

    EXPORTING

    ROW = 3

    COLUMN = 1

    RECEIVING

    CONTAINER = VBAP_CONTAINER.

    CREATE OBJECT GRID

    EXPORTING

    • I_SHELLSTYLE = 0

    • I_LIFETIME =

    I_PARENT = VBAK_CONTAINER

    • I_APPL_EVENTS = space

    • I_PARENTDBG =

    • I_APPLOGPARENT =

    • I_GRAPHICSPARENT =

    • I_NAME =

    EXCEPTIONS

    ERROR_CNTL_CREATE = 1

    ERROR_CNTL_INIT = 2

    ERROR_CNTL_LINK = 3

    ERROR_DP_CREATE = 4

    OTHERS = 5

    .

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    GS_LAYOUT-GRID_TITLE = 'SALES HEADER DETAILS.'(100).

    CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTING

    • I_BUFFER_ACTIVE =

    • I_BYPASSING_BUFFER =

    • I_CONSISTENCY_CHECK =

    I_STRUCTURE_NAME = 'ZVBAK_STRUC'

    • IS_VARIANT =

    • I_SAVE =

    • I_DEFAULT = 'X'

    IS_LAYOUT = GS_LAYOUT

    • IS_PRINT =

    • IT_SPECIAL_GROUPS =

    • IT_TOOLBAR_EXCLUDING =

    • IT_HYPERLINK =

    • IT_ALV_GRAPHICS =

    • IT_EXCEPT_QINFO =

    CHANGING

    IT_OUTTAB = IT_VBAK

    • IT_FIELDCATALOG =

    • IT_SORT =

    • IT_FILTER =

    EXCEPTIONS

    INVALID_PARAMETER_COMBINATION = 1

    PROGRAM_ERROR = 2

    TOO_MANY_LINES = 3

    OTHERS = 4

    .

    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.

    CREATE OBJECT OBJ_EVENT .

    SET HANDLER OBJ_EVENT->HANDLE_DOUBLE_CLICK FOR GRID.

    SET HANDLER OBJ_EVENT->HANDLE_TOP_OF_PAGE FOR GRID.

    CREATE OBJECT TOP_PAGE

    EXPORTING

    STYLE = 'ALV_GRID'

    .

    CALL METHOD TOP_PAGE->INITIALIZE_DOCUMENT.

    CALL METHOD GRID->LIST_PROCESSING_EVENTS

    EXPORTING

    I_EVENT_NAME = 'TOP_OF_PAGE'

    I_DYNDOC_ID = TOP_PAGE.

    CALL SCREEN 100.

    ENDFORM. " CREATE_CALL

    &----


    *& Module USER_COMMAND_0100 INPUT

    &----


    • text

    ----


    MODULE USER_COMMAND_0100 INPUT.

    CASE SY-UCOMM.

    WHEN 'EXIT'.

    LEAVE PROGRAM.

    WHEN 'BACK'.

    LEAVE TO SCREEN 0.

    ENDCASE.

    ENDMODULE. " USER_COMMAND_0100 INPUT

    &----


    *& Form FETCH_ITEM_DETAILS

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM FETCH_ITEM_DETAILS USING WA_VBAK TYPE ZVBAK_STRUC .

    SELECT

    VBELN

    POSNR

    MATNR

    MATWA

    PMATN

    CHARG

    FROM VBAP

    INTO TABLE IT_VBAP

    WHERE VBELN = WA_VBAK-VBELN.

    IF SY-SUBRC <> 0.

    MESSAGE E000 WITH 'NO RECORDS FOUND FOR SPECIFIED KEY'.

    ENDIF.

    ENDFORM. " FETCH_ITEM_DETAILS

    &----


    *& Module STATUS_0200 OUTPUT

    &----


    • text

    ----


    MODULE STATUS_0200 OUTPUT.

    SET PF-STATUS 'ZSTATUS'.

    • SET TITLEBAR 'xxx'.

    ENDMODULE. " STATUS_0200 OUTPUT

    &----


    *& Module USER_COMMAND_0200 INPUT

    &----


    • text

    ----


    MODULE USER_COMMAND_0200 INPUT.

    CASE SY-UCOMM.

    WHEN 'EXIT'.

    LEAVE PROGRAM.

    WHEN 'BACK'.

    LEAVE TO SCREEN 0.

    ENDCASE.

    ENDMODULE. " USER_COMMAND_0200 INPUT

    &----


    *& Form alv_grid

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM ALV_GRID .

    IF FLAG = ''.

    FLAG = 'X'.

    CREATE OBJECT GRID_VBAP

    EXPORTING

    • I_SHELLSTYLE = 0

    • I_LIFETIME =

    I_PARENT = VBAP_CONTAINER

    • I_APPL_EVENTS = space

    • I_PARENTDBG =

    • I_APPLOGPARENT =

    • I_GRAPHICSPARENT =

    • I_NAME =

    • EXCEPTIONS

    • ERROR_CNTL_CREATE = 1

    • ERROR_CNTL_INIT = 2

    • ERROR_CNTL_LINK = 3

    • ERROR_DP_CREATE = 4

    • others = 5

    .

    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.

    GS1_LAYOUT-GRID_TITLE = 'SALES ITEM DETAILS.'(100).

    CALL METHOD GRID_VBAP->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTING

    • I_BUFFER_ACTIVE =

    • I_BYPASSING_BUFFER =

    • I_CONSISTENCY_CHECK =

    I_STRUCTURE_NAME = 'ZVBAP_STRUC'

    • IS_VARIANT =

    • I_SAVE =

    • I_DEFAULT = 'X'

    IS_LAYOUT = GS1_LAYOUT

    • IS_PRINT =

    • IT_SPECIAL_GROUPS =

    • IT_TOOLBAR_EXCLUDING =

    • IT_HYPERLINK =

    • IT_ALV_GRAPHICS =

    • IT_EXCEPT_QINFO =

    CHANGING

    IT_OUTTAB = IT_VBAP

    • IT_FIELDCATALOG =

    • IT_SORT =

    • IT_FILTER =

    EXCEPTIONS

    INVALID_PARAMETER_COMBINATION = 1

    PROGRAM_ERROR = 2

    TOO_MANY_LINES = 3

    OTHERS = 4

    .

    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

    Thanks & regards

    Sreeni

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 12, 2006 at 07:20 AM

    Hello,

    There are three Function modules to develop that.

    <b>1</b>.

    REUSE_ALV_BLOCK_LIST_INIT

    <b>2</b>.

    REUSE_ALV_BLOCK_LIST_APPEND.

    Here minimum exporting params are

    layout

    fieldcat

    tablename

    events

    sort

    Data TABLES

    output table.

    if u want another output again call

    REUSE_ALV_BLOCK_LIST_APPEND and pass above details.

    like that u can show any no of outputs one bye one .

    <b>3</b>.

    REUSE_ALV_BLOCK_LIST_DISPLAY

    <b>Thanks,

    Venkat.O</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.