Application Development 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: 

Can I use a Refresh button in ALV to redirect me to Start-of-Selection?

Former Member
0 Kudos

Hi,

I have a fully functioning ALV report that our users would like to refresh via a "refresh button" instead of going back with green arrow and re-executing from the Selection Screen.

The way the program is written, it seems to me that if I can just redirect back to "start-of-selection" and let the program run from there, that it will produce the report without having to start at the selection screen.

Is it possible to have a button in the ALV report which re-enters the program at "start-of-selection"?

Hope that makes sense...thanks for your help.

Andy

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Andrew,

Sure you could do that.

For that what you need to do is  modularize  your code into blocks say forms.

Then create a button(refresh) and assign a ok_code to it for eg 'F5'.

Then in the form I_CALLBACK_USER_COMMAND give the form in which you write the logic say

if ok_code = 'F5'.

perform execcution.*which will be under start of selection.

endif.

Thanks,

dinesh.

11 REPLIES 11

Former Member
0 Kudos

Hi Andrew,

Sure you could do that.

For that what you need to do is  modularize  your code into blocks say forms.

Then create a button(refresh) and assign a ok_code to it for eg 'F5'.

Then in the form I_CALLBACK_USER_COMMAND give the form in which you write the logic say

if ok_code = 'F5'.

perform execcution.*which will be under start of selection.

endif.

Thanks,

dinesh.

0 Kudos

dinesh,

Thank you for the reply.

I am changing an already written OO program where the calling program is designed with 3 sections.

First is at-selection-screen.

Then is start-of-selection.  This is where all of the methods are called to gather the data.

Last is end-of-selection.  This is where the ALV is called.

Is there a way to implement what you are saying with a program that is already written as this?

If I want to redirect to the start-of-selection, is that possible without having to restructure the whole program?

Thanks,

Andy

0 Kudos

Hi Andrew,

You can do that here as well.Basically you are sure that if the refresh button is clicked it should not redirect to the selection screen.but the recently added entries in the tables should reflect here.

So then from your point i understood that there are methods called in start of selection as well as end of selection.

So then leave the flow as it is As i have replied earlier in the code just make all those in forms and then give the perform statements wherever it is used..

Then to give functionality for refresh, if ok_code = 'F5'. give all the performs(which are used under start of selection and end of selection) under the if condition.

Thats it.you are done

Thanks,

Dinesh.

0 Kudos

Thank you everyone for your insights and expertise.

There is a lot of excellent information here...thanks again for all of your time and help.

Andy

Former Member
0 Kudos

There may be some things that you need to clear/refresh before doing so. 

In the past I've:

CALL TRANSACTION 'Your Tcode'

             AND SKIP FIRST SCREEN. "Display

After loading the inital screen values.

Former Member
0 Kudos

Hi Andy,

Dinesh has the correct idea.  If you are sure you need everthing from the start of selection, put it all into a new form/method and when the refresh button is selected then call the new form/method. It should not matter if it is OO or "regular" ABAP. 

The refresh button can be added to the gui status and then check the ok code for the new refresh button.

Regards,

Steve

arindam_m
Active Contributor
0 Kudos

Hi,

START-OF-SELECTION is an event in your program. The ALV is generated and displayed usually at the END-OF-SELECTION i.e. after the event START-OF-SELECTION has been traversed. There is no way to get back to that event after initial execution.

But yes you can get something similar by calling the same program again after the initial display in an USER_COMMAND event of your ALV or by calling the performs that has the same logic in the start of selection block in the USER_COMMAND event. But when refreshing the data in the ALV grid by either of these ways be mindful to free the ALV of the old data. Check the wiki to understand the flow:

http://wiki.sdn.sap.com/wiki/display/Snippets/Auto+Refresh+ALV+List

Cheers,

Arindam

yang_aiolos
Active Participant
0 Kudos

hi, you should know that start-of-selection is event of report, refresh alv is what you want after the alv is changed,  they are diff

former_member186413
Participant
0 Kudos

Hi, Andrew

First of all, you should create the selection screen with Screen No. Decleartion.

SELECTION-SCREEN: BEGIN OF SCREEN <xxxx>.

SELECTION-SCREEN: END OF SCREEN.

