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

alv and refresh

Former Member
0 Likes
1,463

Hy yall,

in my alv i make a call transaction, when u r in the transaction the back button works correctly and you are send back in the screen (alv) from where you were coming from.

WHEN '&IC1'.
      IF ps_selfield-fieldname = 'LF_QMNUM'.
*     Read data table
        READ TABLE tb_alv INTO wa_output INDEX ps_selfield-tabindex.

        SET PARAMETER ID 'IQM' FIELD wa_output-lf_qmnum.
        CALL TRANSACTION 'IW53' AND SKIP FIRST SCREEN.
      ENDIF.

the trouble start when i add a refresh button.

the call transaction is working well but when u back u r not in the screen you left (you have all the result instead of have the result you had after your select option.

that the code for the refresh

*    WHEN '&REFRESH'.
*      DATA i_rsparams LIKE rsparams OCCURS 0.
*
**      CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
**      EXPORTING
**      curr_report = 'ZPM_VISUALIZZA_AVVISI'
** IMPORTING
* SP =
*      TABLES
*      selection_table = i_rsparams
*      EXCEPTIONS
*      not_found = 1
*      no_report = 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.

  endcase.
*  SUBMIT zpm_visualizza_avvisi WITH SELECTION-TABLE i_rsparams.
*  ps_selfield-refresh = 'X'.

how can i modify my code in other to allow to back to the the screen i was be4 the call transaction?

thanx

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,333

Hi

Try this progrm u'll get an idea on refresh,

REPORT z_alv_auto_refresh.

>********************************************************************

  • This report displays User's info (SM04) using the FM : *

  • REUSE_ALV_LIST_DISPLAY *

  • The list is auto-refreshed (refresh time : 5 seconds) *

----


TYPE-POOLS: slis. " ALV Global Types

DATA :

gt_user LIKE uinfo OCCURS 0 WITH HEADER LINE. " User info in SM04

----


START-OF-SELECTION.

PERFORM f_read_data.

PERFORM f_display_data.

----


  • Form F_LIRE_DATA

----


FORM f_read_data.

REFRESH gt_user.

  • Get User's info

CALL FUNCTION 'THUSRINFO'

TABLES

usr_tabl = gt_user.

  • Wait in a task

PERFORM f_call_rfc_wait.

ENDFORM. " F_READ_DATA

----


  • Form F_DISPLAY_DATA

----


FORM f_display_data.

DEFINE m_sort.

add 1 to ls_sort-spos.

ls_sort-fieldname = &1.

append ls_sort to lt_sort.

END-OF-DEFINITION.

DEFINE m_event_exit.

clear ls_event_exit.

ls_event_exit-ucomm = &1.

ls_event_exit-after = 'X'.

append ls_event_exit to lt_event_exit.

END-OF-DEFINITION.

DATA :

ls_layout TYPE slis_layout_alv,

lt_sort TYPE slis_t_sortinfo_alv,

ls_sort TYPE slis_sortinfo_alv,

lt_event_exit TYPE slis_t_event_exit,

ls_event_exit TYPE slis_event_exit.

  • Build Sort Table

m_sort 'ZEIT'.

  • Build Event Exit Table

m_event_exit '&NTE'. " Refresh

ls_layout-zebra = 'X'.

ls_layout-colwidth_optimize = 'X'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = sy-cprog

i_callback_user_command = 'USER_COMMAND'

is_layout = ls_layout

i_structure_name = 'UINFO'

it_sort = lt_sort

it_event_exit = lt_event_exit

TABLES

t_outtab = gt_user.

ENDFORM. " F_DISPLAY_DATA

----


  • FORM USER_COMMAND *

----


FORM user_command USING i_ucomm TYPE syucomm

is_selfield TYPE slis_selfield. "#EC CALLED

CASE i_ucomm.

WHEN '&NTE'.

PERFORM f_read_data.

is_selfield-refresh = 'X'.

SET USER-COMMAND '&OPT'. " Optimize columns width

ENDCASE.

ENDFORM. " USER_COMMAND

----


  • Form F_CALL_RFC_WAIT

----


FORM f_call_rfc_wait.

DATA lv_mssg(80). "#EC NEEDED

  • Wait in a task

CALL FUNCTION 'RFC_PING_AND_WAIT' STARTING NEW TASK '001'

PERFORMING f_task_end ON END OF TASK

EXPORTING

seconds = 5 " Refresh time

busy_waiting = space

EXCEPTIONS

RESOURCE_FAILURE = 1

communication_failure = 2 MESSAGE lv_mssg

system_failure = 3 MESSAGE lv_mssg

OTHERS = 4.

ENDFORM. " F_CALL_RFC_WAIT

----


  • Form F_TASK_END

----


FORM f_task_end USING u_taskname.

DATA lv_mssg(80). "#EC NEEDED

  • Receiving task results

RECEIVE RESULTS FROM FUNCTION 'RFC_PING_AND_WAIT'

EXCEPTIONS

RESOURCE_FAILURE = 1

communication_failure = 2 MESSAGE lv_mssg

system_failure = 3 MESSAGE lv_mssg

OTHERS = 4.

CHECK sy-subrc EQ 0.

SET USER-COMMAND '&NTE'. " Refresh

ENDFORM. " F_TASK_END

Regards,

Rohini.

Kindly reward if helpful

Hi

Try this progrm u'll get an idea on refresh,

REPORT z_alv_auto_refresh.

>********************************************************************

  • This report displays User's info (SM04) using the FM : *

  • REUSE_ALV_LIST_DISPLAY *

  • The list is auto-refreshed (refresh time : 5 seconds) *

----


TYPE-POOLS: slis. " ALV Global Types

DATA :

gt_user LIKE uinfo OCCURS 0 WITH HEADER LINE. " User info in SM04

----


START-OF-SELECTION.

PERFORM f_read_data.

PERFORM f_display_data.

----


  • Form F_LIRE_DATA

----


FORM f_read_data.

REFRESH gt_user.

  • Get User's info

CALL FUNCTION 'THUSRINFO'

TABLES

usr_tabl = gt_user.

  • Wait in a task

PERFORM f_call_rfc_wait.

ENDFORM. " F_READ_DATA

----


  • Form F_DISPLAY_DATA

----


FORM f_display_data.

DEFINE m_sort.

add 1 to ls_sort-spos.

ls_sort-fieldname = &1.

append ls_sort to lt_sort.

END-OF-DEFINITION.

DEFINE m_event_exit.

clear ls_event_exit.

ls_event_exit-ucomm = &1.

ls_event_exit-after = 'X'.

append ls_event_exit to lt_event_exit.

END-OF-DEFINITION.

DATA :

ls_layout TYPE slis_layout_alv,

lt_sort TYPE slis_t_sortinfo_alv,

ls_sort TYPE slis_sortinfo_alv,

lt_event_exit TYPE slis_t_event_exit,

ls_event_exit TYPE slis_event_exit.

  • Build Sort Table

m_sort 'ZEIT'.

  • Build Event Exit Table

m_event_exit '&NTE'. " Refresh

ls_layout-zebra = 'X'.

ls_layout-colwidth_optimize = 'X'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = sy-cprog

i_callback_user_command = 'USER_COMMAND'

is_layout = ls_layout

i_structure_name = 'UINFO'

it_sort = lt_sort

it_event_exit = lt_event_exit

TABLES

t_outtab = gt_user.

ENDFORM. " F_DISPLAY_DATA

----


  • FORM USER_COMMAND *

----


FORM user_command USING i_ucomm TYPE syucomm

is_selfield TYPE slis_selfield. "#EC CALLED

CASE i_ucomm.

WHEN '&NTE'.

PERFORM f_read_data.

is_selfield-refresh = 'X'.

SET USER-COMMAND '&OPT'. " Optimize columns width

ENDCASE.

ENDFORM. " USER_COMMAND

----


  • Form F_CALL_RFC_WAIT

----


FORM f_call_rfc_wait.

DATA lv_mssg(80). "#EC NEEDED

  • Wait in a task

CALL FUNCTION 'RFC_PING_AND_WAIT' STARTING NEW TASK '001'

PERFORMING f_task_end ON END OF TASK

EXPORTING

seconds = 5 " Refresh time

busy_waiting = space

EXCEPTIONS

RESOURCE_FAILURE = 1

communication_failure = 2 MESSAGE lv_mssg

system_failure = 3 MESSAGE lv_mssg

OTHERS = 4.

ENDFORM. " F_CALL_RFC_WAIT

----


  • Form F_TASK_END

----


FORM f_task_end USING u_taskname.

DATA lv_mssg(80). "#EC NEEDED

  • Receiving task results

RECEIVE RESULTS FROM FUNCTION 'RFC_PING_AND_WAIT'

EXCEPTIONS

RESOURCE_FAILURE = 1

communication_failure = 2 MESSAGE lv_mssg

system_failure = 3 MESSAGE lv_mssg

OTHERS = 4.

CHECK sy-subrc EQ 0.

SET USER-COMMAND '&NTE'. " Refresh

ENDFORM. " F_TASK_END

Regards,

Rohini.

Kindly reward if helpful

8 REPLIES 8
Read only

Former Member
0 Likes
1,334

Hi

Try this progrm u'll get an idea on refresh,

REPORT z_alv_auto_refresh.

>********************************************************************

  • This report displays User's info (SM04) using the FM : *

  • REUSE_ALV_LIST_DISPLAY *

  • The list is auto-refreshed (refresh time : 5 seconds) *

----


TYPE-POOLS: slis. " ALV Global Types

DATA :

gt_user LIKE uinfo OCCURS 0 WITH HEADER LINE. " User info in SM04

----


START-OF-SELECTION.

PERFORM f_read_data.

PERFORM f_display_data.

----


  • Form F_LIRE_DATA

----


FORM f_read_data.

REFRESH gt_user.

  • Get User's info

CALL FUNCTION 'THUSRINFO'

TABLES

usr_tabl = gt_user.

  • Wait in a task

PERFORM f_call_rfc_wait.

ENDFORM. " F_READ_DATA

----


  • Form F_DISPLAY_DATA

----


FORM f_display_data.

DEFINE m_sort.

add 1 to ls_sort-spos.

ls_sort-fieldname = &1.

append ls_sort to lt_sort.

END-OF-DEFINITION.

DEFINE m_event_exit.

clear ls_event_exit.

ls_event_exit-ucomm = &1.

ls_event_exit-after = 'X'.

append ls_event_exit to lt_event_exit.

END-OF-DEFINITION.

DATA :

ls_layout TYPE slis_layout_alv,

lt_sort TYPE slis_t_sortinfo_alv,

ls_sort TYPE slis_sortinfo_alv,

lt_event_exit TYPE slis_t_event_exit,

ls_event_exit TYPE slis_event_exit.

  • Build Sort Table

m_sort 'ZEIT'.

  • Build Event Exit Table

m_event_exit '&NTE'. " Refresh

ls_layout-zebra = 'X'.

ls_layout-colwidth_optimize = 'X'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = sy-cprog

i_callback_user_command = 'USER_COMMAND'

is_layout = ls_layout

i_structure_name = 'UINFO'

it_sort = lt_sort

it_event_exit = lt_event_exit

TABLES

t_outtab = gt_user.

ENDFORM. " F_DISPLAY_DATA

----


  • FORM USER_COMMAND *

----


FORM user_command USING i_ucomm TYPE syucomm

is_selfield TYPE slis_selfield. "#EC CALLED

CASE i_ucomm.

WHEN '&NTE'.

PERFORM f_read_data.

is_selfield-refresh = 'X'.

SET USER-COMMAND '&OPT'. " Optimize columns width

ENDCASE.

ENDFORM. " USER_COMMAND

----


  • Form F_CALL_RFC_WAIT

----


FORM f_call_rfc_wait.

DATA lv_mssg(80). "#EC NEEDED

  • Wait in a task

CALL FUNCTION 'RFC_PING_AND_WAIT' STARTING NEW TASK '001'

PERFORMING f_task_end ON END OF TASK

EXPORTING

seconds = 5 " Refresh time

busy_waiting = space

EXCEPTIONS

RESOURCE_FAILURE = 1

communication_failure = 2 MESSAGE lv_mssg

system_failure = 3 MESSAGE lv_mssg

OTHERS = 4.

ENDFORM. " F_CALL_RFC_WAIT

----


  • Form F_TASK_END

----


FORM f_task_end USING u_taskname.

DATA lv_mssg(80). "#EC NEEDED

  • Receiving task results

RECEIVE RESULTS FROM FUNCTION 'RFC_PING_AND_WAIT'

EXCEPTIONS

RESOURCE_FAILURE = 1

communication_failure = 2 MESSAGE lv_mssg

system_failure = 3 MESSAGE lv_mssg

OTHERS = 4.

CHECK sy-subrc EQ 0.

SET USER-COMMAND '&NTE'. " Refresh

ENDFORM. " F_TASK_END

Regards,

Rohini.

Kindly reward if helpful

Read only

0 Likes
1,333

i'm on the way but it's not excactely what i'm trying to do. i don't need an automatic refresh. Only decide by the user.

My problem is that without the refresh button, i can call the transaction and back to screen, but with the refresh button active no. when i try to come back to the screen, the is refresh. i don't need the screen to be refresh when i come back from the transaction 'iw53'. I don't know i'm a little bit clearer

Read only

0 Likes
1,333

Hi,

Can you re-submit the exact full code that generate your problem (without comment signs)? Thanks

Jeffrey Satriadi

Read only

0 Likes
1,333

that the original code i use

CASE pw_ucomm.
    WHEN '&IC1'.
      IF ps_selfield-fieldname = 'LF_QMNUM'.
*     Read data table
        READ TABLE tb_alv INTO wa_output INDEX ps_selfield-tabindex.

        SET PARAMETER ID 'IQM' FIELD wa_output-lf_qmnum.
        CALL TRANSACTION 'IW53' AND SKIP FIRST SCREEN.
      ENDIF.

    WHEN '&REFRESH'.
      DATA i_rsparams LIKE rsparams OCCURS 0.

      CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
      EXPORTING
      curr_report = 'ZPM_VISUALIZZA_AVVISI'
 IMPORTING
 SP =
      TABLES
      selection_table = i_rsparams
      EXCEPTIONS
      not_found = 1
      no_report = 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.

  ENDCASE.
  SUBMIT zpm_visualizza_avvisi WITH SELECTION-TABLE i_rsparams.
  ps_selfield-refresh = 'X'.
ENDFORM.

in that way, when i come back from the transaction instead of set the screen i was before the transaction, that screen has been refresh. Without the code part of the refresh button i can call the transaction and back without trouble. Am i clear enough?

Read only

0 Likes
1,333

Hi,

After reading your code, I am sure the statements after WHEN '&REFRESH' will not be executed after the calling of IW53. But the following SUBMIT will be executed. Do you really need to do it? If you do not need it delete this lines, and I am sure you will be back to your last list after calling IW53.

SUBMIT zpm_visualizza_avvisi WITH SELECTION-TABLE i_rsparams.

ps_selfield-refresh = 'X'.

Jeffrey Satriadi

Edited by: UNISUP Indonesia PROJECT TEAM on Feb 27, 2008 1:17 AM

Read only

0 Likes
1,333

After re-reading your code, I think you should put the ENDCASE statement after this SUBMIT statement.

    • ENDCASE. "Delete*

SUBMIT zpm_visualizza_avvisi WITH SELECTION-TABLE i_rsparams.

ps_selfield-refresh = 'X'.

ENDCASE. "Insert here!

That should solve your problem.

Jeffrey Satriadi

Read only

Former Member
0 Likes
1,333

Hi

If you are using alv in OO context, then you can do the follwoing for refresh:

WHEN '&REFRESH'.

CALL METHOD gv_alv_grid->refresh_table_display.

(where gv_alv_grid TYPE REF TO cl_gui_alv_grid).

Thanks

VIjay

PLZ reward points if helpful

Read only

0 Likes
1,333

no i'm unsing a classic reuse_alv_grid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = 'ZPM_VISUALIZZA_AVVISI'
      i_structure_name         = 'st_alv'
      i_grid_title             = 'Situazione avvisi'
      is_layout                = layout
      i_callback_user_command  = 'USER_COMMAND'
      i_callback_pf_status_set = 'STANDARD_FULLSCREEN'
      it_fieldcat              = l_t_fieldcat
      is_variant               = lt_variant
      it_events                = er_events[]
      is_print                 = print
      i_save                   = 'A'
    TABLES
      t_outtab                 = tb_alv.

is it better using ALV in OO context? what can be the advantage ( as u understand i'm a newby...)