EXEC CICS START TRANSID command

351 Views Asked by At

Please can someone help me understand, after EXEC CICS START TRANSID is issued from the invoking program, how is the completion of the task checked from the invoking program? What happens to the invoking program.

1

There are 1 best solutions below

0
Remko On

I distilled some sample code, see below.

In our case, the main CICS program would EXEC CICS RUN another transaction (WS-Run-Trancode) as a child process, wait for a while (RESPWAIT seconds), than check if the child is finished. If it has not, discard the results, otherwise, we would move the containers containing the results from the child-channel (Child-Channel-Name) to the channel of out main program (Channel-Name).

It is not necessary to use channels and/or containers.

Working storage fragment:

   77 Child-Token                PIC X(16).
   77 Child-Abcode               PIC X(4).
   77 Child-Status               PIC S9(8) COMP-5 SYNC.
   77 Child-Channel-Name         PIC X(16) VALUE SPACES.
   77 Child-Timeout              PIC S9(8) COMP-5 SYNC.

Program fragment:

  *    Start module again under Run-trancode
       EXEC CICS RUN
                 TRANSID(WS-Run-Trancode)
                 CHILD(Child-Token)
                 CHANNEL(Channel-Name)
                 RESP(Response)
                 RESP2(Response2)
       END-EXEC

       IF Response NOT = DFHRESP(NORMAL)
  *       ...
       END-IF

       MULTIPLY RESPWAIT BY 1000 GIVING Child-Timeout

       EXEC CICS FETCH
                 CHILD(Child-Token)
                 ABCODE(Child-Abcode)
                 COMPSTATUS(Child-Status)
                 CHANNEL(Child-Channel-Name)
                 TIMEOUT(Child-Timeout)
                 RESP(Response)
                 RESP2(Response2)
       END-EXEC
    
       IF Response NOT = DFHRESP(NORMAL)
          EVALUATE Response
          WHEN DFHRESP(NOTFINISHED)
  *            Handle timeout (stop monitoring)
               EXEC CICS FREE CHILD(Child-Token)
                         NOHANDLE
               END-EXEC
  *            ...
          WHEN OTHER
  *            CICS error
  *            ...
          END-EVALUATE
       ELSE
          EVALUATE Child-Status
          WHEN DFHVALUE(NORMAL)
  *            Child-Channel-Name contains response containers
  *            ...
          WHEN DFHVALUE(ABEND)
  *            Child abended
  *            ...
          WHEN OTHER
  *            Some other error
  *            ...
          END-EVALUATE
       END-IF



  *    Cleanup
       IF Child-Channel-Name NOT = SPACES
          EXEC CICS DELETE CHANNEL(Child-Channel-Name)
               NOHANDLE
          END-EXEC
       END-IF