Then, In your call back subrountine USER_COMMAND or PAI model to call the screen <xxxx> by call statment, and when the user press the refrech button.

Because your refrech function is not the ALV standard, you need to know more->http://scn.sap.com/thread/737918 from here.

former_member209120
Active Contributor
0 Kudos

Hi Andrew,

Try like this

TABLES : mara.
TYPES : BEGIN OF ty_mara,
         matnr TYPE mara-matnr,
         mtart TYPE mara-mtart,
         mbrsh TYPE mara-mbrsh,
         meins TYPE mara-meins,
         END OF ty_mara.


DATA : i_mara TYPE TABLE OF ty_mara .
DATA : wa_mara TYPE ty_mara .

DATA : alv_cont TYPE REF TO cl_gui_custom_container.
DATA : alv_grid TYPE REF TO cl_gui_alv_grid .
DATA : i_fcat TYPE lvc_t_fcat .
DATA : wa_fcat LIKE LINE OF i_fcat .

SELECT-OPTIONS : s_matnr FOR mara-matnr.

START-OF-SELECTION .
   CALL SCREEN 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
   SET PF-STATUS 'MENU_100'.
*  SET TITLEBAR 'xxx'.
   PERFORM create_objects.
   PERFORM get_data .
   PERFORM create_fcat .
   PERFORM display_alv .

ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
   CASE sy-ucomm.
     When 'REFRESH'.
     LEAVE TO SCREEN 0 .
     call transaction 'YTEST2013' AND SKIP FIRST SCREEN.
     WHEN 'BACK'.
       LEAVE TO SCREEN 0 .
   ENDCASE .

ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Form  CREATE_OBJECTS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_objects .

   CREATE OBJECT alv_cont
     EXPORTING
       container_name = 'ALV_CONT'.

   CREATE OBJECT alv_grid
     EXPORTING
       i_parent = alv_cont.


ENDFORM.                    " CREATE_OBJECTS
*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_data .
   SELECT * FROM mara
          INTO CORRESPONDING FIELDS OF TABLE i_mara UP TO 10 ROWS
          WHERE matnr IN s_matnr.
ENDFORM.                    " GET_DATA
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display_alv .

   CALL METHOD alv_grid->set_table_for_first_display
     CHANGING
       it_outtab       = i_mara
       it_fieldcatalog = i_fcat.

ENDFORM.                    " DISPLAY_ALV
*&---------------------------------------------------------------------*
*&      Form  CREATE_FCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_fcat .
   CLEAR wa_fcat .
   wa_fcat-col_pos = '1' .
   wa_fcat-fieldname = 'MATNR' .
   wa_fcat-tabname = 'I_MARA' .
   wa_fcat-scrtext_m = 'Material No' .
   APPEND wa_fcat TO i_fcat .

   CLEAR wa_fcat .
   wa_fcat-col_pos = '2' .
   wa_fcat-fieldname = 'MTART' .
   wa_fcat-tabname = 'I_MARA' .
   wa_fcat-scrtext_m = 'Industry Secotr' .
   APPEND wa_fcat TO i_fcat .

   CLEAR wa_fcat .
   wa_fcat-col_pos = '3' .
   wa_fcat-fieldname = 'MBRSH' .
   wa_fcat-tabname = 'I_MARA' .
   wa_fcat-scrtext_m = 'Mat.Type' .
   APPEND wa_fcat TO i_fcat .

   CLEAR wa_fcat .
   wa_fcat-col_pos = '4' .
   wa_fcat-fieldname = 'MEINS' .
   wa_fcat-tabname = 'I_MARA' .
   wa_fcat-scrtext_m = 'UOM' .
   APPEND wa_fcat TO i_fcat .


ENDFORM.                    " CREATE_FCAT

PF status

Output

if you click refresh it shows selection screen

Regards,

Ramesh.T

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

Just happen that I have a sample program for the refresh .

This program incorporate manual & automatic refresh.

It is using cl_gui_alv_grid,cl_gui_timer .

Regards.

Screen flow logic:


PROCESS BEFORE OUTPUT.
  MODULE at_pbo .
*
PROCESS AFTER INPUT.
  MODULE at_pai_exit AT EXIT-COMMAND.
  MODULE at_pai_process .
 
 
Screen element:

OK_CODE: