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

Change ALV variant dynamically

kroly_horvth
Participant
0 Likes
3,607

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
Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,515

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

How do you "turn off invalid dates" exactly?

8 REPLIES 8
Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,516

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

Read only

0 Likes
2,515

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

Read only

Chintu6august
Contributor
0 Likes
2,515

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!!

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
2,515

How do you "turn off invalid dates" exactly?

Read only

0 Likes
2,515

    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.

Read only

Juwin
Active Contributor
0 Likes
2,515

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

Read only

Patrick_vN
Active Contributor
0 Likes
2,515

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

Read only

Clemenss
Active Contributor
0 Likes
2,515

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

Clemens