Application Development 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: 

Change ALV variant dynamically

kroly_horvth
Participant
0 Kudos

Hi,

I have an alv grid (class) showing some data + day01...day31 columns. I use the field catalog to turn off invalid dates, like day31 column for June.

However if I use default variant or any variant for the ALV, its settings I do in the build_field_catalog, is overwritten. Thus I cannot hide 31June (which is an invalid date).

Any suggestions how to modify fields in the variant's fieldcatalog and at what point?

Thanks,

Charlie

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

Try to find an event like after_refresh then handle it to adapt field catalog, use methods like get_frontend_catalog and then set_frontend_catalog and trigger another refresh of the display if and only if you actually changed the catalog (no infinite loop).

Regards,

Raymond

8 REPLIES 8

raymond_giuseppi
Active Contributor
0 Kudos

Try to find an event like after_refresh then handle it to adapt field catalog, use methods like get_frontend_catalog and then set_frontend_catalog and trigger another refresh of the display if and only if you actually changed the catalog (no infinite loop).

Regards,

Raymond

0 Kudos

This worked, THANKS, I set up a g_first_run flag to prevent infinite loop, which is fine with me.

Chintu6august
Contributor
0 Kudos

Hi,

use FM : 'NUMBER_OF_DAYS_PER_MONTH_GET'

pass month and year in it.. you will get the number of days.

then check if month have 31 days.

if days > 30.

add new field to the fieldcatalog internal table.

endif.

as you have modified the Fieldcatalog internal table at run time call the following methods

GET_FRONTEND_FIELDCATALOG, SET_FRONTEND_FIELDCATALOG methods and REFRESH_TABLE_DISPLAY.

thank you!!

Jelena
Active Contributor
0 Kudos

How do you "turn off invalid dates" exactly?

0 Kudos

    CALL FUNCTION '/DSD/PR_LAST_DAY_OF_MONTHS'


Then in the field catalog I have DAY01...DAY31 fields and:


          ls_fcat-no_out = 'X'.

if the day is larger than the last day of the month.

Juwin
Active Contributor
0 Kudos

In such situations, I disable the option to save variants, so that users don't mess up the display and then start complaining saying, the display isn't working.

Thanks,

Juwin

Patrick_vN
Active Contributor
0 Kudos

Have you tried modifying the fieldcatolog at runtime and setting the column you wish to hide as technical?

Clemenss
Active Contributor
0 Kudos

Columns not to display can be marked tech = abap_true in field catalog. ALV layout variant can not override this.

Clemens