Triple A

It's all about ABAP.


Thursday, February 17, 2011

ABAP Timer - Part 2

Function Module - RFC_PING_AND_WAIT
This is the way to use it, the code is pretty self-explanatory:

CALL FUNCTION 'RFC_PING_AND_WAIT'
STARTING NEW TASK "task id"
PERFORMING "subroutine" ON END OF TASK
EXPORTING
seconds = 3
busy_waiting = ' '.

task id:
specify a character type data object(Max length 8) as a task identifier for the called function module. Eg. '001'

subroutine:
specify a subroutine with exactly one USING parameter (type CLIKE). It will be executed after terminating the FM call.
Note - method call is possible in release 6.2 and above, please check with SAP help :)

Here's the code for a simple timer program:

START-OF-SELECTION.

PERFORM trigger.

AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'TRIGGER'.
PERFORM trigger.
WHEN 'EXIT' OR 'CANCEL' OR 'BACK'.
LEAVE PROGRAM.
ENDCASE.


*&---------------------------------------------------------------------*
*& Form on_finished
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->TASKNAME text
*----------------------------------------------------------------------*
FORM on_finished USING taskname.
SET USER-COMMAND 'TRIGGER'.
ENDFORM. "when_finished


*&---------------------------------------------------------------------*
*& Form trigger
*&---------------------------------------------------------------------*
* Trigger the timer
*----------------------------------------------------------------------*
FORM trigger.
WRITE: / sy-uzeit.
sy-lsind = 0.
CALL FUNCTION 'RFC_PING_AND_WAIT'
STARTING NEW TASK '001'
PERFORMING on_finished ON END OF TASK
EXPORTING
seconds = 3
busy_waiting = ' '.
ENDFORM. "triger

Important Note - In dialog program, you may set an OK_CODE that triggers PAI by using static method CL_GUI_CFW=>SET_NEW_OK_CODE. Eg. Refresh

No comments:

Post a Comment