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

Back Button in ALV Grid

Former Member
0 Likes
5,242

Hi Friends,

I am trying to read the data from the ztable that gets updated very frequently by batch jobs and display the output in ALV Format.

I am using the FM 'REUSE_ALV_LIST_DISPLAY' for displaying the output. Now I am trying to provide Refresh button in the Tool bar next to Sort button to see the updated information. I was able to add the refresh button with the Fcode ( &RFO) and using case statement on sy-ucomm  user_command sub routine and calling the subroutines ( fetch --> that fetches the latest data from the table, display_output ( calls the ALV FM to display the output ). Now when I do refresh twice, I am getting the latest data that is present in the table but when I click the back button from the menu bar, it is taking to alv output screen( displayed initially ) instead of selection screen. I need to press twice for getting the selection screen. Incase if I press 'n' times on refresh button, then I need to click 'n' times on Back button to go to Selection screen. I have tried all options like setting

sy-lsind = 0, sy-LISTI = 0,RS_SELFIELD-REFRESH = 'X'.

Any pointers on this will be of great help.

Thanks,

Uday

Hi Friends,

I am trying to read the data from the ztable that gets updated very frequently by batch jobs and display the output in ALV Format.

I am using the FM 'REUSE_ALV_LIST_DISPLAY' for displaying the output. Now I am trying to provide Refresh button in the Tool bar next to Sort button to see the updated information. I was able to add the refresh button with the Fcode ( &RFO) and using case statement on sy-ucomm  user_command sub routine and calling the subroutines ( fetch --> that fetches the latest data from the table, display_output ( calls the ALV FM to display the output ). Now when I do refresh twice, I am getting the latest data that is present in the table but when I click the back button from the menu bar, it is taking to alv output screen( displayed initially ) instead of selection screen. I need to press twice for getting the selection screen. Incase if I press 'n' times on refresh button, then I need to click 'n' times on Back button to go to Selection screen. I have tried all options like setting

sy-lsind = 0, sy-LISTI = 0,RS_SELFIELD-REFRESH = 'X'.

Any pointers on this will be of great help.

Thanks,

Uday

9 REPLIES 9
Read only

Former Member
0 Likes
2,607

Hi

You must try with the custom back button as you are using custom refresh button.

In case of click of back button (custom) route the program to go to selection screen.

Happy coding!!

Sandeep

Read only

Former Member
0 Likes
2,607

Hi,

you can try with the custom back button. Please go through the following code use ful to resolve your problem.

REPORT  ZALV_BACK.

TYPE-POOLS : slis.
TABLES: mara.

DATA : i_fieldcat TYPE TABLE OF slis_fieldcat_alv,
            wa_fieldcat TYPE slis_fieldcat_alv.

Data: it_mara TYPE table of mara,
         wa_mara type mara.

SELECTION-SCREEN BEGIN OF block b1 WITH FRAME TITLE text-001.

PARAMETERS: P_matnr type matnr.

SELECTION-SCREEN end of block b1.

START-OF-selection.

  SELECT * FROM mara into CORRESPONDING FIELDS OF TABLE it_mara up to 10 rows WHERE

    matnr = p_Matnr..

  clear wa_fieldcat.

  wa_fieldcat-fieldname = 'MATNR'.

  wa_fieldcat-outputlen = 18.

  wa_fieldcat-seltext_l = 'material no'.

  wa_fieldcat-col_pos   = 1.

  APPEND wa_fieldcat TO i_fieldcat.

  clear wa_fieldcat.

  wa_fieldcat-fieldname = 'ERSDA'.

  wa_fieldcat-outputlen = 8.

  wa_fieldcat-seltext_l = 'created on'.

  wa_fieldcat-col_pos   = 2.

  wa_fieldcat-edit      = 'X'.

  APPEND wa_fieldcat TO i_fieldcat.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
   EXPORTING
     I_CALLBACK_PROGRAM                = sy-repid
     I_CALLBACK_PF_STATUS_SET          = 'PF_STATUS'
     I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
     IT_FIELDCAT                     = i_fieldcat
    TABLES
      T_OUTTAB                       = it_mara
   EXCEPTIONS
     PROGRAM_ERROR                  = 1
     OTHERS                         = 2
            .
  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  user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->V_UCOMM      text
*      -->WA_SELFIELD  text
*----------------------------------------------------------------------*
FORM user_command USING v_ucomm like sy-ucomm
                        wa_selfield TYPE slis_selfield.
  CASE  sy-ucomm.
    when 'BACK'.
      leave program.
  ENDCASE.

endform.                    "user_command

*&---------------------------------------------------------------------*
*&      Form  pf_status
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->WA_EXTAB   text
*----------------------------------------------------------------------*
FORM pf_status USING wa_extab TYPE slis_t_extab.

  SET PF-STATUS 'ZSTANDARD_FULLSCREEN'.

ENDFORM.                    "pf_status

Read only

0 Likes
2,607

Thanks Naga Lakshmi for the inputs.

Issue got resolved by doing the following

In refresh, we just need to repopulate the data in the internal table and set this variable (rs_selfield-refresh = 'X'.).

We need not call the ALV again.

Read only

Former Member
0 Likes
2,607

Hi Udaya,

When you are using standard back button, it will definitely go to the previous list displayed. So you need to have a custom back button. Use your own PF_STATUS and for Back buton, write the coding as

when sy-ucomm eq "<BACK_OK_CODE>

set screen 0.

Leave Screen.

This statement will take to the selection screen on pressing back button.

Thanks

Sumit

Read only

Former Member
0 Likes
2,607

Hello Uday,

      i think you are calling the ALV FM everytime you click the refresh button, it is not required, just fill the internal table and put i_selfield-refresh = 'X' inside user_command.

Regards

Animesh Sundriyal

Read only

0 Likes
2,607

Thanks so much Animesh. This input helped to resolve the issue.

Read only

Former Member
0 Likes
2,607

try 'leave to screen 0' on your custom back button.

Read only

Former Member
0 Likes
2,607

Thanks everyone for your time and efforts. The issue is resolved with your support.

Read only

0 Likes
2,607

The same problem I am also facing..Udaya Will you please help me out where I have to change my code..

CASE sy-ucomm.

WHEN 'MODIFY'.

       DATA : l_line TYPE i.

       READ TABLE t_zbacklog INTO wa_zbacklog INDEX rs_selfield-tabindex.

       MOVE wa_zbacklog TO zbacklog.

       CALL SCREEN '3100'.

     WHEN 'DELETE'.

       READ TABLE t_zbacklog INTO wa_zbacklog INDEX rs_selfield-tabindex.

       DELETE zbacklog FROM wa_zbacklog.

       IF sy-subrc = 0.

         MESSAGE 'Data Deleted successfully, Please Refresh it' TYPE 'I'.

       ENDIF.

     WHEN 'INSERT'.

       READ TABLE t_zbacklog INTO wa_zbacklog INDEX rs_selfield-tabindex.

       MOVE wa_zbacklog TO zbacklog.

       CALL SCREEN '5000'.

     WHEN 'REFRESH'.

       FREE t_zbacklog[].

       FREE t_fcat[].

       PERFORM f_fetch_data.

       PERFORM f_fieldcat.

       PERFORM f_grid_display.

     WHEN 'BACK'.

       LEAVE TO SCREEN 0.

   ENDCASE.