Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV - Get the data based on layout selected

Former Member
0 Likes
4,729

Hello -

I am using CL_SALV_TABLE class to display ALV report. However I would like to know how to get the filtered data when user creates a layout. Internal table contains all the data, however I want to have only those data based on the layout selected by the user in an internal table. How do i do this?

Thanks,

Hello -

I am using CL_SALV_TABLE class to display ALV report. However I would like to know how to get the filtered data when user creates a layout. Internal table contains all the data, however I want to have only those data based on the layout selected by the user in an internal table. How do i do this?

Thanks,

12 REPLIES 12
Read only

Former Member
0 Likes
3,096

After the report is displayed, goto the layout and select only the entires that you need to display and save this by giving the layout name.Make it the default(you have two check boxes user specific and Default, click the Default). U will get the entries selcted in this layout.

Read only

0 Likes
3,096

Layout will be specified on selection screen. Based on this layout, I want the filtered data in my internal table.

Read only

0 Likes
3,096

Hi Vijay,

getting data based on layout may not be a very good idea as the layout may be changed once the report is displayed. In that case certain columns may appear blank.

However i understand your requriment as reading the columns from the layout name and getting data for those columns.

This may require you to program some logic in the report too.

Say you get the list of columns then from that u need to decide which tables to get data from.

Read only

Former Member
0 Likes
3,096

the layout that u will enter on the slection screen is nothing but the layouts that u first save going to the Layout.

these layout names are displayed when you click on the F4 help for the layout fied on the selction screen.

u can use the FM 'REUSE_ALV_VARIANT_F4' to get the f4 help. and on slecting any of the names on the selction screen, the report displays the entries that were selected in that layout slected.

Read only

0 Likes
3,096

I know that only those entries specified as per layout will be displayed. However my internal table has all the columns ( and not as per the layout). I want this data (filtered as per layout) in a diff internal table (similar to the method get_filtered_entries).

Read only

0 Likes
3,096

but will it be the same layout that u will be entering always.then u can get the data into a diff int table. but if u chg the layout, that should be dynamic.can u explain the req.

Read only

aditya_aghor
Explorer
0 Likes
3,096

Use the set_initial_layout() method of class CL_SALV_LAYOUT.

For Demo code see standard SAP program in se38 'SALV_DEMO_LAYOUT_SERVICE'. let me know if this helps.

Regards,

Aditya

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,096

Look at this sdn wiki [Get set of filtered values from CL_SALV_TABLE|http://wiki.sdn.sap.com/wiki/display/Snippets/GetsetoffilteredvaluesfromCL_SALV_TABLE]

Regards,

Raymond

Read only

0 Likes
3,096

Hello Raymond -

Thanks for the reply. I tried this piece of code. However it does not seem to work for layouts. If I specify a layout on selection screen (which i had created and saved earlier), i am not able to get data for those columns in that layout.

Read only

0 Likes
3,096

Hi,

Are you using REUSE_ALV_VARIANT_GET in the at selection scree?

Are you passing the layout to the REUSE_ALV_GRID_DISPLAY?

Why do you exaclty want to get the selected fields in your internal table? Do you have a requirement to download data as per selected layout?If yes there is a different method for that.

Let me know if you need further info on this.

Thanks,

Read only

0 Likes
3,096

Hello -

You are right. I want to download data based on the layout. Using CL_SALV_TABLE to display the alv.

Read only

0 Likes
3,096

You can do the following

When the user clicks on download

1.Use FM REUSE_ALV_LIST_LAYOUT_INFO_GET / REUSE_ALV_GRID_LAYOUT_INFO_GET to get the Fieldcat (since due to selection of layout on sel screen some columns are disabled. For the columns which have been disabled the resultant Fieldcat from the above FMs would have NO_OUT = 'X'. Delete columns from Fieldcat itab where no_out = 'X'

2.create a dynamic itab using cl_alv_table_create=>create_dynamic_table( ) passing the above Fieldcat itab, get a handle of new itab

3.loop over the original itab and fill the new dynamic itab

hope this helps...