‎2007 Apr 09 11:31 AM
Hi All,
I have a GRID ALV displayed. From the ALV the user can select a ROW and perform a few functions . The Functions include UPDATES using BDC and BAPI. The Meesages from the fucntions are displayed on a separate screen using LEAVE to List Processing.
The PF-status of the this List Processing Screen has a BACK button.
My requirement is that I need to REFRESH the GRID ALV when user presses the BACK button on the LIST DISPLAY .
I have tried SELFIELD-REFRESH = 'X '. In USer Command. But it dosent work.
PLease Advice .
Thanks.
‎2007 Apr 09 11:45 AM
Hi..,
JUst copy and execute this sample program...
type-pools : slis.
Data declarations for work areas ....
data begin of fs_spfli.
data check type c.
data color(4) type c.
include type spfli.
data end of fs_spfli.
data begin of fs_sflight.
data check type c.
data color(4) type c.
include type sflight.
data end of fs_sflight.
data :
fs_sbook type sbook.
data:
fs_layout type slis_layout_alv,
w_prog type sy-repid value sy-repid,
w_event type slis_alv_event,
w_status type i.
Declaration of internal tables...
data :
t_spfli like standard table
of fs_spfli
initial size 0,
t_sflight like standard table
of fs_sflight
initial size 0,
t_sbook like standard table
of fs_sbook
initial size 0,
t_events type slis_t_event.
"----
START OF SELECTION EVENT *
"----
start-of-selection.
perform display_spfli.
&----
*& Form status_set1
&----
This subroutine sets the pf-status for the list *
----
-> lt_extab excluding table *
----
form status_set1 using lt_extab type slis_t_extab.
data : lw_fcode type slis_extab.
lw_fcode-fcode = 'SBOOK'.
append lw_fcode to lt_extab.
set pf-status 'ALV' excluding lt_extab.
clear lt_extab.
endform. " Form status_set1
&----
*& Form status_set2
&----
This subroutine sets the pf-status for the list *
----
-> lt_extab excluding table *
----
form status_set2 using lt_extab type slis_t_extab.
data : lw_fcode type slis_extab.
lw_fcode-fcode = 'SFLIGHT'.
append lw_fcode to lt_extab.
set pf-status 'ALV' excluding lt_extab.
clear lt_extab.
endform. " Form status_set2
&----
*& Form header *
&----
form header.
write : 'Flights Information'.
endform.
&----
*& Form code_for_fcs
&----
This subroutine displays the Sflight data for selected spfli data *
----
->PR_UCOMM function code *
->PR_SELFIELD
----
form code_for_fcs using pr_ucomm type sy-ucomm
pr_selfield type slis_selfield.
data:
lt_spfli like t_spfli,
lt_sflight like t_sflight.
<b> pr_selfield-refresh = 'X'.</b>
case pr_ucomm.
when 'SFLIGHT'.
loop at t_spfli into fs_spfli where check eq 'X'.
fs_spfli-check = '0'.
fs_spfli-color = 'C210'.
modify t_spfli from fs_spfli index sy-tabix
transporting color check.
append fs_spfli to lt_spfli.
endloop.
if sy-subrc ne 0.
message e028(yh640).
endif.
perform retrieve_sflight using pr_selfield
lt_spfli.
when 'SBOOK'.
loop at t_sflight into fs_sflight where check eq 'X'.
fs_sflight-check = '0'.
fs_sflight-color = 'C210'.
modify t_sflight from fs_sflight index sy-tabix
transporting color check.
append fs_sflight to lt_sflight.
endloop.
if sy-subrc ne 0.
message e028(yh640).
endif.
perform retieve_sbook using pr_selfield lt_sflight.
endcase. " Case pr_ucomm.
endform.
&----
*& Form retrieve_sflight
&----
This subroutine displays the Sflight data for selected spfli data *
----
->PR_SELFIELD contents of the selected row. *
----
form retrieve_sflight using pr_selfield type slis_selfield
lt_spfli like t_spfli.
select *
from sflight
into corresponding fields of table t_sflight
for all entries in lt_spfli
where carrid eq lt_spfli-carrid
and connid eq lt_spfli-connid.
if sy-subrc eq 0.
perform display_sflight.
else.
message e020(yh640).
endif. " If sy-subrc eq 0.
clear lt_spfli.
endform. " Form retrieve_sflight
&----
*& Form display_sflight
&----
This subroutine displays sflight data *
----
There are no interface parameters for this subroutine *
----
form display_sflight.
call function 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_PROG
I_CALLBACK_PF_STATUS_SET = 'STATUS_SET2'
I_STRUCTURE_NAME = 'SFLIGHT'
IS_LAYOUT = FS_LAYOUT
IT_EVENTS = t_events
tables
t_outtab = t_sflight
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
if sy-subrc <> 0.
message e020(yh640).
endif.
endform. " Form display_sflight
&----
*& Form retieve_sbook
&----
This subroutine displays sflight data *
----
->PR_SELFIELD contents of the selected records *
----
form retieve_sbook using pr_selfield type slis_selfield
lt_sflight like t_sflight.
select *
from sbook
into corresponding fields of table t_sbook
for all entries in lt_sflight
where carrid eq lt_sflight-carrid
and connid eq lt_sflight-connid
and fldate eq lt_sflight-fldate.
if sy-subrc eq 0.
perform display_sbook.
else.
message e020(yh640).
endif. " If sy-subrc eq 0.
clear lt_sflight.
endform. " Form retieve_sbook
&----
*& Form display_sbook
&----
text
----
There are no interface parameters for this subroutine *
----
form display_sbook .
call function 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'SBOOK'
tables
t_outtab = t_sbook
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
if sy-subrc <> 0.
message e020(yh640).
endif.
endform. " display_sbook
&----
*& Form display_spfli
&----
text
----
There are no interface parameters for this subroutine *
----
form display_spfli.
Selecting the spfli data....
select *
from spfli
into corresponding fields of table t_spfli.
fs_layout-box_fieldname = 'CHECK'.
fs_layout-info_fieldname = 'COLOR'.
Populating the events table...
w_event-name = 'TOP_OF_PAGE'.
w_event-form = 'HEADER'.
append w_event to t_events.
w_event-name = 'USER_COMMAND'.
w_event-form = 'CODE_FOR_FCS'.
append w_event to t_events.
call function 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_PROG
I_CALLBACK_PF_STATUS_SET = 'STATUS_SET1'
I_STRUCTURE_NAME = 'SPFLI'
IS_LAYOUT = FS_LAYOUT
IT_EVENTS = T_EVENTS
tables
t_outtab = T_SPFLI
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
if sy-subrc <> 0.
message e020(yh640).
endif.
<b>reward if it helps u..
sai ramesh</b>
‎2007 Apr 09 11:42 AM
hi
try 2 use this method: refresh_table_display
CALL METHOD g_alv_grid1->refresh_table_display.
lemme no if u stil need some help.
kiran
‎2007 Apr 09 11:43 AM
Hi,
SELFIELD-REFRESH = 'X ' will work fine. Just check that You internal table is updated or not before you process this statement. It works only if any things update is reflected to your internal table. It won't update inernal table automatically. So Please update your internal table manuallly. Once you update it then you this statement will work otherwise you can't see any changes.
I hope i made you clear.
Warm Regards,
Vijay.
‎2007 Apr 09 11:45 AM
Hi..,
JUst copy and execute this sample program...
type-pools : slis.
Data declarations for work areas ....
data begin of fs_spfli.
data check type c.
data color(4) type c.
include type spfli.
data end of fs_spfli.
data begin of fs_sflight.
data check type c.
data color(4) type c.
include type sflight.
data end of fs_sflight.
data :
fs_sbook type sbook.
data:
fs_layout type slis_layout_alv,
w_prog type sy-repid value sy-repid,
w_event type slis_alv_event,
w_status type i.
Declaration of internal tables...
data :
t_spfli like standard table
of fs_spfli
initial size 0,
t_sflight like standard table
of fs_sflight
initial size 0,
t_sbook like standard table
of fs_sbook
initial size 0,
t_events type slis_t_event.
"----
START OF SELECTION EVENT *
"----
start-of-selection.
perform display_spfli.
&----
*& Form status_set1
&----
This subroutine sets the pf-status for the list *
----
-> lt_extab excluding table *
----
form status_set1 using lt_extab type slis_t_extab.
data : lw_fcode type slis_extab.
lw_fcode-fcode = 'SBOOK'.
append lw_fcode to lt_extab.
set pf-status 'ALV' excluding lt_extab.
clear lt_extab.
endform. " Form status_set1
&----
*& Form status_set2
&----
This subroutine sets the pf-status for the list *
----
-> lt_extab excluding table *
----
form status_set2 using lt_extab type slis_t_extab.
data : lw_fcode type slis_extab.
lw_fcode-fcode = 'SFLIGHT'.
append lw_fcode to lt_extab.
set pf-status 'ALV' excluding lt_extab.
clear lt_extab.
endform. " Form status_set2
&----
*& Form header *
&----
form header.
write : 'Flights Information'.
endform.
&----
*& Form code_for_fcs
&----
This subroutine displays the Sflight data for selected spfli data *
----
->PR_UCOMM function code *
->PR_SELFIELD
----
form code_for_fcs using pr_ucomm type sy-ucomm
pr_selfield type slis_selfield.
data:
lt_spfli like t_spfli,
lt_sflight like t_sflight.
<b> pr_selfield-refresh = 'X'.</b>
case pr_ucomm.
when 'SFLIGHT'.
loop at t_spfli into fs_spfli where check eq 'X'.
fs_spfli-check = '0'.
fs_spfli-color = 'C210'.
modify t_spfli from fs_spfli index sy-tabix
transporting color check.
append fs_spfli to lt_spfli.
endloop.
if sy-subrc ne 0.
message e028(yh640).
endif.
perform retrieve_sflight using pr_selfield
lt_spfli.
when 'SBOOK'.
loop at t_sflight into fs_sflight where check eq 'X'.
fs_sflight-check = '0'.
fs_sflight-color = 'C210'.
modify t_sflight from fs_sflight index sy-tabix
transporting color check.
append fs_sflight to lt_sflight.
endloop.
if sy-subrc ne 0.
message e028(yh640).
endif.
perform retieve_sbook using pr_selfield lt_sflight.
endcase. " Case pr_ucomm.
endform.
&----
*& Form retrieve_sflight
&----
This subroutine displays the Sflight data for selected spfli data *
----
->PR_SELFIELD contents of the selected row. *
----
form retrieve_sflight using pr_selfield type slis_selfield
lt_spfli like t_spfli.
select *
from sflight
into corresponding fields of table t_sflight
for all entries in lt_spfli
where carrid eq lt_spfli-carrid
and connid eq lt_spfli-connid.
if sy-subrc eq 0.
perform display_sflight.
else.
message e020(yh640).
endif. " If sy-subrc eq 0.
clear lt_spfli.
endform. " Form retrieve_sflight
&----
*& Form display_sflight
&----
This subroutine displays sflight data *
----
There are no interface parameters for this subroutine *
----
form display_sflight.
call function 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_PROG
I_CALLBACK_PF_STATUS_SET = 'STATUS_SET2'
I_STRUCTURE_NAME = 'SFLIGHT'
IS_LAYOUT = FS_LAYOUT
IT_EVENTS = t_events
tables
t_outtab = t_sflight
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
if sy-subrc <> 0.
message e020(yh640).
endif.
endform. " Form display_sflight
&----
*& Form retieve_sbook
&----
This subroutine displays sflight data *
----
->PR_SELFIELD contents of the selected records *
----
form retieve_sbook using pr_selfield type slis_selfield
lt_sflight like t_sflight.
select *
from sbook
into corresponding fields of table t_sbook
for all entries in lt_sflight
where carrid eq lt_sflight-carrid
and connid eq lt_sflight-connid
and fldate eq lt_sflight-fldate.
if sy-subrc eq 0.
perform display_sbook.
else.
message e020(yh640).
endif. " If sy-subrc eq 0.
clear lt_sflight.
endform. " Form retieve_sbook
&----
*& Form display_sbook
&----
text
----
There are no interface parameters for this subroutine *
----
form display_sbook .
call function 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'SBOOK'
tables
t_outtab = t_sbook
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
if sy-subrc <> 0.
message e020(yh640).
endif.
endform. " display_sbook
&----
*& Form display_spfli
&----
text
----
There are no interface parameters for this subroutine *
----
form display_spfli.
Selecting the spfli data....
select *
from spfli
into corresponding fields of table t_spfli.
fs_layout-box_fieldname = 'CHECK'.
fs_layout-info_fieldname = 'COLOR'.
Populating the events table...
w_event-name = 'TOP_OF_PAGE'.
w_event-form = 'HEADER'.
append w_event to t_events.
w_event-name = 'USER_COMMAND'.
w_event-form = 'CODE_FOR_FCS'.
append w_event to t_events.
call function 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_PROG
I_CALLBACK_PF_STATUS_SET = 'STATUS_SET1'
I_STRUCTURE_NAME = 'SPFLI'
IS_LAYOUT = FS_LAYOUT
IT_EVENTS = T_EVENTS
tables
t_outtab = T_SPFLI
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
if sy-subrc <> 0.
message e020(yh640).
endif.
<b>reward if it helps u..
sai ramesh</b>
‎2007 Apr 09 11:50 AM
Hi,
After doing selfield-refresh = 'X', you have to modify the internal output table passed to FM 'REUSE_ALV_GRID_DISPLAY' with the new values.
Reward all useful answers.
Thank you.
‎2007 Apr 09 12:06 PM
Hi,
in the okcode of refresh button
fill the itab data again(which is modified)and then callthe below method.
CALL METHOD g_alv_grid1->refresh_table_display.
regard,
bharat.