2010 Oct 21 9:18 AM
Hello,
I have a quite simple report with a selection screen. In addition to the selection screen fields, I have some global variables used by that selection screen.
Currently, executing the report does not do anything (START-OF-SELECTION just do some random useless stuff).
After executing the report, it of course stays on the selection screen, but ALL my global variables are reset, and the INITIALIZATION event block is reprocessed.
I do not understand why this happens, it definitely should not. Any idea is welcome.
Thanks,
Thomas
2010 Oct 21 9:40 AM
Hi Thomas,
It's standard behavior of ABAP reports,
There should be an event sequence in your program
- INITIALIZATION ( Setting default values for parameters and some variables )
- START-OF-SELECTION ( Reading data )
- END-OF-SELECTION ( Displaying result data )
When START-OF-SELECTION / END-OF-SELECTION events is ended
and if user has returned to the selection screen in such a way
then all global variables initialized and INITIALIZATION is triggered again then selection screen shown again.
It means report is ready to run again.
What do you want to do?
What is the problem in that?
Edited by: Bulent Balci on Oct 21, 2010 10:41 AM
2010 Oct 21 9:29 AM
Thomas Debouverie wrote >>>>>>>>
Currently, executing the report does not do anything (START-OF-SELECTION just do some random useless stuff).
don't clear global varibale sin START-OF-SELECTION event.
Do the same after END-OF-SELCTION.
Other paste the piice of code so the will get clear Idea.
Regards,
Pravin
2010 Oct 21 9:37 AM
Hello,
Thanks for your fast answer.
I do not do any variables clearing myself. Here is the data declaration:
* Data for node selection
DATA: gs_src_node TYPE hier_iface.
DATA: gs_dst_node TYPE hier_iface.Here is the INITIALIZATION block:
* Initialize solution/project toggle, if first time called. Only supports project for now.
* Also initialize node selection
INITIALIZATION.
IF gv_test IS INITIAL.
* sscrfields-functxt_01 = text-004.
gv_active_solid = gc_flag_inactive.
gv_active_proj = gc_flag_active.
gv_test = 'X'.
ENDIF.
IF com_src IS INITIAL.
com_src = com_dst = text-005.
ENDIF.And here is the start of selection block:
START-OF-SELECTION.
PERFORM report_start.
*&---------------------------------------------------------------------*
*& Form report_start
*&---------------------------------------------------------------------*
* Start report: check selection and do data copy.
*----------------------------------------------------------------------*
FORM report_start.
* DATA: lv_sel_ok TYPE flag.
* PERFORM check_selection CHANGING lv_sel_ok.
* CHECK lv_sel_ok IS NOT INITIAL.
* PERFORM do_copy.
ENDFORM. "report_startI don't have an END-OF-SELECTION block. As you can see the report does not do anything. However my global variables are cleared after the START-OF-SELECTION block, and the INITIALIZATION block is reprocessed each time.
2010 Oct 21 9:40 AM
Hi Thomas,
It's standard behavior of ABAP reports,
There should be an event sequence in your program
- INITIALIZATION ( Setting default values for parameters and some variables )
- START-OF-SELECTION ( Reading data )
- END-OF-SELECTION ( Displaying result data )
When START-OF-SELECTION / END-OF-SELECTION events is ended
and if user has returned to the selection screen in such a way
then all global variables initialized and INITIALIZATION is triggered again then selection screen shown again.
It means report is ready to run again.
What do you want to do?
What is the problem in that?
Edited by: Bulent Balci on Oct 21, 2010 10:41 AM
2010 Oct 21 9:57 AM
You are right this is standard behaviour, and usually it is fine.
When going back to initialization event, all global variables are reset, however selection variables (parameters and select options) are NOT reset. This again is usually fine.
In this case however, I have some selection data which cannot be set as parameters and select options, so I use global variables which are filled in selection-screen events when the user click on a pushbutton, which brings a search help.
I would like to keep these global variables filled, even when the report starts again after the user hits the "BACK" button on the report result.
2010 Oct 21 10:26 AM
Hi,
So you should be filling that global selection data somewhere in your program,
Put that part of program into event INITIALIZATION.
Program has to read it again before the second display of seletion-screen.
Or you can use
" EXPORT .. TO MEMORY ID " "* IMPORT ..FROM MEMORY id" commands
but it won't be a good solution.
Meanwhile,
You should've a mistake, when use returns to selection screen Select-options and parameters are reset too.
You can see old values you specified on your screen again, but they have only stayed on screen
original values is set in initialization again. They will take over values from screen in event START-OF-SELECTION.
Edited by: Bulent Balci on Oct 21, 2010 11:28 AM
2010 Oct 21 10:31 AM
Ok, I was hoping not to have to do some dirty trick to manage it. I will find some way, thanks for the information.
2010 Oct 21 9:53 AM
Hi Thomas,
Initialization event is executed before the selection screen is displayed. Since you have nothing in your START-OF-SELECTION event, the program returns to the selection screen. Hence the initialization event is triggered again.
This should work fine if you have some code in the start of selection event.
Thanks,
Santosh