Initial requirement
My requirement was to create two reports with ALV Grid output. These reports should be called via transaction codes, and their data gathering should be done thru function modules, for the identical data will be needed for a Web Tool accessing those data via RFC.
Issue
For there is no data selection and no selection screen in these reports (and there shouldn't be one as required), after starting these transactions the users see nothing for several seconds, until the ALV Grid is displayed. So some users became unsure, if they've correctly started the transactions.
Looking for a solution
I was looking for some ideas, and I found here on SCN some threads pointing to class CL_GUI_TIMER. So I decided to create a function module calling a screen and closing it, after the timer interval has finished.
Creating the function module
First I thought about the data to be passed to the function module:
- a heading text for the popup screen
- an info text, that some action has been started
- a label text and a value text to tell, from where the function module has been called
- an info text, that the screen will be closed automaticall.
Code of the function module
FUNCTION zmy_popup_show.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_HEADER_TEXT) TYPE TEXT80
*" VALUE(I_INFO_TEXT1) TYPE TEXT80
*" VALUE(I_LABEL_TEXT) TYPE TEXT30 OPTIONAL
*" VALUE(I_VALUE_TEXT) TYPE TEXT50 OPTIONAL
*" VALUE(I_INFO_TEXT2) TYPE TEXT80 OPTIONAL
*" VALUE(I_INTERVAL) TYPE I DEFAULT 5
*"----------------------------------------------------------------------
* Filling dynpro fields and interval
xv_header_text = i_header_text.
xv_info_text1 = i_info_text1.
xv_info_text2 = i_info_text2.
xv_label_text = i_label_text.
xv_value_text = i_value_text.
xv_interval = i_interval.
* Call info screen 9000
CALL SCREEN '9000'
STARTING AT 5 5.
ENDFUNCTION.
Here I pass all input parameters to global defined variables. All text fields will be shown at the screen.
Code of the function group's TOP include
FUNCTION-POOL zmy_popup. "MESSAGE-ID ..
* Definitions
CLASS xcl_event_receiver DEFINITION DEFERRED.
DATA: xo_event TYPE REF TO xcl_event_receiver."#EC NEEDED
DATA: xv_header_text TYPE text80.
DATA: xv_info_text1 TYPE text80.
DATA: xv_info_text2 TYPE text80.
DATA: xv_interval TYPE i.
DATA: xv_label_text TYPE text30.
DATA: xo_timer TYPE REF TO cl_gui_timer.
DATA: xv_value_text TYPE text50.
* Definition of class XCL_EVENT_RECEIVER
INCLUDE lzmy_popupcls.
For catching the FINISHED event of class CL_GUI_TIMER a local event receiver class is needed:
Event Receiver Class Definition ...
*&---------------------------------------------------------------------*
*& Include LZMY_POPUPCLS
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* CLASS xcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
CLASS xcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
timer_finished FOR EVENT finished
OF cl_gui_timer.
ENDCLASS. "xcl_event_receiver DEFINITION
... and Implementation
*&---------------------------------------------------------------------*
*& Include LZMY_POPUPCLI
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* CLASS xcl_event_receiver IMPLEMENTATION *
*----------------------------------------------------------------------*
* Handle events *
*----------------------------------------------------------------------*
CLASS xcl_event_receiver IMPLEMENTATION.
*----------------------------------------------------------------------*
* METHOD timer_finished *
*----------------------------------------------------------------------*
* Action after timer has finished *
*----------------------------------------------------------------------*
METHOD timer_finished.
PERFORM exit_dynpro.
ENDMETHOD. "timer_finished
ENDCLASS. "xcl_event_receiver IMPLEMENTATION
How to leave will be shown in FORM EXIT_DYNPRO later.
Definition of the Info Screen 9000
The flow logic looks pretty simple:
PROCESS BEFORE OUTPUT.
MODULE call_timer.
*
PROCESS AFTER INPUT.
MODULE exit_dynpro.
The screen contains the fields
- XV_HEADER_TEXT
- XV_INFO_TEXT1
- XV_LABEL_TEXT
- XV_VALUE_TEXT
- XV_INFO_TEXT2
and some frames:
Remark: Übertschrift means Header/Heading.
Definition of PBO module CALL_TIMER:
*&---------------------------------------------------------------------*
*& Include LZMY_POPUPO01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module CALL_TIMER OUTPUT
*&---------------------------------------------------------------------*
* Create and start timer
*----------------------------------------------------------------------*
MODULE call_timer OUTPUT.
* Timer setzen
CREATE OBJECT xo_timer
EXCEPTIONS
OTHERS = 4.
CHECK sy-subrc EQ 0.
SET HANDLER xo_event->timer_finished FOR xo_timer.
xo_timer->interval = xv_interval.
xo_timer->run( ).
ENDMODULE. " CALL_TIMER OUTPUT
Here the timer object is created, the event handler is set, the timer interval is set and the timer is started.
Definition of optional PAI module EXIT_DYNPRO:
*&---------------------------------------------------------------------*
*& Include LZMY_POPUPI01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module EXIT_DYNPRO INPUT
*&---------------------------------------------------------------------*
* Leave Screen
*----------------------------------------------------------------------*
MODULE exit_dynpro INPUT.
CASE sy-ucomm.
WHEN 'ECAN'.
PERFORM exit_dynpro.
ENDCASE.
ENDMODULE. " EXIT_DYNPRO INPUT
This module is optional, if you want to close the info screen manually, too.
Definition of FORM routine EXIT_DYNPRO:
*&---------------------------------------------------------------------*
*& Include LZMY_POPUPF01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form EXIT_DYNPRO
*&---------------------------------------------------------------------*
* Leave Screen
*----------------------------------------------------------------------*
FORM exit_dynpro .
FREE xo_timer.
CLEAR xo_timer.
LEAVE TO SCREEN 0.
ENDFORM. " EXIT_DYNPRO
And the Function Group ZMY_POPUP looks like::
*******************************************************************
* System-defined Include-files. *
*******************************************************************
INCLUDE lzmy_popuptop. " Global Data
INCLUDE lzmy_popupuxx. " Function Modules
*******************************************************************
* User-defined Include-files (if necessary). *
*******************************************************************
INCLUDE lzmy_popupcli. " Class Implementation
INCLUDE lzmy_popupf01. " FORM Routines
INCLUDE lzmy_popupi01. " PAI-Modules
INCLUDE lzmy_popupo01. " PBO-Modules
Now the Function Group ZMY_POPUP and Function Module ZMY_POPUP_SHOW are complete.
Calling Function Module ZMY_POPUP_SHOW from report
After testing this function module in SE37, I added an asynchronous RFC call to my ALV Grid reports looking like
CALL FUNCTION 'Z2V_POPUP_SHOW'
STARTING NEW TASK 'POPUP'
EXPORTING
i_header_text = text-hdr
i_info_text1 = text-in1
i_label_text = text-lbl
i_value_text = xv_text_val
i_info_text2 = xv_text_in2
i_interval = xk_interval.
And the result looks like
The screen closes automatically and all could be fine, if there were no ...
Further issues
First issue is, that for calling this function module in ARFC mode you need a free user mode. If you have no free user mode, the call won't work. So I've coded a workaround, that this function module is only called, if a free user mode is availabale:
CALL FUNCTION 'TH_USER_INFO'
IMPORTING
act_sessions = xv_s_act
max_sessions = xv_s_max.
CHECK xv_s_max GT xv_s_act.
This is no fine solution but a workaround only..
The other issue is, that to process a function module in RFC mode you need the authority to do it, like
Authority object: S_RFC
Authority field: RFC_TYPE Value: FUGR
Authority field: RFC_NAME Value: ZMY_POPUP
Authority field: ACTVT Value: 16
Looking for improvement
So I'm searching for an improvement of this solution, where I don't need a free user mode and I don't need additional authorities.
I'm looking forward to seeing your suggestions.
Regards,
Klaus