ISPF makes using z/OS easy. Many tools are at your disposal that let you create, modify, compile, and test programs, run utilities, and generally do your day-to-day tasks. But if you have repetitive, complex, or long-running tasks, it can make sense to run them in the background.
How Set Up JCL to Execute ISPF in Batch
The setup for using ISPF in batch is much like the setup for using ISPF interactively. The setup that is normally done in your logon proc or your ISPF exec needs to be done in JCL. You need to allocate all of the ISPF product data sets and establish the ISPF enviroment. Your JCL needs to
- Execute the IKJEFT01 utility.
- Use DD statements to allocate the ISPF product data sets.
- Use the ISPSTART command to establish the ISPF environment for the command.
Your EXEC statement executes IKJEFT01 utility, which runs TSO's Terminal Monitoring Program (TMP).
Allocate ISPF DDNames
You need DD statements to allocate the appropriate data sets
- An ISPF profile
- ISPPROF which you can specify either as a
- temporary data set, or
- an existing data set,specified with DISP=OLD to ensure exclusive use of a cataloged profile data set. If you use an existing data set with DISP=SHR, the job often fails with ABEND 998, like this:
IEF142I SHELLYA ISPFSTP - STEP WAS EXECUTED - COND CODE 0998
ISPT036 Table in use -/-TBOPEN issued for table ISPSPROF that is in use, ENQUEUE failed.
- ISPPROF which you can specify either as a
- All required ISPF product ddnames
- ISPPLIB - panels
- ISPMLIB - messas
- ISPSLIB - skeletons
- ISPTLIB - tables
- Specify a temporary data set as the first data set in DDname ISPTLIB. If the ISPPROF data set is new or temporary, ISPF needs to access ISPTLIB to get defaults for the profile. If two jobs run concurrently and the first data set in ISPTLIB is ISP.SISPTABL, one of the jobs will get the message ISPT036 Table in use TBOPEN issued for table ISPSPROF that is in use, ENQUEUE failed.
- Any data sets your application needs
- ISPLLIB for any load modules
- SYSPROC or SYSEXEC for any CLISTs or REXX execs.
- ISPTABL for any output tables
- ISPLOG to show any logged messages
The SYSTSIN DD statement starts the application with the ISPSTART command.
Coding Your Application in Batch
There are a few situations that require particular attention in batch.
Since there is no user interaction in batch, if the dialog uses any of the display services (DISPLAY, TBDISPL, SELECT PANEL, SETMSG, PQUERY), the dialog must provide input that would normally be supplied by the user. You might need to alter panels to simulate an END or ENTER key by using the .RESP keyword in your panel definition, for example.
)INIT .RESP = ENTER
If there is an error in the display processing, an infinite loop can occur. To prevent an infinite loop, use the BDISPMAX parameter on the ISPSTART command so the dialog ends after a given number of displays. Use the BREDIMAX parameter so that the dialog ends after a given number of redisplays. The screen width and screen depth can also be set for batch.
ISPSTART CMD(SERVPAN) BATSCRW(132) BATSCRD(50) BDISPMAX(255) BREDIMAX(2)
executes a REXX exec called SERVPAN, which will "display" with a screen width of 132, and a screen depth of 50, and "displays" a panel 255 times before ending or "redisplays" a panel twice before ending. When the batch display maximum is reached, the job ends with code 990, and a message displays:
ISPP330 BDISPMAX exceeded -/-255 displays exceeded in batch mode on panel SERVPAN
If your code attempts to redisplay a panel, you might see message:
ISPP331 BREDIMAX exceeded -/-2 ;msg redisplays exceeded in batch mode.
The default value for BDISPMAX is 100 and the default value for BREDIMAX is 2.
To run EDIT in batch, you must use an initial edit macro to provide the input that would normally be supplied by the user. This initial macro can do anything that can be done by an initial macro in an interactive session. However, in batch, the macro must end with an ISREDIT END or ISREDIT CANCEL statement. These statements ensure that no attempt is made to display the edit screen in batch. Without these statements, an infinite loop can result.
If your batch ISPF job gets a 998 abend, often a message appears to describe the error. If not, here are some things to consider:
- Are all required data element libraries allocated?
- Can all ISPF data element libraries be opened? Try browsing each of the data sets to make sure there are no errors.
- Do the data element libraries have valid data set characteristics? Use the Library Utility (option 3.2) or the Data Set List Utility (option 3.4) to display data set information. See ISPF User's Guide Vol. I for information about the required characteristics.
- Can the literals module be loaded? The literals modules are ISRNLxxx and ISPNLxxx, where xxx is the suffix based on the language. You can see where they are loaded in your ISPF session, using the DDLIST command. Type DDLIST on any ISPF command line. Then type LOAD ISRNLENU, for example, to see where the English language literals modules is loaded. Compare the results to your JCL.
- Is ISPF being called recursively? If so, modify your code so that ISPF is not called recursively.
Here is some sample JCL for running ISPF in batch:
//USERAA JOB (ISPF),'ISPF USER',MSGCLASS=X, // CLASS=A,NOTIFY=&SYSUID //* //ISPFSTP EXEC PGM=IKJEFT01,DYNAMNBR=30,REGION=32M //ISPPROF DD RECFM=FB,LRECL=80,SPACE=(TRK,(2,2,2)) //ISPLLIB DD DSN=USERA.LOADLIB,DISP=SHR //ISPMLIB DD DSN=ISP.SISPMENU,DISP=SHR //ISPPLIB DD DSN=ISP.SISPPENU,DISP=SHR //ISPSLIB DD DSN=ISP.SISPSENU,DISP=SHR // DD DSN=ISP.SISPSLIB,DISP=SHR //ISPTLIB DD RECFM=FB,LRECL=80,SPACE=(TRK,(1,0,1)) // DD DSN=ISP.SISPTENU,DISP=SHR //ISPCTL1 DD SPACE=(CYL,1),RECFM=FB,LRECL=80 //ISPLOG DD SYSOUT=*,RECFM=FB,LRECL=133 //SYSEXEC DD DSN=ISP.SISPEXEC,DISP=SHR //SYSPROC DD DSN=ISP.SISPCLIB,DISP=SHR //SYSTSPRT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSTSIN DD * ISPSTART CMD(ISPFCMD)
This example shows
- EXEC PGM=IKJEFT01 to start TSO TMP
- Allocation of all ISPF ddnames, including
- ISPPROF as a temporary data set
- ISPLLIB to hold the application load module
- ISPTLIB with a temporary data set as the first data set in the concatenation
- ISPLOG to show the ISPF messages log
- SYSEXEC and SYSPROC to hold the REXX execs and CLISTs
- ISPSTART command which sets up the ISPF environment and invokes a REXX exec called ISPFCMD.
Running ISPF in Batch
Many tasks that you do interactively in ISPF can be done in the background. By automating repetitive tasks and submitting them as batch jobs, you can gain control over your processes and improve productivity. For more information, see ISPF Services in Batch.