Skip to Content

cl_salv_table - Save Layout

I am using cl_salv_table to display an ALV but I can't get the save layout option to be available (in the menu path or on the toolbar). Is this not possible? Below is the code I am using to display:

  call method cl_salv_table=>factory
*    EXPORTING
*      list_display   = IF_SALV_C_BOOL_SAP=>FALSE
*      r_container    =
*      container_name =
    importing
      r_salv_table   = gr_table
    changing
      t_table        = it_out.

gr_functions = gr_table->get_functions( ).
  gr_functions->set_all( abap_true ).

  gr_display = gr_table->get_display_settings( ).
  gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
  gr_display->set_list_header( 'Cash Receipts Log' ).

  gr_sorts = gr_table->get_sorts( ).
*  TRY.

  call method gr_sorts->add_sort
  exporting
    columnname = 'BUKRS'
*      position   =
*      sequence   = IF_SALV_C_SORT=>SORT_UP
    subtotal   = if_salv_c_bool_sap=>false
*      group      = IF_SALV_C_SORT=>GROUP_NONE
*      obligatory = IF_SALV_C_BOOL_SAP=>FALSE
*    receiving
*      value      =
    .

  call method gr_sorts->add_sort
  exporting
    columnname = 'GKONT'
*      position   =
*      sequence   = IF_SALV_C_SORT=>SORT_UP
    subtotal   = if_salv_c_bool_sap=>false
*      group      = IF_SALV_C_SORT=>GROUP_NONE
*      obligatory = IF_SALV_C_BOOL_SAP=>FALSE
*    receiving
*      value      =
    .

  call method gr_sorts->add_sort
  exporting
    columnname = 'XREF1'
*      position   =
*      sequence   = IF_SALV_C_SORT=>SORT_UP
    subtotal   = if_salv_c_bool_sap=>false
*      group      = IF_SALV_C_SORT=>GROUP_NONE
*      obligatory = IF_SALV_C_BOOL_SAP=>FALSE
*    receiving
*      value      =
    .

  call method gr_sorts->add_sort
  exporting
    columnname = 'ZUONR'
*      position   =
*      sequence   = IF_SALV_C_SORT=>SORT_UP
    subtotal   = if_salv_c_bool_sap=>false
*      group      = IF_SALV_C_SORT=>GROUP_NONE
*      obligatory = IF_SALV_C_BOOL_SAP=>FALSE
*    receiving
*      value      =
    .

  call method gr_sorts->add_sort
  exporting
    columnname = 'BUDAT'
*      position   =
*      sequence   = IF_SALV_C_SORT=>SORT_UP
    subtotal   = if_salv_c_bool_sap=>true
*      group      = IF_SALV_C_SORT=>GROUP_NONE
*      obligatory = IF_SALV_C_BOOL_SAP=>FALSE
*    receiving
*      value      =
    .


  gr_columns = gr_table->get_columns( ).
  gr_column ?= gr_columns->get_column( 'GKONT').
  gr_column->set_long_text( 'Account Assignment Number' ).
  gr_column->set_medium_text( 'Account Assignment' ).
  gr_column->set_short_text( 'Account #' ).


  gr_agg = gr_table->get_aggregations( ).
  gr_agg->add_aggregation( 'WRBTR' ).

* Display
  gr_table->display( ).

Regards,

Davis

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Aug 11, 2008 at 09:07 PM

    If I want to allow the user to specify a variant, how do I do that. Right now I am using the f4_layouts method, passing the variant.

    PARAMETERS:       p_layout    TYPE disvariant-variant.
    
    *----------------------------------------------------------------------*
    * AT SELECTION-SCREEN ON VALUE-REQUEST                                 *
    *----------------------------------------------------------------------*
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout.
      PERFORM f4_layouts USING cl_salv_layout=>restrict_none CHANGING p_layout.
    
    
    *&---------------------------------------------------------------------*
    *&      Form  F4_LAYOUTS
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->P_IF_SALV_C_LAYOUT=>RESTRICT_NON  text
    *      <--P_P_LAYOUT  text
    *----------------------------------------------------------------------*
    FORM f4_layouts USING i_restrict TYPE salv_de_layout_restriction
    CHANGING c_layout TYPE disvariant-variant.
    
      DATA: ls_layout TYPE salv_s_layout_info,
            ls_key    TYPE salv_s_layout_key.
    
      ls_key-report = sy-repid.
    
      ls_layout = cl_salv_layout_service=>f4_layouts(
      s_key    = ls_key
      restrict = i_restrict ).
    
      c_layout = ls_layout-layout.
    
    ENDFORM.                    " F4_LAYOUTS

    It is allowing the user to press F4 but the layout doesn't get transferred to the ALV. I included the code that Rich posted and it does now allow for a save.

    Regards,

    Davis

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 11, 2008 at 04:46 PM
    10

    use the following coding to enable the save layout functionality.

    DATA: gr_layout TYPE REF TO cl_salv_layout.
    DATA: key TYPE salv_s_layout_key.
    
    gr_layout = gr_table->get_layout( ).
    key-report = sy-repid.
    gr_layout->set_key( key ).
    * You can pass the folling values to the SET_SAVE_RESTRICTION method.
    *RESTRICT_NONE
    *RESTRICT_USER_DEPENDANT
    *RESTRICT_USER_INDEPENDANT
    gr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).

    Also, you may want to look at this for reference.

    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/eac1fa0b-0e01-0010-0990-8530de4908a6

    Regards,

    Rich Heilman

    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.