call a proc based on data in the file



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

call a proc based on data in the file

Postby Namrata_Singri » Mon Jul 04, 2016 5:44 pm

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.
Namrata_Singri
 
Posts: 13
Joined: Mon Jun 20, 2016 6:18 pm
Has thanked: 2 times
Been thanked: 0 time

Re: call a proc based on data in the file

Postby steve-myers » Mon Jul 04, 2016 6:47 pm

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.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: call a proc based on data in the file

Postby Robert Sample » Mon Jul 04, 2016 8:15 pm

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.

These users thanked the author Robert Sample for the post:
Namrata_Singri (Tue Jul 05, 2016 4:47 pm)
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: call a proc based on data in the file

Postby Aki88 » Mon Jul 04, 2016 9:08 pm

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.

These users thanked the author Aki88 for the post:
Namrata_Singri (Tue Jul 05, 2016 4:46 pm)
Aki88
 
Posts: 381
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post