Page 1 of 1

call a proc based on data in the file

PostPosted: Mon Jul 04, 2016 5:44 pm
by Namrata_Singri
Hii All,

I have a file which unloads data from a table. The 71st position of this file contains a character which can be either A or M or W. I want to read this character in my jcl and accordingly call three procedures. If suppose the 71st character is "A" call proc1
else if the 71st character is "M" call proc2
else
call proc3 ..

How can I implement this logic in my jcl.
Please suggest me. Its an urgent need for me.

Re: call a proc based on data in the file

PostPosted: Mon Jul 04, 2016 6:47 pm
by steve-myers
You can't. Period. End of story.
  • JCL is fully analyzed before - sometimes long before - the job executes. Once analyzed, JCL cannot be altered.
  • JCL cannot read or analyze any data. Only programs that are run by JCL can do this.

Re: call a proc based on data in the file

PostPosted: Mon Jul 04, 2016 8:15 pm
by Robert Sample
I have a file which unloads data from a table
WRONG! You have a data set. The only files you see on a mainframe are tapes or stored in Unix System Services. If you are using z/OS and not using tape, you CANNOT have a file -- period.

Please suggest me. Its an urgent need for me.
So what? This is a voluntary forum -- people answer when / if they have the time and knowledge to do so. If you have an urgent need, convince your management to pay for a consultant to help you.

When someone posts about wanting to change submitted JCL as you have -- and the question comes up WAY too often -- the standard response is that you use a program written in the language of your choice (which could be SORT or another utility, or COBOL, or PL/I, or assembler, or Perl, or whatever) that creates the JCL you need and submits it as a separate job into the internal reader.

Re: call a proc based on data in the file

PostPosted: Mon Jul 04, 2016 9:08 pm
by Aki88
Hello,

In-line with what Mr. myers and Mr. Sample have said, you will need a 'utility' which 'can be executed' through a JCL to achieve what you want done; termminology is very important here.

<long post on>

Aside, there are multiple solutions to the problem, each depending upon your programming proficiency, be it a REXX solution or others.
A very simple way (with few more steps than required) would be, use *SORT to generate 3 output datasets using OUTFIL-FILES-INCLUDE options, in INCLUDE add your test conditions of 'A', 'M' or 'W'. If 'A' is present write this one record to datasets with names DSA, else DSM else DSW (or whatever you fancy). This is your first JCL step.
Next, have three IDCAMS/*SORT steps, which test if the earlier created datasets - DSA/DSM/DSW are empty or have atleast one record; depending upon this criteria, set a return code for these three steps; ideally only one of three datasets will have data at any time; hence an RC=0 (or your choice again till the time it adheres to RC rules for the utility) for this step, rest steps will have an RC=4/8/12 etc, your choice.
Next step- have an IF-THEN-ELSE JCL construct, which tests the RC set in the earlier steps, and executes PROC1/2/3 conditionally.
Simple, straight-forward solution, but requires more number of steps to achieve (though, can be done with fewer steps).


Note: Please understand that you haven't specified how many records there can be in your input dataset, you have also not specified if there can be multiple records having - 'A', 'M' or 'W' in the same dataset, or will there be only one, nor have you specified the RECFM/LRECL of your input datasets; there are more points which are also missed out in the request post, but these are the bare minimum required to cook up a working solution. I have assumed that your input DS has only 1 record, which has the control information on column- 71; if it is otherwise, the solution will/can change; though I'll leave it to you to to figure that one out.

</long post off>

Hope this helps.