Need help regarding a JCL

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

Need help regarding a JCL

Postby Yogi » Wed May 10, 2017 8:15 pm


I wanted to create an JCL where month filed should be subtract by 1 from the current month from an input file.
Below is the format of file where date is in the format YYYYMM.


Please provide your guidance.
Posts: 1
Joined: Wed May 10, 2017 8:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need help regarding a JCL


Re: Need help regarding a JCL

Postby NicC » Wed May 10, 2017 8:22 pm

JCL does not do that. It only tells the machine what programs you want executed, the resources those programs require and the sequence of processing.
Your JCL will depend on what program you are going to use - if a utility then the utility manual will describe the JCL required. It will also describe the utility control statements.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Global moderator
Posts: 2670
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 101 times

Re: Need help regarding a JCL

Postby Robert Sample » Wed May 10, 2017 8:50 pm

Your post is pretty much useless as far as explaining what you want. For example, what does
create an JCL where month filed should be subtract by 1 from the current month
mean? Assuming that you meant "month field" instead of "month filed" (proofreading your post before hitting the Submit button is something everyone should do), where is the month field to be used? It could be part of a data set name, or a SET parameter in a job, or a utility control statement (such as SORT or IDCAMS), or a parameter for an EXEC ... in other words, you have told us NOTHING about month field and its usage. Also, since JCL cannot be changed once it is submitted, if you want to create month field and use it in the executing job -- that CANNOT be done, period. You could create another job to submit through the internal reader, but you cannot have a created value affecting the executing job.

And, by the way, most of the time date manipulation is done through the job scheduler for production jobs. So why are you not using your site's job scheduler for this?
Robert Sample
Global moderator
Posts: 3326
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 218 times

Re: Need help regarding a JCL

Postby Aki88 » Thu May 11, 2017 1:54 pm


Should you choose to use DFSORT or SYNCSORT (MFX) for your requirement, then you'll have to let us know which SORT your site has (DFSORT or SYNCSORT).
This can be checked by looking at the SORT step SYSOUT, if the messages start with ICE, it is DFSORT; if they start with WER, it is SYNCSORT.

Reason for asking this is, DFSORT has a quick solution for your problem, you can use the function SUBMONS provided by DFSORT to subtract months from a given date; have used it on numerous occasions in the past, and find it extremely useful, it saves a lot of code.

The site I am currently working with has SYNCSORT, I do not happen to have the updated documentation for it with me, so I cannot attest to this, but SUBMONS (at least for the version I have: SYNCSORT for z/OS gave me a SYNTAX ERROR when tested. In this case what you can do is, first subtract the month by using SUB function, then use IFTHEN construct to test the new month calculated so as to modify the year/century accordingly. Requires a bit of code, but doable.
Posts: 362
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 34 times

Return to JCL