Tuesday, May 25, 2010

ABAP Program for a wait process in Process Chains

Using this program you can control all your process chains in a single meta chain even if you wish to trigger some chains at certain times.


Pic-1. - BW Wait Process ABAP Code

Example:  if you want to trigger one chain only after 12 midnight, but this chain aslo have dependant chains that should run ahead of this chain.

Create a program using the below code and create variants according to your requirement and use the ABAP Program process type in Process Type to create your own "wait till" process.


REPORT  ZBW_WAIT_PROCESS.

PARAMETERS WAIT_TO LIKE SY-UZEIT.

SELECTION-SCREEN COMMENT /1(50) i_msg.
SELECTION-SCREEN COMMENT /1(50) i_msg2.

AT SELECTION-SCREEN OUTPUT.
  i_msg = 'Wait until hh:mm:ss, (Use 24 hr clock format)'.
  CONCATENATE 'Current time ' SY-UZEIT(2) ':' SY-UZEIT+2(2) ':' SY-UZEIT+4(2) INTO i_msg2.
  MODIFY SCREEN.

START-OF-SELECTION.

  DATA: i_secs TYPE F.

* The input parameter gives the time to wait until. Get the difference between
* the wait until time and the system time and use the number of seconds as the time
* to wait before continuation.

  i_secs = WAIT_TO - SY-UZEIT.

  IF i_secs > 0.
    WAIT UP TO i_secs SECONDS.
  ELSE.
    EXIT.
  ENDIF.

  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


No comments: