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: 

Refresh ALV field catalog

Former Member
0 Kudos
7,126

Hi,

I have developed one program with dynamic internal table. And also I have added another toolbar button to the standard ALV toolbar.

When I press ALV custom toolbar button, ALV field catalog should refresh.

Here is the situation:

After displaying output I am hiding few fields from the output. Then I am pressing ALV custom toolbar button.

But my ALV field catalog is not refreshing. I need updated fieldcatalog. I mean whatever I hide those fields should update in fieldcatalog table (i.e it_fieldcatalog-NO_OUT = 'X').

I am not using any custom containers / classes. Please help me.

I supposed to write the code in user_command subroutine based on the updated fieldcatalog.

Please help me.

Thanks

Raghu

15 REPLIES 15

Former Member
0 Kudos
851

Hi

When ever u r user command is triggered, build another field catalog internal table.

regards,

Raghu

0 Kudos
851

Anyone got idea?

No OOPS concept. Normal ALV_GRID_DISPLAY

Edited by: r badveli on Oct 13, 2009 10:14 PM

Former Member
0 Kudos
851

Hi,

Try this:

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

  • i_background_id = 'ALV_BACKGROUND'

i_callback_program = g_repid

i_callback_pf_status_set = 'PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

is_layout_lvc = gs_layout

it_fieldcat_lvc = gt_fieldcat[]

i_save = g_save

is_variant = g_variant

it_events = gt_events[]

it_event_exit = lt_event_exit

i_default = 'X'

TABLES

t_outtab = itab_data.

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

.......

.......

modify itab_data.

rs_selfield-refresh = 'X'.

Regards,

José

0 Kudos
851

Thanks for yor response.

Still I am getting same problem.

0 Kudos
851

Hi,

Use this in Interactive section (User Command ) even if you are doing simple ALV.

DATA:

lv_ref_grid TYPE REF TO cl_gui_alv_grid.

CLEAR : gv_tcode.

*-- to ensure that only new processed data is displayed

IF lv_ref_grid IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = lv_ref_grid.

ENDIF.

IF NOT lv_ref_grid IS INITIAL.

CALL METHOD lv_ref_grid->check_changed_data.

ENDIF.

THis will solve your problem.

Thanks and Regards,

Vijay

0 Kudos
851

Hi Vijay,

As you said I followed your steps. But no effect on fieldcatalog table IT_FIELDS.

If I use CALL METHOD LV_REF_GRID->CHECK_CHANGED_DATA. where the data get changed. I need modified field catalog.

i mean.. if user hide some fields ... those fields update in fieldcatlog table with NO_OUT = 'X'.

Please help me.

================

Here is my code:

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_HTML_TOP_OF_PAGE = 'HTML_TOP_OF_PAGE'

IS_LAYOUT = GS_LAYOUT

IT_FIELDCAT = IT_FIELDS

IT_SORT = IT_SORT

I_SAVE = 'A'

IS_VARIANT = G_VARIANT

TABLES

T_OUTTAB = <L_TABLE> ====> Dynamic Internal Table

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

====

FORM USER_COMMAND USING UCOMM TYPE SY-UCOMM

SELFIELD TYPE SLIS_SELFIELD.

DATA: LV_REF_GRID TYPE REF TO CL_GUI_ALV_GRID.

IF LV_REF_GRID IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = LV_REF_GRID.

ENDIF.

IF NOT LV_REF_GRID IS INITIAL.

CALL METHOD LV_REF_GRID->CHECK_CHANGED_DATA.

ENDIF.

ENDFORM. "USER_COMMAND

====

Thanks

Raghu

0 Kudos
851

Please Help me .

0 Kudos
851

Its Webdynpro? I am not sure...

I just do it in Dynpro with the function table for first display.

after i created two objects - one for the container the second for the alv table - i destroy both with container->free. and alv-> free.

like:

if alv_object is not initial

call method alv_object->free.

clear alv_object.

endif.

cal method container_object is not initial.

call method container_object->free.

clear container_object.

endif.

after that i create both objects again..

0 Kudos
851

No. I used normal ALV_GRID

0 Kudos
851

Cany anyone answer pls?

0 Kudos
851

Hi,

as far as I understud u need to use the functionality of Change Layout button in std ALV,which can be used to cahnge the layout of output list(hide/unhide).

0 Kudos
851

Hi

Can u try this..

Build two fieldcatalogs .

IT_FIELDS1 - having d fields to be displayed initially

IT_FIELDS2 - all fields ( including the hidden fields)

In the form 'USER_COMMAND'.

Write the code to call the FM REUSE_ALV_GRID_DISPLAY again using the fieldacatalog IT_FIELDS2 on clicking the refresh button on the custom toolbar.

former_member203650
Participant
851

I know this thread is over 4 years old, but no one actually gave the correct answer, so here is the correct answer:

In the user command subroutine, make the required changes to your field catalog (in this case, setting the NO_OUT values on the rows you want to show), then execute this code:

        DATA lv_ref_grid TYPE REF TO cl_gui_alv_grid.
      IF lv_ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = lv_ref_grid.
      ENDIF.
      IF NOT lv_ref_grid IS INITIAL.
        CALL METHOD lv_ref_grid->set_frontend_fieldcatalog
          EXPORTING
            it_fieldcatalog = t_fcat1.
      ENDIF.
      ps_selfield-refresh = abap_true.

This is assuming you are using the function module   REUSE_ALV_GRID_DISPLAY_LVC to display your ALV grid; I have not tested this technique with the older SLIS grid. Now the next time someone searches Google or SCN for the answer to this question, a working solution will be found!

Cheers,

TerryB

0 Kudos
851

It works perfectly with the older SLIS grid. It's the same approach, the only thing you gotta do is convert the old SLIS field catalog to the new LVC one.

There's this FM:  LVC_TRANSFER_FROM_SLIS, so there's no need to map the fields manually.

Thanks for sharing.

Former Member
0 Kudos
851

Hi,

You need to change the layout & save the same.

Under user command you may set code to assign the changed layout & then try to refresh ALV output.

Thanks!

Anil Sahni