‎2009 Mar 12 10:44 AM
Hi Experts,
I am generating an ALV output using REUSE_ALV_GRID_DISPLAY where I a field as editable. If I am changing any row / rows and If I press a button, those rows should not come in ALV display (i.e. ALV should be refreshed ).
I made use of
sf-refresh = 'X'.
sf-col_stable = 'X' .
sf-row_stable = 'X' .
where sf is type slis_selfield
which is deleting only one line and not more than one line. And also, I should not recall REUSE_ALV_GRID_DISPLAY once again. The existing ALV must refreshed and the lines that I edited should not come.
Expecting your kind response,
Venkat
‎2009 Mar 12 10:50 AM
hi,
Suppose u hv a Perform "DISPLAY" inside wic u hv written ur code for the FM-ALV.
Do somethng at press of the button u catch a user command and call this perform all over again. in this way it will get refreshed and you will get the updated values.
regards,
ags.
‎2009 Mar 12 10:56 AM
Hi,
Take a button DELETE with function code DELETE in pf-status and then select records using checkbox and click DELETE button to remove records from ALV display
Use this code, its working:-
TYPE-POOLS : slis.
*INTERNAL TABLE
DATA : BEGIN OF it_final OCCURS 0,
chk(1) TYPE c.
INCLUDE STRUCTURE tcurc.
DATA : END OF it_final.
*FIELD CATALOG
DATA : it_field TYPE slis_t_fieldcat_alv,
wa_field TYPE slis_fieldcat_alv.
*LAYOUT
DATA : wa_layout TYPE slis_layout_alv.
START-OF-SELECTION.
*fill internal table
PERFORM get_data.
*create field catalogs
PERFORM field_cat.
*create alv layout
PERFORM alv_layout.
END-OF-SELECTION.
*display data in alv
PERFORM alv_display.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* Get data from database table
*----------------------------------------------------------------------*
FORM get_data .
SELECT * FROM tcurc UP TO 10 ROWS
INTO CORRESPONDING FIELDS OF TABLE it_final.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form FIELD_CAT
*&---------------------------------------------------------------------*
* Create Field Catalogs
*----------------------------------------------------------------------*
FORM field_cat .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'IT_FINAL'
i_structure_name = 'TCURC'
CHANGING
ct_fieldcat = it_field
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
wa_field-fieldname = 'CHK'.
wa_field-tabname = 'IT_FINAL'.
wa_field-outputlen = 2.
wa_field-seltext_l = ' '.
wa_field-edit = 'X'.
wa_field-input = 'X'.
wa_field-checkbox = 'X'.
APPEND wa_field TO it_field.
CLEAR wa_field.
ENDFORM. " FIELD_CAT
*&---------------------------------------------------------------------*
*& Form ALV_LAYOUT
*&---------------------------------------------------------------------*
* Set ALV Layout
*----------------------------------------------------------------------*
FORM alv_layout .
wa_layout-zebra = 'X'.
ENDFORM. " ALV_LAYOUT
*&---------------------------------------------------------------------*
*& Form ALV_DISPLAY
*&---------------------------------------------------------------------*
* Display data in ALV Grid
*----------------------------------------------------------------------*
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_field
i_callback_user_command = 'COMMAND'
is_layout = wa_layout
i_callback_pf_status_set = 'PF'
TABLES
t_outtab = it_final
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.
ENDFORM. " ALV_DISPLAY
*&---------------------------------------------------------------------*
*& Form pf
*&---------------------------------------------------------------------*
* FOR PF-STATUS WITH USER DEFINED BUTTONS
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM pf USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZPF_STAT'.
ENDFORM. "pf
*&---------------------------------------------------------------------*
*& Form command
*&---------------------------------------------------------------------*
* TO HANDLE USER ACTIONS AGAINST PF-STATUS
*----------------------------------------------------------------------*
* -->UCOMM text
* -->SELFIELD text
*----------------------------------------------------------------------*
FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
DATA : ok_code TYPE sy-ucomm.
ok_code = ucomm.
CASE ok_code.
WHEN 'DELETE'.
" to reflect the data changed into internal table
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
SORT it_final BY chk DESCENDING.
DELETE it_final WHERE chk = 'X'.
selfield-refresh = 'X'.
ENDCASE.
ENDFORM. "command
Hope this helps you.
Regards,
Tarun
Edited by: Tarun Gambhir on Mar 12, 2009 4:27 PM