Formatting output file after an INCLUDE condition in JCL - jcl

I want to create 3 outfiles depending on the below INCLUDE criteria from the input file. In addition I want only part of the record in the output file given by the below 3 BUILD's.
The issue now I think is that having multiple BUILD/OUTREC gives a duplicate error.
Is there any other way of achieving the same in JCL?
SORT FIELDS=COPY
OUTFIL FILES=01,
INCLUDE=(38,8,CH,EQ,C'AMSAM00'),
BUILD=(1,4,5:366,8)
OUTFIL FILES=02,
INCLUDE=(38,8,CH,EQ,C'AMSAM00',AND,390,1,CH,EQ,C'Y'),
BUILD=(1,4,5:382,8)
OUTFIL FILES=03,
INCLUDE=(38,8,CH,EQ,C'AMSAM00',AND,545,4,CH,NE,C'0000'),
BUILD=(1,4,5:C'013,',9:545,4)

This got a random poke, so...
Deuian I think was on the right lines, but left some complication and for user change didn't use the correct positions or type of output file, so would have been too much typing to apply to the situation...
OPTION COPY
INCLUDE COND=(38,8,CH,EQ,C'AMSAM00')
OUTFIL FILES=02,
INCLUDE=(390,1,CH,EQ,C'Y'),
BUILD=(1,4,382,8)
OUTFIL FILES=03,
INCLUDE=(545,4,CH,NE,C'0000',
AND,390,1,CH,NE,C'Y'),
BUILD=(1,4,C'013,',545,4)
OUTFIL FILES=01,SAVE,
BUILD=(1,4,366,8)
This presumes that SORTOUT will not be needed (it would just be a copy of the input file).
All the AMSAM00 records are INCLUDED, everything else (which is unwanted for the OUTFILs) is ignored.
OUTFIL 02 gets all the 'Y's.
OUTFIL 03 gets all the not 0000s which are not 'Y'
OUTFIL 01, moved to make it easier to follow, gets all the records which are not selected on another OUTFIL (by using SAVE).
All of the data which passes the INCLUDE will be on one of the three OUTFILs, and only one.
I have used OPTION COPY for clarity. SORT FIELDS=(... logically appears after the INCLUDE (wherever you code it) and by using OPTION COPY it is clear, up front, and in a logical place, that it is a COPY operation.
I have taken out the "columns" from the BUILDs (those numbers followed by a colon). If the data is going into that column automatically (which it is), then using the columns only creates work, introduces a new possibility of error, and makes the Sort Control Cards more difficult to maintain.
The question is unclear, so this is just a guess at what was wanted.
There was mention of OUTREC.
From the context, this is OUTREC on OUTFIL. There is a separate OUTREC statement. To avoid confusion (due to the "overloading" of OUTREC), don't use OUTREC on OUTFIL, which is for "backwards compatability", use the modern BUILD instead, which is entirely equivalent.
BUILD exists on INREC, OUTREC and OUTFIL, separately and as part of an IFTHEN. OUTREC as equivalent of BUILD is only on OUTFIL.
On INREC and OUTREC, FIELDS also has the "overloading" for the same reason (the backwards thing).
Don't use INREC FIELDS=, or OUTREC FIELDS= or OUTFIL OUTREC=, use BUILD in their place.

The below is what I think you are trying to do. Include 1 excludes what Include 2 and 3 will select, likewise Include 2 excludes what 1 and 3 will select. Include 3 is doing the same except excluding 1 and 2 includes.
Each FILE DD has only 1 record from the below and all the records are copied to the sortout
//SORTIN DD *
AMSAM00Y0000
AMSAM00N0001
AMSAM00Y0001
AMSAM00N0000
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=FILE1,
INCLUDE=(1,7,CH,EQ,C'AMSAM00',
AND,8,1,CH,NE,C'Y',AND,9,4,CH,EQ,C'0000'),
BUILD=(1,12)
OUTFIL FNAMES=FILE2,
INCLUDE=(1,7,CH,EQ,C'AMSAM00',AND,
8,1,CH,EQ,C'Y',AND,
9,4,CH,EQ,C'0000'),
BUILD=(1,12)
OUTFIL FNAMES=FILE3,
INCLUDE=(1,7,CH,EQ,C'AMSAM00',AND,
8,1,CH,NE,C'Y',AND,
9,4,CH,NE,C'0000'),
BUILD=(1,12)
FIlE1
AMSAM00N0000
FILE2
AMSAM00Y0000
FILE3
AMSAM00N0001
SORTOUT
AMSAM00Y0000
AMSAM00N0001
AMSAM00Y0001
AMSAM00N0000

Related

Syncsort - Write UNPAIRED records to SORTOUT file, and PAIRED records to PAIRED file

I'm able to save the UNPAIRED records to SORTOUT (this is what I want) using the following:
//SORT EXEC PGM=SORT,PARM='DYNALLOC=(SYSDA,255)'
//SORTMSGS DD SYSOUT=*
//SORTJNF1 DD DSN=FILE1,
// DISP=OLD,DCB=BUFNO=255
//SORTJNF2 DD DSN=FILE2,
// DISP=OLD,DCB=BUFNO=255
//SORTOUT DD DSN=FILEOUT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=(SYSDA,59),
// SPACE=(CYL,(500,100),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(25,4,A,115,20,A,135,4,A,140,4,A,5,20,A)
JOINKEYS FILE=F2,FIELDS=(5,4,A,9,20,A,29,4,A,33,4,A,37,20,A)
JOIN UNPAIRED,F2,ONLY
but I need to save the PAIRED records to a separate file. I tried the following statement but the PAIRED records don't get saved in my PAIRED file:
//SORT EXEC PGM=SORT,PARM='DYNALLOC=(SYSDA,255)'
//SORTMSGS DD SYSOUT=*
//SORTJNF1 DD DSN=FILE.F1,
// DISP=OLD,DCB=BUFNO=255
//SORTJNF2 DD DSN=FILE.F2,
// DISP=OLD,DCB=BUFNO=255
//SORTOUT DD DSN=FILE.SORTOUT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=(SYSDA,59),
// SPACE=(CYL,(500,100),RLSE)
//PAIRED DD DSN=FILE.PAIRED,
// DISP=(NEW,CATLG,DELETE),
// UNIT=(SYSDA,59),
// SPACE=(CYL,(500,100),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(25,4,A,115,20,A,135,4,A,140,4,A,5,20,A)
JOINKEYS FILE=F2,FIELDS=(5,4,A,9,20,A,29,4,A,33,4,A,37,20,A)
JOIN UNPAIRED,F2,ONLY
OUTFIL FNAMES=SORTOUT
OUTFIL FNAMES=PAIRED,SAVE
Edit 1: OP has mentioned (in the comments section of this answer), "I only want to keep the UNPAIRED records (F2 only) in my main SORTOUT dataset, and the PAIRED records (F2 only) in my PAIRED dataset." Paired records mean both F1 & F2. OP is basically looking for RIGHT JOIN. The SORT statements provided below are edited as per OP's requirement. Note that a REFORMAT statement is required unless a JOIN statement with the ONLY operand is specified.
You must use a method in Syncsort (which is called as indicator method in dfsort), to acheive what you're expecting. See below SORT statements.
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(25,4,A,115,20,A,135,4,A,140,4,A,5,20,A)
JOINKEYS FILE=F2,FIELDS=(5,4,A,9,20,A,29,4,A,33,4,A,37,20,A)
REFORMAT FIELDS=(F1:p,l,F2:p,l,?)
JOIN UNPAIRED,F2
OUTFIL FNAMES=BOTH,INCLUDE=(53,1,CH,EQ,C'B'),BUILD=(Build the columns you need from F1/F2)
OUTFIL FNAMES=UNPAIRED,INCLUDE=(53,1,CH,EQ,C'2'),BUILD=(Build the columns you need from F2)
where,
p - The position value indicates the first byte of the field relative to the beginning of the input record.
l - The length value indicates the length of the field.
Observe the ? in the REFORMAT FIELDS statement.
Quote from Syncsort for z/OS Programmer's guide:
?
This symbol is used to place a one-byte indicator in the reformatted
record that indicates whether the reformatted record is a paired or an
unpaired joined record. The indicator will be set to one of three
different printable values:
“B” if the reformatted record is a paired
record
“1” if the reformatted record is an unpaired record created
from the F1 file
“2” if the reformatted record is an unpaired record
created from the F2 file
More details:
Paired and unpaired F1/F2 records (indicator method).
Syncsort for z/OS Programmer's guide.
Hope this helps!

Adding amounts present in the character format

I have a PS with LRECL = 500 and RECFM=FB and in positions 70 through 82, I have the below amount fields in character format.
-000000042.99
-000000001.50
-000000003.00
-000000001.50
-000000042.99
+000000025.00
+000000019.52
+000000058.36
How can I convert this to Packed Decimal? My intention is I need to sum up the amounts field.Any ideas?
We have DFSORT. These amount fields are not in Packed decimal or numeric format. This file comes from an external system and I would like to sum all the amounts in this file through a JCL. I have to know the amount. For obvious reasons I do not wish to export this file to an excel and find the total there. I do not want to sum the totals based on a key. I just want to sum all the amounts in that file in that column.
//SORTA EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
TRAILER1=(TOTAL=(1,13,SFF,
EDIT=(SIIIIIIIIT.TT),
SIGNS=(+,-),
LENGTH=13))
//SORTIN DD *
-000000010.10
-000000020.20
+000000005.88
Now I am getting the desired output
-000000010.10
-000000020.20
+000000005.88
-24.42
It is a simple task using OUTFIL and its reporting functions:
//TOTALREP EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
TRAILER1=(TOTAL=(1,13,SFF,
EDIT=(SIIIIIIIIT.TT),
SIGNS=(+,-),
LENGTH=13))
//SORTIN DD *
-000000042.99
-000000001.50
-000000003.00
-000000001.50
-000000042.99
+000000025.00
+000000019.52
+000000058.36
SORTOUT contains:
-000000042.99
-000000001.50
-000000003.00
-000000001.50
-000000042.99
+000000025.00
+000000019.52
+000000058.36
+3.86
REMOVECC says don't include a printer Control Code, TRAILER1 is actioned at the end of the OUTFIL group, TOTAL (or TOT) says give a total of the position (here 1) length (13) and type (FS) (which you should look up in the DFSORT Application Programming Guide, which, for your version of DFSORT, can be found here: http://www-01.ibm.com/support/docview.wss?uid=isg3T7000080 . The EDIT, SIGNS and LENGTH dictate how the TOTAL value is going to appear.
UFF is Unsighed Free Format - This will strip out all non-numeric digits and process the result
SFF is Signed Free Format - This will strip out all non-numeric digits and process the result based on the presence, anywhere in the field, and that means anywhere, of one or more -If - is located, value will be negative otherwise positive.
FS
CSF These two are synonymous and can handle leading signs, but not decimal points. In the original example, the presence of the decimal point caused the number to be treated as only the decimal part. Everything in front of the decimal point was ignored, including the sign.

Passing symbol value using DFSORT to file

Statement: Earlier files were fetched from remote server location to mainframe. Then
those files content were get and saved at mainframe in a sequential file. But
sometime, some file names contained spaces. Due to this job fails while getting its
content.
Now to solve this problem, we fetched all files from server and separated good files
and bad files. Now we fetch only good file contents.
Problem: While renaming the files, we add prefix Process_ and Odate(fetched from Control M) to file name.
But earlier it was done in jcl as below through unix code.
Pseudo code:
print "rename " $1 " " "Process_" %%DAT "_" $1
We are fetching ODATE from a software control-M.
Jcl code:
//JOBNAME JOB (DEE),'Job Desc',CLASS=P,MSGCLASS=J,
// MSGLEVEL=(1,1),COND=(0,NE)
//* %%SET %%DAT = %%$ODATE
//STEP01 EXEC PROC1
PROC1 code:
//STEP02 EXEC PGM=SORT
//SORTIN DD DSN=DS.FILE1,
// DISP=SHR
//SORTOUT DD DSN=DS.FILE2,
// UNIT=SYSSF,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0),
// SPACE=(27920,(29,6),RLSE),
// DISP=(NEW,CATLG,DELETE)
//SYSIN DD DSN=DS.PARM(PARM03),DISP=SHR
PARM03 contains:
Here I am creating unix code to rename file:
SORT FIELDS=COPY
OUTFIL BUILD=(1:C'print "get " r_fi',18:SEQNUM, -
3,ZD,22:C'" //DD:upload"',/,1:C'print "rename " r_fi', -
21:SEQNUM,3,ZD,24:C' ', -
25:C' " " "Process_" %%DAT "_" r_fi',53:SEQNUM,3,ZD,80:X)
/*
The unix code which I am creating dynamically:
Here depending on the number of files p_fi01, p_fi02, p_fi03..... is generated.
I am saving the unix code in a dataset and passing it as instream to run.
The problem is, it is not able to get the value in DAT variable.
Is there any way, I can pass the value of D from jcl to proc and append it with
"Process_" using sort card in proc.
Example data:
File File1.csv contents are fetched and then renamed as Process_20140101_File1.csv
Assuming that the rest of your code is OK, it is fairly simple with DFSORT, using JPn, which is a special DFSORT symbol which allows the separate values of up to 10 parameters to be used in control cards.
Here is an example:
// SET INPARM='ABC'
//*
//STEP0100 EXEC PGM=SORT,PARM='JP0"&INPARM"'
//SYSOUT DD SYSOUT=*
//SYMNOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(JP0)
//SORTIN DD *
IRRELEVANT DATA, JUST AN EXAMPLE
I have used SET to create a JCL symbol, but you have yours already from CONTROL-M, so just replace &INPARM on the PARM with your CONTROL-M symbol.
JPn means JP0 through JP9. Three separate pieces of data could look like this:
//STEP0100 EXEC PGM=SORT,PARM='JP0"&INPARM1",JP1"&INPARM2",JP2"&INPARM3"'
The SYMNOUNT DD is optional, but very, very useful, as it will show you the translated values of the symbols.
Assuming that the rest of your code is correct, you would make this change:
25:C' " " "Process_"',JP0,C'"_" r_fi',53:SEQNUM,3,ZD,80:X)
And include a PARM on the EXEC card, PARM='JP0"[yourControl-M-symbol]"'
SyncSort does not have JPn, so that is lucky for you that you have DFSORT. A different technique would be required for SyncSort.

reference information data (i) of pds/ps using jcl

i want to use the referenced date of pds/ps in my JCL.
is there any way i can do it?
i basically want to delete several ps which have not been referenced in the past 2 months using JCL..
Use DFDMSdss (PGM=ADRDSSU) for this task. Chapter 9 of the DFDMSdss Storage Administration book describes how to use ADRDSSU to manage DASD space, and has a specific section demonstrating how to delete unused or stale data sets using the DUMP command to a DUMMY DD. Use PARM='TYPRUN=NORUN' during your testing as you tweak your filters.
reference
//DELETE EXEC PGM=ADRDSSU,PARM='UTILMSG=YES,TYPRUN=NORUN'
//OUTDD DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DUMp {DATASet | DS}(
BY((selector,operator,arg){,(selector,operator,arg),...})
{EXClude(dsn{,dsn,...})} {INClude(dsn{,dsn,...})}
|
EXClude(dsn{,dsn,...}) {INClude(dsn{,dsn,...})}
{BY((selector,operator,arg){,(selector,operator,arg),...})}
|
{FILterdd | FDD}(ddn)
{INDDname | IDD}(ddn) | {INDYnam | IDY}(vol{,unit})
{OUTDDname | ODD}(ddn{,ddn,...)
{DELete}
in the above i can put my condition in the BY clause.. My query now is whether i need to put the file name that has the list of files i need to delete in the INCLUDE clause ?

Symbolic JCL Confusion

I am a bit confused on how to create a symbolic variable in JCL for an assignment I am doing in my COBOL class.
For example, I am supposed to "Specify a symbolic parameter for the PARM option and specify TEST and APOST as the default."
How do I designate the "PARM" option to be a symbolic parameter?
EDIT: Forgive the oversight; it seems that I forgot to mention what OS I am running in. I am writing this JCL file in z/OS.
Thanks in advance!
EDIT:
#avisser:
So, what you're saying is that I can just call it "&PARM='TEST,APOST'" and, if I wanted to change that parameter when I run this proc with another JCL statement, the parms listed can be changed from the calling JCL?
EDIT:
#avisser:
Yeah, sorry, I really need to work on being more specific... In my COBOL JCL, I am calling the COBOL compiler (IGYCRCTL), the Linkage Editor (HEWL) and a program fetch (EXEC PGM=).
EDIT:
Perhaps it would help to see what my output is. I really do appreciate all those who have tried to help so far.
Output:
------ JES2 JOB STATISTICS ------
37 CARDS READ
61 SYSOUT PRINT RECORDS
0 SYSOUT PUNCH RECORDS
3 SYSOUT SPOOL KBYTES
0.00 MINUTES EXECUTION TIME
!! END OF JES SPOOL FILE !!
1 //KC03CEFA JOB ,'MATT R',MSGCLASS=H,TYPRUN=SCAN JOB07731
//*
2 //STEP01 EXEC PGM=IGYCRCTL,&REGION=248K,
// &PARM='TEST,APOST'
3 //STEPLIB DD DSN=IGY340.SIGYCOMP,DISP=SHR
/*
4 //SYSLIN DD &DSN=&&OBJSET,UNIT=DISK,SPACE=(TRK,(3,3)),
// &DISP=(NEW,PASS,DELETE)
5 //SYSPRINT DD SYSOUT=*
6 //SYSUT1 DD UNIT=DISK,SPACE=(CYL,(1,1))
7 //SYSUT2 DD UNIT=DISK,SPACE=(CYL,(1,1))
8 //SYSUT3 DD UNIT=DISK,SPACE=(CYL,(1,1))
9 //SYSUT4 DD UNIT=DISK,SPACE=(CYL,(1,1))
10 //SYSUT5 DD UNIT=DISK,SPACE=(CYL,(1,1))
11 //SYSUT6 DD UNIT=DISK,SPACE=(CYL,(1,1))
12 //SYSUT7 DD UNIT=DISK,SPACE=(CYL,(1,1))
//*
//*
13 //STEP02 EXEC PGM=HEWL,&COND=,&REAGION=2048K,
// &PARM=
14 //SYSLIB DD DSN=CEE.SCEELKED,DISP=SHR
15 //SYSLIN DD &DSN=&&OBJSET,&DISP=(OLD,DELETE)
16 //SYSLMOD DD DSN=&&TEMPLIB(PGM6),
// SPACE=(1024,(50,20,1)),UNIT=DISK,
// DISP=(NEW,CATLG,DELETE)
17 //SYSPRINT DD SYSOUT=*
18 //PRINTER DD SYSOUT=*
19 //SYSUT1 DD UNIT=DISK,SPACE=(TRK,(10,10))
//*
//*
20 //STEP01 EXEC PGM=PGM6,&PARM=TERMTHDACT(DUMP)
21 //STEPLIB DD DSN=&&TEMPLIB,DISP=SHR
22 //CEEDUMP
23 //SYSUDUMP
24 //PRINTER DD SYSOUT=*
25 //PRODUCTS DD DSN=KC02322.CSCI465.SP09(DATA1),DISP=SHR
26 //SYSIN DD *
!! END OF JES SPOOL FILE !!
STMT NO. MESSAGE
2 IEFC630I UNIDENTIFIED KEYWORD &REGION
2 IEFC630I UNIDENTIFIED KEYWORD &PARM
4 IEFC630I UNIDENTIFIED KEYWORD &DSN
4 IEFC630I UNIDENTIFIED KEYWORD &DISP
13 IEFC630I UNIDENTIFIED KEYWORD &COND
13 IEFC630I UNIDENTIFIED KEYWORD &REAGION
13 IEFC630I UNIDENTIFIED KEYWORD &PARM
15 IEFC630I UNIDENTIFIED KEYWORD &DSN
15 IEFC630I UNIDENTIFIED KEYWORD &DISP
20 IEFC630I UNIDENTIFIED KEYWORD &PARM
22 IEFC605I UNIDENTIFIED OPERATION FIELD
23 IEFC605I UNIDENTIFIED OPERATION FIELD
!! END OF JES SPOOL FILE !!
symbolic parameters are names preceded by an ampersand. When used in a JCL statement, at runtime they get converted into the supplied value. One way of creating them (on z/OS) is using a
// SET name = value
declaration.
If you use a PARM, you should design your program so that it can work with one. Perhaps the assignment is about how to do that (hint: linkage section). Or is JCL a part of your COBOL class?
TEST and APOST look to me like compiler directives. I don't know if you can specify them in your program, at my workplace we only supply them when calling the compiler.
EDIT:
Ok this is a bit unusual to me, as we tend to compile and run our programs in separate JCL streams. But anyway.
Taking your second statement:
2 //STEP01 EXEC PGM=IGYCRCTL,&REGION=248K,
// &PARM='TEST,APOST'
REGION and PARM are so-called positional parameters and they are keywords, not really meant to be presented as symbolic names, although you're free to do so (this will explain the "UNIDENTIFIED KEYWORD" messages).
The common use - when applicable - is to provide symbolic names for the operands of
such parameters. And obviously you have to define a value for them first, e.g:
// SET OPTIONS='TEST,APOST'
//STEP01 EXEC PGM=IGYCRCTL,REGION=248K,
// PARM=&OPTIONS
Ok, I did some digging, and, with the guidance that avisser gave me, I was able to figure out what I had to do. So, for future reference for anyone who might have this question (or one similar), here is what I figured out:
Step 1: Create a "PROC" with the variables you will be using.
ex. I wanted to use variables for the "PARM" in my COBOL compiler that had the default values of "TEST" and "APOST", so I wrote something like:
//PROC1 PROC CPARM='TEST,APOST',
Step 2: Use those newly defined symbolic parameters in your actual JCL step. The "&" character shows that whatever follows it is a symbolic parameter.
ex. I used the aforementioned "CPARM" for my COBOL compile step:
//COB EXEC PGM=IGYCRCTL,REGION=&CREGION,
// PARM='&CPARM'
Step 3: End your "PROC" with a "PEND" statement after your actual step.
ex. After I listed all of my variables and I listed all the steps for compilation (compiler name, where the compiler can be found, and, as can be seen right before the PEND statement, the SYSUT1-SYSUT7 statements), place your PEND keyword:
//SYSUT7 DD UNIT=DISK,SPACE=(CYL,(1,1))
// PEND
Step 4: Add any additional JCL steps and/or code to your source file and you're off!
Notes:
-You can have more than one PROC statement in a single JCL file. I had three: one for COBOL compilation, one for the linkage editor and one for the program fetch. I also have COBOL code in the same file that my PROC statements are in.
-This took place on an IBM Mainframe running z/OS.
-Above, it can be seen that my "CPARM" variable is set to the default of 'TEST,APOST'. It is possible to have a variable be null by default by simply leaving the field blank (ex. CPARM=,).
-You may have noticed that after the CPARM definition, there is a comma; this is because I have more variables after it. Please remember that the last symbolic parameter you create for any given PROC should have nothing following it (ie. no comma). You can, of course, place a comment line (//*), another PROC or actual code afterward, but the last symbolic parameter should have nothing following it on the same line.