Search code examples
mainframebatch-processingcics

Mainframe Batch Job Triggering


I am new to CICS. I have one query, Can we trigger Batch job thorough CICS transaction? I want to trigger a batch job through program which is executed by CICS transaction,is it possible?


Solution

  • Yes, it's possible.

    Your system programmers have to set up an extra partition transient data queue whose DD statement is pointing towards the internal JES reader.

    You have to write the JCL to the transient data queue, including the last // card.

    You are responsible for assuring serial access to the transient data queue with CICS ENQUEUE and DEQUEUE commands.

    The JOB card has to contain a userid and a password, so that the JOB runs under your account and not the userid of the CICS region.

    Another option is the CICS SPOOLOPEN command.

    Here's some Cobol code that uses the SPOOLOPEN command.

    EXEC CICS SPOOLOPEN OUTPUT
              NODE ('LOCAL')
              USERID ('INTRDR')
              RESP(RETCODE)RESP2(RESP2)
              TOKEN(TOKEN)
    END-EXEC
    
    PERFORM VARYING JCL-IND FROM +1 BY +1
      UNTIL RETCODE NOT = DFHRESP(NORMAL)
         OR JCL-IND > jcl-ind-max
      MOVE JCLELE (JCL-IND)     TO      JOBQUEUE
      EXEC CICS SPOOLWRITE
              FROM(JOBQUEUE)
              RESP(RETCODE) RESP2(RESP2)
              FLENGTH(OUTLEN)
              TOKEN(TOKEN)
      END-EXEC
    END-PERFORM
    
    EXEC CICS SPOOLCLOSE
              TOKEN(TOKEN)
              RESP(RETCODE) RESP2(RESP2)
    END-EXEC
    

    I found this information in a CICS wiki.