Perhaps someone can help me with my problem/situation.
At my installation, we run Natural under both TSO and CICS but all online applications run under CICS. I have a Natural process (under CICS) where a user can initiate a batch process (Natural running under TSO) where they can optionally specify a TSO dataset as job input.
What I want to do in my Natural online program is to dynamically allocate this dataset as a work file (e.g. CMWKF01) only for the duration of this process. I want to ensure that the dataset exists (obviously the allocation fails if it does not exist) and trap allocation failure this to send an appropriate message to the screen via REINPUT.
If the dataset does exist, I want to determine the number of records in the file and take some action, depending on the number of records. In my case, if there are more than 200 records the batch job will be submitted for overnight processing, otherwise it will be submitted for immediate processing.
Anyone here done something similar and would be willing to share?
I’ve managed to use USR2021N as a method to verify the existence of the specified file. Now I’m playing around trying to read that file to count the records. Halfway there!
I believe that under CICS, WORK files are implemented as Transient Data Queues (TDQ) only (i.e. temporary storage). The following example works under TSO, but not under CICS.
To read a flat file, you’ll need to run your program under TSO (or in batch).
DEFINE DATA LOCAL
1 #W (A75)
END-DEFINE
DEFINE WORK FILE 1 'RALPH.ZBROG.DATA'
READ WORK 1 #W
DISPLAY #W
END-WORK
END
I have gotten it to run under TSO and in batch but had hoped that there was some way to do this work file read under CICS (i.e. in an online CICS session).
I’ll have to give up on this functionality and be satisfied that I now know how to do the dynamic allocation of a file using USR2021N. Being able to read the file would have been gravy.
If you really want to do all this, look into getting Entire System Server. You can check the catalog, read and write work files online, read SPOOL, and much, much more.
"For TYPE=TD, only the first 4 characters of operand1 are honored and the transient data destination must be predefined to CICS. "
You will need to use an extra-partition transient data queue and the 4 character TD identifier are what you specify in the DEFINE WORK FILE 1 ‘tdqn’ statement.
You need a TDQ defined in your CICS definitions (DCT/CEDC) to use that is not included in the CICS JCL. CMWKF01 is not a TDQ name, but is mapped to the DEST= subparameter. The actual DD name used is specified by the TDQ entry corresponding to the DEST= subparameter. This is the DDNAME your USR2021N would need to be allocated to (not CMWKF01).