09-12-2008 6:52 AM
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
09-12-2008 7:11 AM
Did you tried coding till the processing part.if so just post the code here..
You try till the processing part and then get back.
09-12-2008 7:01 AM
Hi,
After your processing you can call the same ALV output but make sure when you call again remove those field entries from field catalog and then pass the field catalog to the ALV FM. This ensures that the columns are hidden.
Regards,
Pramod
09-12-2008 7:03 AM
09-12-2008 7:11 AM
Did you tried coding till the processing part.if so just post the code here..
You try till the processing part and then get back.
09-12-2008 7:36 AM
Hi,
This is the Call to the ALV FM:
FORM alv_display_data.
IF v_flag IS INITIAL.
report_id = sy-repid.
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 <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDFORM. "display_data
Then I write this in the USER COMMAND Form:
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'.
This is where I want to display the ALV with the new set of data and columns **
ENDCASE.
ENDFORM. "alv_user_command
Call Transaction and BDC Code here:
FORM f_clear_items.
OPEN THE BDC SESSION FOR PROCESSING
PERFORM f_open_bdc_session.
PERFORM f_fetch_clear_data.
PERFORM f_process_clear_data.
PERFORM f_close_bdc_session.
ENDFORM. " f_clear_items
After I have the messages I want to display them.
Thanks,
Payel
09-12-2008 7:49 AM
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
09-12-2008 10:11 AM