Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Hide certain columns in ALV after Refresh

Hi,

I have displayed an ALV with a set of columns.

After some processing I want to display a different set of columns, hiding some of the columns of the first layout.

How do I achieve that ?

Thanks

~ Payel

Tags:
Former Member
replied

have the perform display inside your report. in that perform place the call function logic.

perform display_data.

form display_data.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = report_id
i_callback_pf_status_set = 'ALV_SET_PF_STATUS'
i_callback_user_command = 'ALV_USER_COMMAND'
is_layout = ls_layout
it_fieldcat = pi_field_cat
i_save = 'A'
TABLES
t_outtab = i_output
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc NE  0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
ENDIF.

endform.

just see the comments here..

FORM alv_user_command USING r_ucomm LIKE sy-ucomm
p_selfld TYPE slis_selfield.

r_ucomm = sy-ucomm.
DATA: wa_output TYPE ty_output,
l_valid TYPE c.

CASE r_ucomm.
WHEN '&CONTINUE'.
DATA ref1 TYPE REF TO cl_gui_alv_grid.

"Creates a ref to the I_OUTPUT table. 
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref1.


"Captures the checkbox status. 
CALL METHOD ref1->check_changed_data
IMPORTING e_valid = l_valid.

IF l_valid EQ 'X'.
LOOP AT i_output INTO wa_output WHERE check_box NE 'X'.
DELETE i_output INDEX sy-tabix.
ENDLOOP.

ENDIF.
p_selfld-refresh = 'X'.

WHEN '&PROCESS'.
PERFORM f_clear_items. " Please refer below
CLEAR i_output[].
APPEND LINES OF i_final_file TO i_output.
p_selfld-refresh = 'X'.

"here you need to add the columns to the fieldcatalog what 
"ever you want to display them.
" i hope all the data is present in the i_output.
"use the same table for display of extra columns also.
"populate the fieldcatalog with new columns or 
" by default make them hide using no_out
"here modify their status to visible using NO_OUT = ''.
p_selfield-exit = 'X'.  "this is used to exit the current list
perform display_data.  "new grid will be called.


"This is where I want to display the ALV with the new set of 
"data and columns ** 
ENDCASE.
ENDFORM. "alv_user_command

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