SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Check Job Dependencies & Kick Off Event if Ready



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Batch Input (BDC), Background processing and Jobs
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Wed Aug 20, 2008 9:38 am    Post subject: Check Job Dependencies & Kick Off Event if Ready Reply with quote

Code:
* Source Name is  ZCHCKDEP
* Source Name is  ZCHCKDEP
REPORT ZCHCHDEP.
***********************************************************************
* One or More Job Steps must Complete - then RAISE a Event            *
*   WHICH will initiate a New Job to Start                            *
***********************************************************************
PARAMETERS: EVENTID LIKE BTCUEV-EVENTID."Note - only use 1st 22 Position
*SELTEXT E * Event ID to be Trigerred
SELECTION-SCREEN SKIP.
PARAMETERS: JOB01 LIKE TBTCM-JOBNAME.
*SELTEXT E * Job1 That Must Finish
PARAMETERS: JOB02 LIKE TBTCM-JOBNAME.
*SELTEXT E * Job2 That Must Finish
PARAMETERS: JOB03 LIKE TBTCM-JOBNAME.
*SELTEXT E * Job3 That Must Finish
PARAMETERS: JOB04 LIKE TBTCM-JOBNAME.
*SELTEXT E * Job4 That Must Finish
PARAMETERS: JOB05 LIKE TBTCM-JOBNAME.
*SELTEXT E * Job5 That Must Finish
PARAMETERS: JOB06 LIKE TBTCM-JOBNAME.
*SELTEXT E * Job6 That Must Finish
PARAMETERS: JOB07 LIKE TBTCM-JOBNAME.
*SELTEXT E * Job7 That Must Finish
PARAMETERS: JOB08 LIKE TBTCM-JOBNAME.
*SELTEXT E * Job8 That Must Finish
PARAMETERS: JOB09 LIKE TBTCM-JOBNAME.
*SELTEXT E * Job9 That Must Finish
PARAMETERS: JOB10 LIKE TBTCM-JOBNAME.
*SELTEXT E * Jo10 That Must Finish

TABLES: INDX.
DATA: BEGIN OF EXPORT-ID-FILES,
      SRTFD LIKE INDX-SRTFD,
      END OF EXPORT-ID-FILES.
DATA: BEGIN OF TABDATA OCCURS 10,
      JOBNAME LIKE TBTCM-JOBNAME,
      STATUS(09),
      END OF TABDATA.
DATA: JOBNAME LIKE TBTCM-JOBNAME.
DATA: NOT-COMPLETED.
CLEAR JOBNAME.
MOVE EVENTID TO EXPORT-ID-FILES-SRTFD.
IMPORT TABDATA FROM DATABASE INDX(AR) CLIENT SY-MANDT
                                      ID EXPORT-ID-FILES.
IF SY-SUBRC NE 0.
  REFRESH TABDATA.
ENDIF.

* Make Sure Dependent Jobs are in Table
PERFORM UPDATE-TABDATA USING JOB01.
PERFORM UPDATE-TABDATA USING JOB02.
PERFORM UPDATE-TABDATA USING JOB03.
PERFORM UPDATE-TABDATA USING JOB04.
PERFORM UPDATE-TABDATA USING JOB05.
PERFORM UPDATE-TABDATA USING JOB06.
PERFORM UPDATE-TABDATA USING JOB07.
PERFORM UPDATE-TABDATA USING JOB08.
PERFORM UPDATE-TABDATA USING JOB09.
PERFORM UPDATE-TABDATA USING JOB10.

* Update Current Job in Table - Make Completed
CLEAR JOBNAME.
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
     IMPORTING
          JOBNAME         = JOBNAME
     EXCEPTIONS
          NO_RUNTIME_INFO = 1
          OTHERS          = 2.
IF NOT JOBNAME IS INITIAL.
  LOOP AT TABDATA.
    IF JOBNAME CS TABDATA-JOBNAME.
      MOVE 'Completed' TO TABDATA-STATUS.
      MODIFY TABDATA.
    ENDIF.
  ENDLOOP.
ENDIF.

* Determine if All Jobs ARE IN COMPLETED STATUS
MOVE 'N' TO NOT-COMPLETED.
LOOP AT TABDATA.
  IF TABDATA-STATUS NE 'Completed'.
    MOVE 'Y' TO NOT-COMPLETED.
    EXIT.
  ENDIF.
ENDLOOP.
IF NOT-COMPLETED EQ 'Y'.               "Update Table & Send Back
  EXPORT TABDATA TO   DATABASE INDX(AR) CLIENT SY-MANDT
                                        ID EXPORT-ID-FILES.
  WRITE:/ 'Event ', EVENTID, ' not READY TO BE Triggered'.
ELSE.
  REFRESH TABDATA.        "Clear Out Table & Send Back
  EXPORT TABDATA TO   DATABASE INDX(AR) CLIENT SY-MANDT
                                        ID EXPORT-ID-FILES.
* Then Raise Event to Trigger Other Job(s)
CALL FUNCTION 'BP_EVENT_RAISE'
     EXPORTING
          EVENTID                = EVENTID
          EVENTPARM              = 'U'
          TARGET_INSTANCE        = ' '
     EXCEPTIONS
          BAD_EVENTID            = 01
          EVENTID_DOES_NOT_EXIST = 02
          EVENTID_MISSING        = 03
          RAISE_FAILED           = 04.
IF SY-SUBRC NE 0.
  WRITE:/ 'Event ', EVENTID, ' not Triggered'.
ELSE.
  WRITE:/ 'Event ', EVENTID, ' has been Trigerred'.
ENDIF.
ENDIF.



*---------------------------------------------------------------------*
*       FORM UPDATE-TABDATA                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  JOBXX                                                         *
*---------------------------------------------------------------------*
FORM UPDATE-TABDATA USING JOBXX.
  DATA: LOOP-FOUND.
  IF NOT JOBXX IS INITIAL.
    CLEAR LOOP-FOUND.
    LOOP AT TABDATA.
      IF JOBXX CS TABDATA-JOBNAME.
        MOVE 'Y' TO LOOP-FOUND.
        EXIT.
      ENDIF.
    ENDLOOP.
    IF LOOP-FOUND IS INITIAL.
      CLEAR TABDATA.
      MOVE JOBXX TO TABDATA-JOBNAME.
      APPEND TABDATA.
    ENDIF.
  ENDIF.
ENDFORM.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Batch Input (BDC), Background processing and Jobs All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.