900-CREATE-AND-SUBMIT-JOB

900-CREATE-AND-SUBMIT-JOB creates a job, updates the job parameters, or both; and then it submits the batch job to the Job Scheduler.

To use the900-CREATE-AND-SUBMIT-JOB. routine

  1. Populate all of the appropriate fields for the JOBREQ group.

  2. Populate the working storage parameter fields.

  3. Move the entire parameter working storage to the JOBSTP-PARAMS field.

  4. Perform 900-CREATE-AND-SUBMIT-JOB.

    The calling program has no method of knowing when the job actually starts or completes.

Library JOBRTNS
Unused Fields (None)
Output The batch job is submitted to the Job Scheduler.

Required Fields

Field Type and length Definition
JOBREQ-CREATE A 1 Y = Deletes an existing job definition before creating a new one.
JOBREQ-MODIFY A 1

Y = Deletes an existing job definition before creating a new one.

Note: If neither JOBREQ-CREATE nor JOBREQ-MODIFY has a value of Y, the routine sets JOBREQ-MODIFY to Y.
JOBREQ-DELQJB A 1 Deletes all Job Scheduler entries for the job except for running jobs. If the job already exists and it is running, then the routine fails and returns Y in the WSJR-ERROR field.
JOBREQ-NO-MOD-IF-EXISTS A 1 Forces the routine not to update the job if it already exists. If the job exists, then the routine returns Y in the WSJR-ERROR field.
JOBREQ-STEPS Occurs 20 times Group label for each step occurrence. The following fields are subscripted.
JOBSTP-TOKEN A 10 Case-sensitive form ID to be run in this step.
JOBSTP-PROJECT A 14 Product line, data area, or data ID name for the application form ID. user and environment form IDs have no product line, so in those cases, move spaces to this field.
JOBSTP-PARAMS A 2000 The parameters for this step, strung together in contiguous order. Not all steps have parameters.

Optional Fields

Field Type and length Definition
JOBREQ-DESCRIPTION A 30 Description for the job.
JOBSTP-DESCRIPTION A 30 Description for the job step.
JOBSTP-DIST-GRP A 10 Distribution groups you have defined in Distribution Group Maintenance.
JOBSTP-PRINTER A 10 Appropriate printer
JOBSTP-NBR-COPIES N 2 Number of copies to print if sent directly to a printer. The default is to 1.
JOBSTP-SAVE A 1 Whether or not to save the job definition after it has completed. The default is to Y.
JOBREQ-JOB-QUEUE A 5 Job queue you want to submit the job through. (If left blank, the default queue is used.)
JOBREQ-START-DATE N 8 Date the job should start. (If left blank, the job starts now.)
JOBREQ-START-TIME N 6 Time the job should start. (If left blank, the job starts now.)

Return Value

Field Type and length Definition
WSJR-ERROR A 1

Y = Call failed.

N = Call successful.

Programming Example for Application Form ID

           IF (IC89F1-FC               = "S")
               MOVE CRT-USER-NAME      TO JOBREQ-USER-NAME
               STRING "IC588"         DELIMITED BY " "
                      INTO JOBREQ-JOB-NAME
               PERFORM 900-LOAD-JOB
               IF (WSJR-ERROR          = "Y")
                   MOVE "Y"            TO JOBREQ-CREATE
                   MOVE "N"            TO JOBREQ-IS-MULT-STEP
                   MOVE 1              TO JOBREQ-NBR-STEPS
                   MOVE "IC588"        TO JOBSTP-TOKEN (1)
                   MOVE WS-DB-PRODUCT-LINE
                                       TO JOBSTP-PROJECT (1)
                   MOVE 1              TO JOBSTP-NBR-COPIES (1)
                   MOVE "Y"            TO JOBSTP-SAVE (1)
                   MOVE IC89F1-TIME    TO JOBSTP-PARAMS (1)
               ELSE
                   MOVE "N"            TO JOBREQ-CREATE
                   MOVE "Y"            TO JOBREQ-MODIFY
                   MOVE IC89F1-TIME    TO JOBSTP-PARAMS (1)
               END-IF
               PERFORM 900-CREATE-AND-SUBMIT-JOB
               IF (WSJR-ERROR          NOT = "N")
                   MOVE 911            TO CRT-ERROR-NBR.

Programming Example for User Form ID

****************************************************
 1000-DO-REPORT                 SECTION 50.
***********************************************************
 1000-START.

   MOVE ZEROS                 TO RPT-PAGE-COUNT (MO202-R1).
   MOVE ZEROES                TO DB-COMPANY.
   PERFORM 850-FIND-NLT-COMSET1.

         MOVE "usrtkn1"             TO JOBSTP-TOKEN(1).
         MOVE SPACES                TO JOBSTP-PROJECT(1).
         MOVE "/lawson/usr/lawusr1/USRCMD1"
         TO JOBSTP-PARAMS(1).
         MOVE "N"                   TO JOBREQ-IS-MULT-STEP.
         MOVE "lawusr1"             TO JOBREQ-USER-NAME.
         MOVE "USERTKN1"            TO JOBREQ-JOB-NAME.
         MOVE 1                     TO JOBREQ-NBR-STEPS.
         MOVE "LAWUSR1"               TO WSJR-USER-NAME.
         MOVE "USERTKN1"           TO WSJR-JOB-NAME.
         PERFORM 900-CREATE-AND-SUBMIT-JOB.
         IF WSJR-ERROR = "Y"
             DISPLAY "REQUEST lawusr1, USRTKN1 DID NOT WORK".
         ELSE
             DISPLAY "REQUEST lawusr1, USRTKN1 WORKED".
   PERFORM 1020-DO-COM-COMPANY
     THRU    1020-END.
         UNTIL (COMPANY-NOTFOUND).

     GO TO 1000-END.

*********************************************************