Skip to Content

Field catalog using cl_salv_table

Hi experts,

I am using cl_salv_table to display the data.

1.Is it possible to pass my own field catalog to this class as we pass for cl_gui_alv_grid.

We can get the functions by the following code....

gr_funct = gr_table->get_functions( ).

gr_funct->set_all( Abap_True ).

But,

2.How to hide specific functions and display few extra functions like 'FIND' etc..

3.How to set the column heading.

4.How to optimize the width of the column.

If I can pass my own field catalog to this I will be able to solve maximum issues.

Best Regards,

Eshwar

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 Dec 16, 2014 at 07:19 AM

    Hi,

    Below code can help you to change field catalog and column width.

    You can go through Method of class cl_salv_functions_list, cl_salv_columns_table, cl_salv_column_table and cl_salv_table to find various functions or options that can be done.

    DATA: o_col TYPE REF TO cl_salv_column_table,

    o_columns TYPE REF TO cl_salv_columns_table.

    *To set columns optimized

    CALL METHOD o_columns->set_optimize

    EXPORTING

    value = abap_true.

    *Setting Short Text, Max 10 characters

    CALL METHOD o_col->set_short_text

    EXPORTING

    value = fp_stext.



    *Setting Medium Text, Max 20 characters

    CALL METHOD o_col->set_medium_text

    EXPORTING

    value = fp_mtext.



    *Setting Long Text, Max 40 characters

    CALL METHOD o_col->set_long_text

    EXPORTING

    value = fp_ltext.



    *To change alignment

    CALL METHOD o_col->set_alignment

    EXPORTING

    value = if_salv_c_alignment=>left.

    Regards,

    Ganesh Lathi.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 16, 2014 at 08:03 AM

    Hi,

    the SALV-classes are a strict(er) OO-approach (in contrast to cl_gui_alv_grid e.g.).


    So, it's only consequent that we don't find a field-catalog here anymore (that means a huge structure with many flags). The OO-approach offers classes for the different components instead, like Ganesh has already posted.


    I agree that switching to SALV is a little bit hard for the first time, having to find all the classes/methods instead of the "old" field-catalog. However, the documentation for the classes (se24) is quite helpful fortunatelly.


    Regards,

    Ulrich

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 16, 2014 at 08:21 AM

    Hi Eshwar,

    Why you need fieldcatlog? It seems how many field columns in your itab then it will shows all field columns out.

    2, Do not use set_all() method, to use set_function() with name and bool value.Just go class CL_SALV_FUNCTIONS_LIST to check.

    3, Using cl_salv_columns_table to get_column(), then set_short_text().

    4, there is class cl_salv_layout to set layout.

    Detail please refer this link: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/eac1fa0b-0e01-0010-0990-8530de4908a6?QuickLink=index&overridelayout=true&5003637741929

    regards,

    Archer.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 16, 2014 at 09:06 AM

    Hi,

    Data :lv_columns type ref to cl_salv_columns_table,

    lv_column type ref to cl_salv_column_table.

    lv_columns = gt_table->get_columns().

    lv_columns->set_optimize( abap_true).

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 16, 2014 at 12:54 PM
    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.