MainframeSupports
tip week 46/2005:

Batch TSO can be used for a lot of things. Most of you are likely to use batch TSO only for the purpose of running DB2 programs. This is actually quite boring. You can use batch TSO to execute any kind of non interactive commands and you do not have to wait for the result. A good example is HRECALL. Long running RACF commands producing a lot of output is another example. Finally you can use batch TSO to allocate datasets.

Why on earth should I do this you may wonder. Imagine you want to allocate a new dataset and if it does exists then do nothing. Normally you will use DISP=MOD for this kind of stuff. DISP=MOD has the side effect of holding the dataset exclusively and this might not be what you have in mind when the dataset already exists. Using the following step you will avoid this problem:

//TSOBATCH EXEC PGM=IKJEFT01
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
  ALLOCATE DATASET('MY.OWN.DATASET') SHR
  WHEN SYSRC(= 12) -
    ALLOCATE DATASET('MY.OWN.DATASET') -
    TRACKS SPACE(10,10) NEW CATLG
/*

I start by allocating the dataset as if it already exists. If this fails because the dataset doesn't exist I allocate it. In this way I will only have exclusive access to the dataset when I create it.

All the above is only meant to show you that it is possible to make simple IF statements in the TSO command input stream without having to use REXX or CLIST. This is done by using WHEN SYSRC(operator value). You can have more WHEN SYSRC which enables you to execute different commands depending of the result of a previous command. WHEN is a simple command. Nesting is not allowed, but simple things are better than nothing at all. The WHEN command is described in the TSO Command Reference.

Previous tip in english        Sidste danske tip        Tip list