Page 1 of 1

Determining batch/TSO/CICS in assembler

PostPosted: Sat 22 Feb 2014, 01:00
by tdarcos
I am trying to figure out how to set a flag in an assembly program that determines whether the program is running on batch or on TSO or how you can do input and output that work on both TSO and Batch. Now, on batch you can create a DSN with DSNAME=SYSPRINT and DSNAME=SYSIN and do that, and on TSO you can use TPUT (and probably TGET), at least the IBM manuals make that clear, but I'm not sure how to create a program that can run either in batch or on TSO by determining which it's on.

At least I know how to execute, for batch you use EXEC PGM=modulename and point the joblib to the PDS that contains that member. On TSO you use the CALL statement referencing the PDS. Maybe I should ask if there's a difference if the assembly program is running from ISPF instead of from the TSO command line.

I never found out what it was for reading and writing to the terminal in TSO because we didn't have it; for the terminal monitor we had MUSIC/SP which had MVS emulation, and we ran VM so we submitted batch jobs to MVS, and MUSIC/SP supported use of OPEN/CLOSE on a DSN, so on MUSIC/SP you could run them the same way on either or you could define sysprint/sysin to point to the terminal. (Actually, if you were running on MUSIC/SP you could also use WTO/WTOR which is clearly out of the question for a batch task!)

Oh, I probably also should ask how a program can know if it's running on CICS too. So that it can determine which of the three environments it's on and adjust accordingly.

Either a quick how or a pointer to a place where they tell how would be appreciated.

Re: Determining batch/TSO/CICS in assembler

PostPosted: Sat 22 Feb 2014, 03:34
by steve-myers
I sent to your ID via XMIT a little Assembler program to determine if the environment is TSO (return code 4) or something else (return code 0). It locates a control block called a Subsystem Identification Block (SSIB). The SSIB has the JESx job ID in it; it tests if the first byte is T (TSO) and uses that to set the return code.

Re: Determining batch/TSO/CICS in assembler

PostPosted: Sat 22 Feb 2014, 03:57
by steve-myers
Code: Select all
         PUSH  PRINT
         PRINT NOGEN
         CVT   DSECT=YES
         IKJTCB ,
         IEZJSCB ,
         IEFJSSIB ,
         POP   PRINT
         USING *,2
         SAVE  (14,2),,'ENVIRON &SYSDATE &SYSTIME'
         LR    2,15
         L     15,CVTPTR
         L     15,CVTTCBP-CVTMAP(,15)
         L     15,4(,15)
         L     15,TCBJSCB-TCB(,15)
         L     14,JSCBSSIB-IEZJSCB(,15)
         SR    15,15
         CLI   SSIBJBID-SSIB(14),C'T'
         BNE   *+L'*+4
         LA    15,4
         RETURN (14,2),T,RC=(15)
         DC    0D'0'
         END   ENVIRON