05-20-2016 10:38 AM
I met a scheduling problem with ALV, there is a standard in standard ALV sorting, after I sorted by editable field, fill editable field values, refresh the ALV, for modified of the order of the record will be changed, I want to know is there any way after I manually triggered the sorting, refresh the ALV, interface does not change the data on the order
05-20-2016 1:35 PM
05-20-2016 5:55 PM
i.e. method REFRESH_TABLE_DISPLAY has parameters IS_STABLE and I_SOFT_REFRESH -> cf SAP Library http://help.sap.com/saphelp_nw70/helpdata/en/0a/b5531ed30911d2b467006094192fe3/frameset.htm
05-23-2016 2:05 AM
Is hope can edit fields in the ALV interface manual sorting, refresh before, can have a way to manually sort this reset, can make the last refresh is not the result of the chaos sequence
05-23-2016 2:18 AM
I have tried this, or not, when I show ALV, manual sorting editable field, modify the data after the refresh, it would still be in accordance with the manual sorting order, when will I revised data to other position, below is my code:
FORM user_command USING ucomm LIKE sy-ucomm "接收用户的命令
selfield TYPE slis_selfield.
READ TABLE i_output INDEX selfield-tabindex.
CHECK sy-subrc = 0.
DATA: wl_answer TYPE c.
DATA: is_stable TYPE lvc_s_stbl .
* DATA ds_sort1 TYPE lvc_S_sort.
DATA: ds_sort1 LIKE TABLE OF lvc_s_sort WITH HEADER LINE.
DATA: l_guid TYPE REF TO cl_gui_alv_grid.
DATA stbl TYPE lvc_s_stbl. "稳定刷新
* stbl-row = 'X'." 基于行的稳定刷新
* stbl-col = 'X'." 基于列稳定刷 新
DATA:ls_row TYPE lvc_s_row,
ls_col TYPE lvc_s_col.
DATA: pt_exclude TYPE ui_functions .
DATA : gt_exclude TYPE ui_functions.
DATA: ls_exclude TYPE ui_func.
DATA gs_layout TYPE lvc_s_layo .
DATA gt_fieldcat TYPE lvc_t_fcat .
DATA: l_grid TYPE REF TO cl_gui_alv_grid.
DATA: g_grid TYPE REF TO cl_gui_alv_grid.
DATA: lt_sort TYPE slis_t_sortinfo_alv.
*------------将ALV上修改的内容保存到内表--------------------------------
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_grid.
CALL METHOD l_grid->check_changed_data.
DATA: lt_excl_func TYPE ui_functions.
th_layout-no_toolbar = 'X' .
* CALL METHOD l_grid->set_table_for_first_display
* EXPORTING
* is_layout = th_layout
* i_buffer_active = 'X'
* it_toolbar_excluding = pt_exclude
* CHANGING
** it_sort = ds_sort1[]
* it_outtab = i_output[]
** it_fieldcatalog = i_fieldcat
* EXCEPTIONS
* invalid_parameter_combination = 1
* program_error = 2
* too_many_lines = 3
* OTHERS = 4.
* CALL METHOD l_grid->get_sort_criteria
* IMPORTING
* et_sort = ds_sort1.
CASE ucomm.
WHEN '&IC1'.
CASE selfield-sel_tab_field.
WHEN 'I_OUTPUT-LIFNR'.
PERFORM sel_lifnr USING ztype.
IF zlifnr <> '' .
i_output-lifnr = i_pb77-llief .
ENDIF .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = i_output-lifnr
IMPORTING
output = i_output-lifnr.
SELECT SINGLE sortl FROM lfa1 INTO i_output-sortl WHERE lifnr = i_output-lifnr.
*
MODIFY i_output INDEX selfield-tabindex.
* selfield-refresh = 'X'.
PERFORM alv_refresh CHANGING selfield-col_stable
selfield-row_stable
selfield-refresh.
CLEAR zlifnr.
ENDCASE.
WHEN 'ALL'.
PERFORM select_all.
PERFORM alv_refresh CHANGING selfield-col_stable
selfield-row_stable
selfield-refresh.
WHEN 'UNALL'.
PERFORM cancle_all.
PERFORM alv_refresh CHANGING selfield-col_stable
selfield-row_stable
selfield-refresh.
ENDCASE.
is_stable-row = 'X'.
is_stable-col = 'X'.
CALL METHOD l_grid->refresh_table_display
EXPORTING
is_stable = is_stable
* i_soft_refresh = ''
EXCEPTIONS
finished = 1
OTHERS = 2.
05-23-2016 8:54 AM
The sorting of ALV table affects the order of the internal table lines.
That's how it works.
If you want to know the initial order, then you have to add an additional tehnical field (hidden, TECH='X' in field catalog) in your internal table, containing the initial order.
This way you may reorder the lines of the internal table when the ALV is closed.