Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Refresh the alv

Former Member
0 Likes
983

Iam initially retrieving data from the custom table and then displaying it on one screen.

for creating new data i move to other screen, after i create the data i need to append the same to cutsom table and come back to initial screen to display the cutsiom table data.

the alv grid continues to display the old data ,

I have tried using refresh table display but it is not working.

please give some suggestion.

Iam initially retrieving data from the custom table and then displaying it on one screen.

for creating new data i move to other screen, after i create the data i need to append the same to cutsom table and come back to initial screen to display the cutsiom table data.

the alv grid continues to display the old data ,

I have tried using refresh table display but it is not working.

please give some suggestion.

5 REPLIES 5
Read only

Former Member
0 Likes
842

Hi Saurabh,

After updating the custom table, Use

LEAVE TO TRANSACTION 'ZSTART'.

Here, ZSTART is the transaction name assigned to your program.

Regards,

Pooja.

Read only

p291102
Active Contributor
0 Likes
842

Hi,

Following report is the sample report for 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

Read only

Former Member
0 Likes
842

Hi,

See the below code..

START-OF-SELECTION.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = ws_repid

i_callback_pf_status_set = 'GUI_STAT'

i_callback_user_command = 'STAT'

is_layout = gs_layout

it_fieldcat = i_fieldcat[]

TABLES

t_outtab = i_zaw_pol_plan.

IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

FORM stat USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.

DATA selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN 'BACK' .

SELECT * FROM zaw_pol_plan

INTO CORRESPONDING FIELDS OF TABLE i_zaw_pol_plan

WHERE zzvendor IN s_idn AND

post_code1 IN s_pcode AND

outcode IN s_ocode AND

district IN s_dist AND

date1 IN s_date AND

typbz IN s_mttype AND

no_jobs_pro IN s_jobs.

DATA ref1 TYPE REF TO cl_gui_alv_grid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = ref1.

CALL METHOD ref1->check_changed_data.

CALL METHOD ref1->refresh_table_display.

ENDCASE.

AT SELECTION-SCREEN.

You save your new data in customized table here.

NOTE:

Above "zaw_pol_plan" your customized table

"i_zaw_pol_plan" This is your internal table in which you are passing the data.

Pls. reward if useful....

Read only

Former Member
0 Likes
842

Hi,

To refresh the ALV: In the user command form for the back button (sy-ucomm = BACK), put a select statement on the custom table and get the data in the internal table used for ALV display and then use

rs_selfield-refresh = X to refresh the display with the new data.

Thank you.

Reward points if found useful.

Read only

Former Member
0 Likes
842

Hi,

Try using

DATA ref1 TYPE REF TO cl_gui_alv_grid.

CASE ucomm.

WHEN '&UPD'.

CALL fuNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = ref1.

CALL METHOD ref1->check_changed_data.

will update the screen