Hello,
In this blog post, let's see how we can make use of EZTPX01 sub program in Easytrieve to get PARM values from the JCL. Also, we'll make use of the PARM values to update a VSAM file, all through Easytrieve.
The VSAM file I'm using in this example will have the following contents.
Contents of the VSAM file used for this example. |
The first six bytes are the ID (which acts as the key) and the next 20 bytes starting from 8th position is the text field. Our objective is to add a string in the text field of the 3rd record with 345678 as the key.
The JCL with Easytrieve program is shown below:
JCL with the Easytrieve program. |
What the program does?
- In the EXEC statement of the JCL, we are passing values using PARM keyword.
- In the Work variables' section, we have defined some variables for handling the PARM data. PARM-LEN is used to store the length of the PARM data and it should always be defined in 2 bytes of binary. PARM-DATA variable is used to store the PARM data i.e., '345678SRINI '.
- Remember that YOU are responsible for placing the maximum length you expect for the PARM information, into the 2-byte binary field before calling EZTPX01 sub program.
- Take a look at the fields that are being redefined in the Work variables section. PARM-LEN and PARM-DATA fields are redefining the PARM-INFO field which is of length 28 (26 bytes for the PARM data and 2 bytes for storing the length of the PARM data). Again, WS-ID and WS-NAME are redefining the PARM-DATA field in order to disintegrate the PARM data into two parts, ID and Text.
- Since we are going to use Controlled file processing, the JOB INPUT statement is NULL.
- The START procedure executes first and the control is passed to PARM-PARA. In the PARM-PARA, we are defining the maximum length of PARM data in the PARM-LEN field before calling EZTPX01 sub program.
- Please note that PARM data is truncated on the right if the data's length is more than the length you specified in the program.
- EZTPX01 requires two parameters, the system defined PARM-REGISTER, and a User-defined input/output field (in this example, it is PARM-INFO field).
- Issue a call to EZTPX01 sub program to get the PARM data.
- After receiving the PARM data, WS-ID field have the key (345678) and WS-NAME will have the text field data (SRINI ) as these fields are redefining PARM-DATA field.
- READ the VSAM file with a special form of READ statement. Here, we do a Random read by accessing the VSAM file using the key.
- Note the READ statement with STATUS parameter. Specify the STATUS parameter whenever there is a possibility for unsuccessful completion of the input/output request. STATUS checks input/output processing to see if it was performed properly. STATUS causes the file's FILE-STATUS field to be set with the appropriate return code. FILE-STATUS is a read only field in Easytrieve.
- We evaluate the FILE-STATUS field to know the status of READ operation. If the READ is success, then we move the WS-NAME field to the corresponding field in the VSAM file and we issue a WRITE statement to the same VSAM file.
- Use UPDATE parameter in the WRITE statement to let Easytrieve know that you're updating the file. You can also use ADD or DELETE in the place of UPDATE. Don't forget to capture the STATUS though.
- The control comes out of the para when the WRITE is success and the program ends.
Output:
The 3rd record is updated now. |
Note the text field in the 3rd record which is now updated with the data passed in the PARM.
Hope this helps! Share your thoughts in the comments section.
References:
- Easytrieve Plus manual by Pansophic.
- http://www.mvsforums.com/helpboards/viewtopic.php?p=11054
No comments:
Post a Comment