Skip to Content
avatar image
Former Member

Classes to split ALV in OO

Hi All,

I am using OO to display my ALV, what is needed to have a split on the ALV and display some data in the top half.

Here is my code:

TRY.

      cl_salv_table=>factory(
        IMPORTING r_salv_table = gr_alv
        CHANGING  t_table      = gt_rpt_details ).

      PERFORM f_set_header.
      PERFORM f_display_settings.

      gr_alv->set_screen_status(
      pfstatus = 'ZSTANDARD'
      report = sy-repid
      set_functions = gr_alv->c_functions_all ). "set all basic ALV funtions

      gr_events = gr_alv->get_event( ).
      "create layout object
      CREATE OBJECT gr_layout.

      lr_columns = gr_alv->get_columns( ).
      lr_columns->set_optimize( 'X' ).
      lr_columns->set_headers_visible( 'X' ).

*
*   get layout object
      lo_layout = gr_alv->get_layout( ).
*
*   set Layout save restriction
*   1. Set Layout Key .. Unique key identifies the Differenet ALVs
      ls_key-report = sy-repid.
      lo_layout->set_key( ls_key ).
*   2. Remove Save layout the restriction.
      lo_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
      lo_layout->set_default( abap_true ).
*
*   set initial Layout
      "lf_variant = 'Z/ZTEST'.
      "lo_layout->set_initial_layout( lf_variant ).

      CREATE OBJECT event_handler.

      SET HANDLER event_handler->on_user_command FOR gr_events.

      gr_functions = gr_alv->get_functions( ).

      gr_functions->set_all('X').

      gr_functions->set_group_filter( value = if_salv_c_bool_sap=>false ).

*       Set print preview
      gr_functions->set_print_preview( ).

      gr_alv->get_display_settings( ).

      gr_alv->display( ).

    CATCH cx_salv_msg.
      MESSAGE 'ALV Display Not possible'(w02) TYPE 'I' DISPLAY LIKE 'E'.
  ENDTRY.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Sep 21, 2010 at 01:59 PM

    In order to split the ALV you can use the below code for your reference

    data : lr_custom_container type ref to cl_gui_custom_container,

    lr_event_receiver type ref to lcl_event_receiver,

    lr_splitter type ref to cl_gui_splitter_container,

    lr_parent_top type ref to cl_gui_container,

    lr_parent_grid type ref to cl_gui_container,

    lr_dyndoc_id type ref to cl_dd_document,

    lr_display type ref to cl_gui_alv_grid.

    if lr_custom_container is initial.

    v_container_name = " Container name which you defined in Screen

    create object lr_custom_container

    exporting

    container_name = v_container_name

    exceptions

    cntl_error = 1

    cntl_system_error = 2

    create_error = 3

    lifetime_error = 4

    lifetime_dynpro_dynpro_link = 5.

    if sy-subrc <> 0.

    message i081 display like c_e.

    "Unknown Error Occured While Displaying

    leave to screen 0.

    endif.

    *Split the container into two parts

    create object lr_splitter

    exporting

    parent = lr_custom_container

    rows = 2

    columns = 1

    exceptions

    cntl_error = 1

    cntl_system_error = 2

    others = 3.

    if sy-subrc <> 0.

    message i081 display like c_e.

    "Unknown Error Occured While Displaying

    leave to screen 0.

    endif.

    *Get the upper part of the container into V_PARENT_TOP

    call method lr_splitter->get_container

    exporting

    row = 1

    column = 1

    receiving

    container = lr_parent_top.

    *Get the lower part of the container into V_PARENT_GRID

    call method lr_splitter->get_container

    exporting

    row = 2

    column = 1

    receiving

    container = lr_parent_grid.

    *Set the height of the top part of the container

    call method lr_splitter->set_row_height

    exporting

    id = 1

    height = 28

    exceptions

    cntl_error = 1

    cntl_system_error = 2

    others = 3.

    if sy-subrc <> 0.

    message i081 display like c_e.

    "Unknown Error Occured While Displaying

    leave to screen 0.

    endif.

    *Create a instance of cl_gui_alv_grid

    create object lr_display

    exporting

    i_parent = lr_parent_grid

    exceptions

    error_cntl_create = 1

    error_cntl_init = 2

    error_cntl_link = 3

    error_dp_create = 4

    others = 5.

    if sy-subrc <> 0.

    message i081 display like c_e.

    "Unknown Error Occured While Displaying

    leave to screen 0.

    endif.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Marcin Pciak

      maybe I asked the wrong questions... BUT I figured it out, Here is the code to make it work it is from SAP example program

      SALV_TEST_TABLE_DISPLAY_OR_XML

      *... Top of List, End of List
        data: lr_content type ref to cl_salv_form_element.
      
            PERFORM create_alv_form_content_tol USING space CHANGING lr_content.
            gr_alv->set_top_of_list( lr_content ).
      
      
      
      FORM create_alv_form_content_tol                     USING i_print TYPE sap_bool
                         CHANGING cr_content TYPE REF TO cl_salv_form_element.
      
        DATA: lr_header TYPE REF TO cl_salv_form_header_info,
              l_text    TYPE string.
      
      *... create header information
        CASE i_print.
          WHEN space.
            CONCATENATE 'TOP_OF_LIST' text-h01 INTO l_text SEPARATED BY space.
          WHEN abap_true.
            CONCATENATE 'TOP_OF_LIST_PRINT' text-h01 INTO l_text SEPARATED BY space.
        ENDCASE.
      
        CREATE OBJECT lr_header
          EXPORTING
            text    = l_text
            tooltip = l_text.
      
        cr_content = lr_header.
      ENDFORM.                    " CREATE_ALV_FORM_CONTENT_TOL
      
      

  • Sep 21, 2010 at 07:05 AM

    You use the same approach as you would work with splitter container and cl_gui_alv_grid . For this refer [Multiple ALVs on one screen|How to dispaly Three Internal Table Data (One below another) in ALV OOPS;.

    All you change is when calling factory method you pass one of the containers (top, middle, bottom) to parameter R_CONTAINER .

    Regards

    Marcin

    Add comment
    10|10000 characters needed characters exceeded