Tailor and run jcl programmatically using rexx - mainframe

Monthly, I need to run a set of JCLs. These JCLs has some hardcoded parameters that I need to be changed every month (eg: the year/month of the source file).
On the other hand, these JCL need to be run for many source files:
LEA.D.1804.L03
LEA.D.1804.L04
LEA.D.1804.L05
and so on..
Here is an excerpt of a JCL:
//*---------------------------------------------------------------------
//STEP01 EXEC PGM=OSGENER
//*---------------------------------------------------------------------
//SYSPRINT DD SYSOUT=T
//*
//SYSUT1 DD DSN=LEA.D.1804.L03,DISP=SHR
//*
//SYSUT2 DD DSN=LEA.L03.DAT,UNIT=SYSDA,DISP=(,PASS),
// DCB=(RECFM=FB,LRECL=135,BLKSIZE=0),SPACE=(CYL,16,RLSE)
//SYSIN DD *
RCOUT 4,,'016011'
RCOUT 4,,'016012'
RCOUT 4,,'016021'
COPY
I believe (and hope) that there must be some way to use params instead of these harcoded values.
I think that I could use rexx to call these JCLs programmatically, looping the source files.
First, is this possible?
How do I do to use vars/params in my JCLs instead of harcoded values?
(I also know that there is something called file tailoring but I can't understand how I should use it)
I come from PHP, Java, Javascript and those kind of langs stacks. Please be as clear and explicit as possible.
Thanks!

I'm going to presume that file tailoring isn't a requirement because it isn't necessary in order to solve your problem.
My recommendation would be to code a procedure, cataloged or in-stream, and then execute it with your different parameters.
//MYPROC01 YY=SUPPLYTWODIGITYEAR,
// MM=SUPPLYTWODIGITMONTH,
// LLQ=SUPPLYLOWLEVELQUALIFIER
//*
//*---------------------------------------------------------------------
//STEP01 EXEC PGM=OSGENER
//*---------------------------------------------------------------------
//SYSPRINT DD SYSOUT=T
//*
//SYSUT1 DD DSN=LEA.D.&YY.&MM..&LLQ,DISP=SHR
//*
//SYSUT2 DD DSN=LEA.&LLQ..DAT,UNIT=SYSDA,DISP=(,PASS),
// DCB=(RECFM=FB,LRECL=135,BLKSIZE=0),SPACE=(CYL,16,RLSE)
//SYSIN DD *
RCOUT 4,,'016011'
RCOUT 4,,'016012'
RCOUT 4,,'016021'
COPY
//*
// PEND
//*
//LLQ3 EXEC PROC=MYPROC01,YY=&LYR2,MM=&MON,LLQ=L03
//LLQ4 EXEC PROC=MYPROC01,YY=&LYR2,MM=&MON,LLQ=L04
//LLQ5 EXEC PROC=MYPROC01,YY=&LYR2,MM=&MON,LLQ=L05
//*
this is just freehand, no guarantees I haven't introduced a typo
The &LYR2 and &MON dynamic system symbols were new with z/OS 2.3, and procedures gained the capability of housing in-stream data a couple of releases prior to that.
Absent the ability to use system symbolics, I suggest talking to whomever is responsible for scheduling jobs in your shop. Most mainframe shops have a job scheduling package and these tend to have powerful date manipulation capabilities.

In our site, we do have some jobs which run in Monthly basis and the only parameter which keeps changing is the Month & year (in MMMYY format ex: APR18). The jobs are scheduled in Control-M. The MMM & YY variables to be used in the JCL symbolic overrides are set by Control-M based on current month/year.
%%IF %%OMONTH EQ 01
%%SET %%MON = JAN
%%GOTO ENDIT
%%ENDIF
%%IF %%OMONTH EQ 02
%%SET %%MON = FEB
%%GOTO ENDIT
%%ENDIF
%%IF %%OMONTH EQ 03
%%SET %%MON = MAR
%%GOTO ENDIT
%%ENDIF
%%IF %%OMONTH EQ 04
%%SET %%MON = APR
%%GOTO ENDIT
%%ENDIF
%%IF %%OMONTH EQ 05
%%SET %%MON = MAY
%%GOTO ENDIT
%%ENDIF
%%IF %%OMONTH EQ 06
%%SET %%MON = JUN
%%GOTO ENDIT
%%ENDIF
%%IF %%OMONTH EQ 07
%%SET %%MON = JUL
%%GOTO ENDIT
%%ENDIF
%%IF %%OMONTH EQ 08
%%SET %%MON = AUG
%%GOTO ENDIT
%%ENDIF
%%IF %%OMONTH EQ 09
%%SET %%MON = SEP
%%GOTO ENDIT
%%ENDIF
%%IF %%OMONTH EQ 10
%%SET %%MON = OCT
%%GOTO ENDIT
%%ENDIF
%%IF %%OMONTH EQ 11
%%SET %%MON = NOV
%%GOTO ENDIT
%%ENDIF
%%IF %%OMONTH EQ 12
%%SET %%MON = DEC
%%GOTO ENDIT
%%ENDIF
%%LABEL ENDIT
The above lines are usually commented out in the JCL and they are meant to be valid only on the Control-M system. In the JCL, we assign the following Control-M variable names (%%MON & %%OYEAR) to MMMYY symbolic override.
MMMYY=%%MON.%%OYEAR
During runtime of the JCL, the values are substituted. These jobs are scheduled in Control-M to run in a particular time of the month and they don't need manual intervention. Hope this helps.
As cschneid said, I strongly suggest you to get in touch with the schedulers in your site.

Related

Will the Excel "Date()" function will corrected, in order to handle older years (before 1900)?

I was just having a look at this other question and I thought "But why don't you use the standard Excel's Date() function", but after some tryouts, I understood why:
Year Month Day ±Date(Y, M, D)
2023 04 08 08/04/2023
1734 04 08 08/04/3634 => wrong! (3634 = 1734 + 1900)
1899 04 08 08/04/3799 => wrong! (3799 = 1899 + 1900)
1900 04 08 08/04/1900
The Microsoft webpage about the Date() function does not mention anything about this bug. Is there any knowledge on when this will be tackled?

How do I use a list of Dates from .txt as input in shell script?

I'm trying to extract dates from a .nc file and I wanted to write a script to automate the process by using a .txt file, the data looks like this:
1995 04 05
1995 06 12
1995 06 30
1995 07 16
1995 07 19
1995 07 20
1995 07 28
1996 03 09
1996 04 25
1996 08 13
I want to assign a variable for years, months and days separately e.g. , so that It would take the date from each line as input it in a command like this:
cdo seltimestep,$DD "mon_$MM.nc" "/Desktop/2020/output/$YYYY-$MM-$DD.nc"
I previously made a script similar to this but I had to input each date manually.
You can read input file line by line and then use bash array to split the dates.
#!/bin/bash
while read -r line; do
dateArray=( $line )
echo "YYYY: ${dateArray[0]}, MM: ${dateArray[1]}, DD: ${dateArray[2]}"
done < input.file
Using awk:
awk '{printf("YYYY: %04d, MM: %02d, DD: %02d\n", $1, $2, $3)}' input.txt
The actual awk program is very straightforward, printing formatted fields of each record line:
{
printf("YYYY: %04d, MM: %02d, DD: %02d\n", $1, $2, $3)
}
Read can create all needed vars from line at once
while read -r year month day; do
echo "Year: $year Month: $month Day: $day"
done < file

Parsing date with timezone

I am trying to match the following date with logstash:
Thu Apr 07 13:09:40 BST 2016
Using the following:
date {
match => ["report_time", "EEE MMM dd HH:mm:ss z yyyy"]
target => "#timestamp"
}
But this results in the following error:
Failed parsing date from field {:field=>"report_time",
:value=>"Thu Apr 07 13:08:03 BST 2016",
:exception=>"Invalid format: \"Thu Apr 07 13:08:03 BST 2016\"
is malformed at \"BST 2016\"", :config_parsers=>"EEE MMM dd HH:mm:ss z yyyy",
:config_locale=>"default=en_US", :level=>:warn}
I think it's the z part that is causing the issue, can someone please explain how I can parse the timezone i.e BST?
It is a know issue of JODA (which is used by Logstash) which is not able to parse timezone names, in your case it's BST. (Timezone Name)
Reference Link:- https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html#plugins-filters-date-timezone
To overcome this problem you can replace Timezone Name by the timezone offset.
You can change BST into equivalent offset such as +0100.
To do so add the following into your logstash configuration file:
mutate {
gsub => ["report_time", "BST", "+0100"]
}
It will replace as following:
"message" => "Thu Apr 07 13:09:40 BST 2016",
"report_time"=> "Thu Apr 07 13:09:40 +0100 2016",

How to Increment a day in Date using Node.js

I have date object like this "Tue Sep 02 2014 13:34:17 GMT+0500 (Pakistan Standard Time)"
I want increment a day in the date object using node.js.
I.E.
var myDate = "Tue Sep 02 2014 13:34:17 GMT+0500 (Pakistan Standard Time)";
please mention how to increment a day in above myDate.
Thanks
Try this
var myDate = new Date("Tue Sep 02 2014 13:34:17 GMT+0500 (Pakistan Standard Time)");
myDate.setDate(myDate.getDate() + 1);
alert(myDate);

Linux variable expansion problem ?

I'd like to get a sequence of number like this 01,02,..,30
But if I use {01..30}, I will get 1,2,..30, the zero before single-digit number is missing.
How can I get the format like 01,02..30 ? Thanks in advance
In Bash4, your {01..30} brace expansion actually works as you want it to. If you are on Bash3 or lower you can use the printf builtin along with the brace expansion to get what you want without resorting to external commands.
$ printf "%02d " {1..20}
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
seq -w 1 30 # ought to work
as in:
for number in $(seq -w 1 30); do
touch /tmp/bleah$number.dat
done

Resources