SAP ABAP Getting the list of fields in the current layout using CL_SALV_TABLE

作者:郑德鼎 约 3 分钟阅读 更新日期:2024-02-22 2 年前更新 标签:ABAP, 开发

Getting the list of fields in the current layout using CL_SALV_TABLE

Hi Experts,

I am displaying the data available by using the class cl_salv_table.

I have been successful in displaying the table. But now I need to write a logic to download the table to the application server.

While downloading, I also need to consider the layout of the ALV selected. (The layout field is also provided in the selection screen and options are provided to run the program in background).

I am able to get the current layout of the ALV using CL_SALV_TABLE->GET_LAYOUT method (which will again be the value in the selection screen), but I couldnt find any method to find outthe fields available in current layout and the order of the fields.

Please help me finding out the same.

Thanks in advance,

Yuvaraj S

Tags

report

alv

alv_grid

abap_objects

abap

Former Member

December 05, 2012 at 05:42 AM

0 Likes

Helpful Answer

by

Raymond Giuseppi

Former Member

Not what you were looking for? View more on this topic or Ask a question

3 replies

Helpful Answer

Raymond Giuseppi replied

December 04, 2012 at 09:53 AM

Read Former Member's sample ALV fieldcatalog - create for ANY table which use methods get_columns and get_aggregations to get information from cl_salv_table and then rebuild the "classical" field catalog with method cl_salv_controller_metadata=>get_lvc_fieldcatalog.

Regards,

Raymond

0 likes

Helpful Answer

Former Member replied

December 04, 2012 at 12:56 PM

Yes, you can use they way Raymond mentioned. But: By far easier is the use of the columns object, i.e.

DATA:

lo_columns        TYPE REF TO cl_salv_columns_list,

lt_column_ref     TYPE salv_t_column_ref.

FIELD-SYMBOLS

<column>          TYPE LINE OF salv_t_column_ref.

• get columns object

lo_columns = mo_salv->get_columns( ).

• get table of columns

lt_column_ref = lo_columns->get( ).
LOOP AT lt_column_ref ASSIGNING <column>.

In the loop, you may use all required methods to get characteristics of each column, the name is in <column>-columnname and the columns reference is in <column>-r_column->. I.e. <column>-r_column->get_decimals(  ) gives numer of decimals of the column. The order of fields displayed is the order in lt_fields.

Regards,

Clemens

1 likes

Former Member replied

December 05, 2012 at 05:42 AM

Hi,

I must have been more clear with my question.

I am have provided o_layout->set_save_restriction( if_salv_c_layout=>restrict_none ) option.

This would allow me to save a Variant with any fields in any order.

cl_salv_controller_metadata=>get_lvc_fieldcatalog or mo_salv->get_columns( ) would give me the field catalogue for entire table. But I need to get the field catalogue for the variant that is chosen currently.

I searched for classes but since I couldn't find any, I am using a classical FM 'LT_DBDATA_READ_FROM_LTDX'..

This FM gives me details of all the fields and their order for the currenr variant.

Is there any other class methods that I can use for this situation?

Thanks,

Yuvaraj S

0 likes

郑德鼎

关于作者:郑德鼎

企业信息化与 SAP 技术顾问,长期专注 SAP ABAP、FI/CO、MM、SD 等模块的技术分享与实战经验总结。查看更多介绍

来源说明:本文内容由「SAP ABAP Getting the list of fields in the current layout using CL_SALV_TABLE.docx」整理生成,仅用于内部技术分享与学习交流。