2007 Nov 22 11:33 PM
Hi All..
I have a problem with my ALV refresh in that when I come back to my ALV Grid it is doing the refresh but keeps going back to the first row of my ALV Grid rather than the edited record. I have tried this code but it is not working.. please help:
STEP 1: Get the scroll position with FM... put into E_GRID_SCROLL
CASE L_UCOMM.
WHEN OTHERS.
CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
IMPORTING
ES_GRID_SCROLL = E_GRID_SCROLL
EXCEPTIONS
NO_INFOS = 1
PROGRAM_ERROR = 2
OTHERS = 3.
Step 2: Call transaction and update record that has been changed
Call ZDOC2.
*make changes in ZDOC2.
*My refresh table is set to execute when I come back to my report
PERFORM REFRESH_TABLE.
MODIFY Itab...
Step 3: Set the scroll position from E_GRID_SCROLL...
CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_SET'
EXPORTING
IS_GRID_SCROLL = E_GRID_SCROLL.
Step 4: Set flags for refresh
LS_SELFIELD-REFRESH = 'X'.
LS_SELFIELD-ROW_STABLE = 'X'.
Step 5: Output List Viewer
PERFORM OUTPUT_ALV.
This still doesn't work!!! I get no errors and E_GRID_SCROLL is populated with the row index... I get SY-SUBRC = 0 after each FM. Yet my ALV still resets to first record each time I go back. What am I missing?
2007 Dec 19 3:32 PM
Hi Brad,
I had the same problem than you.
I added a "Refresh"-Button in the Gui-Status.
Every time I pressed this button, the system turned back to the first row of my ALV.
I solved this in the following way:
Wenn I press "Refresh"-Button the system populates the refresh.
I call the FM REUSE_ALV_GRID_DISPLAY like this:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = s_layout
it_fieldcat = int_fcat
it_sort = int_sortcat
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'STANDARD_SET'
i_save = 'A'
TABLES
t_outtab = i_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_GRID_DISPLAY'.
ENDIF.
The form USER_COMMAND looks like this:
----
FORM user_command
----
--> UCOMM *
--> SELFIELD *
----
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
IF ucomm = 'AKTU'.
perform aktualisieren.
"Grid refresh:
selfield-refresh = 'X'.
selfield-col_stable = 'X'.
selfield-row_stable = 'X'.
ENDIF.
Now, after the refresh, the ALV stays in the edited record.
I hope, this can help you, to solve your problem.
Greetings, Reiner.
Hi All..
I have a problem with my ALV refresh in that when I come back to my ALV Grid it is doing the refresh but keeps going back to the first row of my ALV Grid rather than the edited record. I have tried this code but it is not working.. please help:
STEP 1: Get the scroll position with FM... put into E_GRID_SCROLL
CASE L_UCOMM.
WHEN OTHERS.
CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
IMPORTING
ES_GRID_SCROLL = E_GRID_SCROLL
EXCEPTIONS
NO_INFOS = 1
PROGRAM_ERROR = 2
OTHERS = 3.
Step 2: Call transaction and update record that has been changed
Call ZDOC2.
*make changes in ZDOC2.
*My refresh table is set to execute when I come back to my report
PERFORM REFRESH_TABLE.
MODIFY Itab...
Step 3: Set the scroll position from E_GRID_SCROLL...
CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_SET'
EXPORTING
IS_GRID_SCROLL = E_GRID_SCROLL.
Step 4: Set flags for refresh
LS_SELFIELD-REFRESH = 'X'.
LS_SELFIELD-ROW_STABLE = 'X'.
Step 5: Output List Viewer
PERFORM OUTPUT_ALV.
This still doesn't work!!! I get no errors and E_GRID_SCROLL is populated with the row index... I get SY-SUBRC = 0 after each FM. Yet my ALV still resets to first record each time I go back. What am I missing?
2007 Nov 23 3:46 AM
Hi,
Following report will explain the sample refresh alv report.
REPORT YMS_REFRESHALV .
TABLES :T247.
TYPE-POOLS SLIS. "Type definitions for alv report
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
WA_FIELDCAT TYPE LVC_S_FCAT.
DATA: WA_LAYOUT TYPE LVC_S_LAYO.
DATA : BEGIN OF IT_FINAL OCCURS 0,
CHECK(1),
CELLTAB TYPE LVC_T_STYL, " Switch between display/change
MNR LIKE T247-MNR,
LTX LIKE T247-LTX,
END OF IT_FINAL.
DATA : WA_FINAL LIKE IT_FINAL.
DATA : W_REPID LIKE SY-REPID.
W_REPID = SY-REPID.
REFRESH IT_FINAL.
SELECT MNR LTX
FROM T247
INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
WHERE SPRAS EQ 'E'.
WA_FIELDCAT-FIELDNAME = 'CHECK'.
WA_FIELDCAT-TABNAME = 'IT_FINAL'.
WA_FIELDCAT-CHECKBOX = 'X'.
WA_FIELDCAT-EDIT = 'X'..
WA_FIELDCAT-OUTPUTLEN = '3'.
WA_FIELDCAT-COL_POS = '1'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'MNR'.
WA_FIELDCAT-TABNAME = 'IT_FINAL'.
WA_FIELDCAT-OUTPUTLEN = '8'.
WA_FIELDCAT-COL_POS = '2'.
WA_FIELDCAT-REPTEXT = 'Month'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'LTX'.
WA_FIELDCAT-TABNAME = 'IT_FINAL'.
WA_FIELDCAT-OUTPUTLEN = '20'.
WA_FIELDCAT-COL_POS = '3'.
WA_FIELDCAT-REPTEXT = 'Month Desc'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
DATA: WA_CELLTAB TYPE LVC_S_STYL,
IT_CELLTAB TYPE LVC_T_STYL,
L_INDEX TYPE I.
CLEAR : WA_CELLTAB,WA_FINAL,IT_CELLTAB.
REFRESH IT_CELLTAB.
*Initialize the celltab table
LOOP AT IT_FINAL INTO WA_FINAL.
L_INDEX = SY-TABIX.
WA_CELLTAB-FIELDNAME = 'CHECK'.
WA_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
INSERT WA_CELLTAB INTO TABLE IT_CELLTAB.
INSERT LINES OF IT_CELLTAB INTO TABLE WA_FINAL-CELLTAB.
MODIFY IT_FINAL FROM WA_FINAL INDEX L_INDEX.
ENDLOOP.
*Make the first five 5 rows as disabled
CLEAR L_INDEX.
LOOP AT IT_FINAL INTO WA_FINAL.
L_INDEX = SY-TABIX.
IF SY-TABIX LE 5.
LOOP AT WA_FINAL-CELLTAB INTO WA_CELLTAB.
IF WA_CELLTAB-FIELDNAME EQ 'CHECK' .
WA_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
MODIFY WA_FINAL-CELLTAB FROM WA_CELLTAB.
MODIFY IT_FINAL INDEX L_INDEX FROM WA_FINAL TRANSPORTING CELLTAB.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
WA_LAYOUT-BOX_FNAME = 'CHECK'.
WA_LAYOUT-NO_ROWMARK = 'X'.
WA_LAYOUT-STYLEFNAME = 'CELLTAB'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = W_REPID
I_GRID_TITLE = 'GRID DISPLAY'
IS_LAYOUT_LVC = WA_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCAT
TABLES
T_OUTTAB = IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
Thanks,
Sankar M
2007 Nov 23 4:37 AM
Dear Brad,
There are 2 things related with ALV table refresh that I found.
First :
definition part . i set the lifetime for the ALV grid object container
CREATE OBJECT g_cconth
EXPORTING
container_name = 'CCONTH'
lifetime = g_cconth->lifetime_dynpro.
CREATE OBJECT grid_pr1
EXPORTING
i_parent = g_cconth .
Second :
coding part. i use the following code when saving
FORM save_pr2.
DATA: l_valid(1) TYPE c.
DATA : tmp_qty like mska-kalab,
tmp_waste like wa_it_pr2-waste1.
CASE ok_code.
WHEN 'SAVE'.
CALL METHOD grid_pr2->check_changed_data
IMPORTING
e_valid = l_valid.
IF l_valid <> 'X'.
EXIT.
ELSE.
CALL METHOD grid_pr2->refresh_table_display.
ENDIF.
I hope that helps.
Rgds,
TS WINEDYA
2007 Nov 25 8:01 PM
Hi
Sorry I should've been more clear, can someone give me an example of a Function Module ALV where it refreshes and when you come back to the ALV screen it has remembered the grid scroll position?
2007 Dec 19 3:32 PM
Hi Brad,
I had the same problem than you.
I added a "Refresh"-Button in the Gui-Status.
Every time I pressed this button, the system turned back to the first row of my ALV.
I solved this in the following way:
Wenn I press "Refresh"-Button the system populates the refresh.
I call the FM REUSE_ALV_GRID_DISPLAY like this:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = s_layout
it_fieldcat = int_fcat
it_sort = int_sortcat
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'STANDARD_SET'
i_save = 'A'
TABLES
t_outtab = i_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_GRID_DISPLAY'.
ENDIF.
The form USER_COMMAND looks like this:
----
FORM user_command
----
--> UCOMM *
--> SELFIELD *
----
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
IF ucomm = 'AKTU'.
perform aktualisieren.
"Grid refresh:
selfield-refresh = 'X'.
selfield-col_stable = 'X'.
selfield-row_stable = 'X'.
ENDIF.
Now, after the refresh, the ALV stays in the edited record.
I hope, this can help you, to solve your problem.
Greetings, Reiner.
2008 Jan 16 4:42 AM
Turned out I was putting the LS_SELFIELD-REFRESH = 'X'.
LS_SELFIELD-ROW_STABLE = 'X'.
in the wrong area of the report