‎2007 Aug 27 6:22 PM
Normally in module pool programming PAI is triggered when we press a button or do some action in the screen. But my requirement is to trigger PAI automatically after PBO is complete(after the data is shown in the screen). Is there any function module to trigger PAI in the code.
‎2007 Aug 27 7:24 PM
Do you want to automatically fire the PAI at some time interval, see this example.
REPORT zrich_0001.
*----------------------------------------------------------------------*
* CLASS lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: on_finished FOR EVENT finished OF cl_gui_timer.
ENDCLASS. "lcl_event_handler DEFINITION
DATA: gui_timer TYPE REF TO cl_gui_timer.
DATA: timeout TYPE i VALUE '3'.
PARAMETERS: p_datum TYPE sy-datum,
p_uzeit TYPE sy-uzeit.
AT SELECTION-SCREEN OUTPUT.
CREATE OBJECT gui_timer.
SET HANDLER lcl_event_handler=>on_finished FOR gui_timer.
gui_timer->interval = timeout.
CALL METHOD gui_timer->run.
AT SELECTION-SCREEN.
CASE sy-ucomm.
WHEN 'REFR'.
* Do What ever
p_datum = sy-datum.
p_uzeit = sy-uzeit.
ENDCASE.
*---------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
METHOD on_finished.
* Start Timer again
gui_timer->interval = timeout.
CALL METHOD gui_timer->run.
* cause PAI
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'REFR'.
ENDMETHOD. "on_finished
ENDCLASS. "lcl_event_handler IMPLEMENTATION
The implementatino is pretty much the same for a dynpro as well.
Regards,
Rich Heilman
‎2007 Aug 27 6:53 PM
Hi,
I think you can try use the Method "set_new_ok_code":
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = '<Your New OKCODE>'.
Regards.
Marcelo Ramos
‎2007 Aug 27 6:55 PM
You can use this class method:
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'XXXX'.
Problem is, after PAI, PBO automatically triggers, so you'll probably enter an endless loop (i'm not able to try out now). You should only trigger PAI automatically based on some condition that will change sometime, recheck your requirement.
Regards
Please reward points if helpful.
Message was edited by:
Alejandro Bindi
‎2007 Aug 27 7:05 PM
No this is not happening for module pool programming. PAI is not triggered...
‎2007 Aug 27 7:12 PM
What I mean is:
Normal module behaviour is:
PBO > [user action] > PAI > PBO > [user action] > PAI > PBO > [user action] > PAI ....
You intend to replace [user action] with an automatic triggering (using the method we suggested). So, taking [user action] out of the way:
PAI > PBO > PAI > PBO > PAI > PBO > PAI > PBO....
You will loose interaction which is the dialog program main purpose. To avoid that, you should call the method based on some condition which is not always true.
Hope you get it.
Regards
‎2007 Aug 27 7:15 PM
The automatic trigger of PAI will happen only after some regular time interval. So there wont be a problem in stopping the flow.
‎2007 Aug 27 7:16 PM
‎2007 Aug 27 7:24 PM
Do you want to automatically fire the PAI at some time interval, see this example.
REPORT zrich_0001.
*----------------------------------------------------------------------*
* CLASS lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: on_finished FOR EVENT finished OF cl_gui_timer.
ENDCLASS. "lcl_event_handler DEFINITION
DATA: gui_timer TYPE REF TO cl_gui_timer.
DATA: timeout TYPE i VALUE '3'.
PARAMETERS: p_datum TYPE sy-datum,
p_uzeit TYPE sy-uzeit.
AT SELECTION-SCREEN OUTPUT.
CREATE OBJECT gui_timer.
SET HANDLER lcl_event_handler=>on_finished FOR gui_timer.
gui_timer->interval = timeout.
CALL METHOD gui_timer->run.
AT SELECTION-SCREEN.
CASE sy-ucomm.
WHEN 'REFR'.
* Do What ever
p_datum = sy-datum.
p_uzeit = sy-uzeit.
ENDCASE.
*---------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
METHOD on_finished.
* Start Timer again
gui_timer->interval = timeout.
CALL METHOD gui_timer->run.
* cause PAI
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'REFR'.
ENDMETHOD. "on_finished
ENDCLASS. "lcl_event_handler IMPLEMENTATION
The implementatino is pretty much the same for a dynpro as well.
Regards,
Rich Heilman
‎2007 Aug 27 7:25 PM
Hi,
You can use the program <b>DEMO_CUSTOM_CONTROL</b> as example.
<b>Don't forget to close this Thread and reward points when your question be answered.</b>
Regards.
Marcelo Ramos