Hi
I have two input files in jcl ....(Say Todays file and yesterday's file).
Can i use SORT to find if todays file is having RECORD Count greater than yertaerday ? aslo need to find the difference between the two files ....
You can use COUNT to count the number of records in each dataset and write the count to the output datasets say count1 and count2. Then compare both the output datasets count1 and count2.
What kind of difference you want to check in both the files?
Agreed. I have record counts in count1 and Count2 .
Now can i use SORT to find which file is having more number of records..and print the actual difference in record count in another output file ?
Thanks Bill !!
Just to clarify ....
Files are not Static / This is not once-off operation / nor it is backfill exercise.
let me put it simple
I have two files ..
1. XDMC.PDFS.TEST1 - (Created by batch job yesterday..)
2. XDMC.PDFS.TEST2 - (Created by batch job Today..)
Question
1. I want to find which file is having more number of records and by how much(Difference between the record counts of two files) ?
2. Can i use Subtract operation via SORT ?
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Still losing it.
Million ways to count records in sort. Just do any sort without dropping or inserting any records, and it tells you how many records it processed.
Take pencil, write down figure. Same thing with the second dataset. Subtract. As long as you remember which figure was which, then you have an answer.
If you still want the different data between the files, there is always JOINKEYS. Play around with that. I even suspect it will give you seperate counts in the output listing for the two files.
If you want to count and subtract with sort, then yes, probably. There have been a few examples recently. Search the forum for "trailer" and you'll probably get some useful examples.
Or if you have a file comparison product, you could try that, but then you don't get to subtract in sort (and the file comparison probably won't do the subtract, you'd have to actually look at the listing to get the answer).
I have assumed LRECL of 80 and FB for both the input files. The job below writes a trailer kind record indicating if previous day or current has more number of records and their respective difference in counts. If they have same number of records then it also indicates the same.
If this is not what you want, please provide sample input and expected output.
To answer your question, yes DFSort can use Subtract operation via SORT
Code:
//STEP0001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//CURRDAY DD *
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//PREVDAY DD *
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS F1=CURRDAY,FIELDS=(81,1,A)
JOINKEYS F2=PREVDAY,FIELDS=(81,1,A)
REFORMAT FIELDS=(F1:82,08,F2:82,08)
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(21:1,8,ZD,SUB,09,08,ZD,TO=ZD,LENGTH=08)),
IFTHEN=(WHEN=(21,8,ZD,GT,0),
BUILD=(C'CURRENT DAY FILE HAS ',21,8,ZD,M11,LENGTH=08,
C' MORE RECORDS THAN PREVIOUS DAY FILE')),
IFTHEN=(WHEN=(21,8,ZD,LT,0),
BUILD=(C'PREVIOUS DAY FILE HAS ',21,8,ZD,M11,LENGTH=08,
C' MORE RECORDS THAN CURRENT DAY FILE')),
IFTHEN=(WHEN=(21,8,ZD,EQ,0),
BUILD=(C'CURRENT DAY AND PREVIOUS DAY FILES HAVE THE ',
C'NUMBER OF RECORDS - ',01,8,ZD,M11,LENGTH=08))
SORT FIELDS=COPY
/*
//JNF1CNTL DD *
INREC OVERLAY=(81:C'A',7C'0',C'1')
SUM FIELDS=(82,8,ZD)
/*
//JNF2CNTL DD *
INREC OVERLAY=(81:C'A',7C'0',C'1')
SUM FIELDS=(82,8,ZD)
/*
OUTPUT
Code:
CURRENT DAY FILE HAS 00000002 MORE RECORDS THAN PREVIOUS DAY FILE
Thanks a lot !!! This similar to what i needed.
two more questions
1. Based on the output i get ...say
IF previous day file had more records than only need to execute next steps...Is posssible to do via JCL ?.....(I have seen return code being passed by COBOL and than evaluating it JCL but i dont want to it via COBOL)
2. Can we also perform division and multiplication operations via DFSORT? please suggest a location where i can find some documentation on the use Arithmetic operation via sort....
In general, if you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
IF previous day file had more records than only need to execute next steps...Is posssible to do via JCL ?.....(I have seen return code being passed by COBOL and than evaluating it JCL but i dont want to it via COBOL)
If I understand this correctly, you want to set different return codes based on condition(RC=0 if matched,4 if previous day count is higher and 8 if current day is higher). As far as I know,DFSort can only set one of the two return code(i.e. 0 if both counts are same or 4/8/16 if they are not same).
See if below works... This sets RC16 if counts don't match.
Can we also perform division and multiplication operations via DFSORT? please suggest a location where i can find some documentation on the use Arithmetic operation via sort....
Thanks I am going through the documents and trying to learn more on how to use Arithmetic operation via sort...
I want to do this
Input files LRECL = 133 and FBA
If previous day file is having 4% more records than current days file than
1. Copy file XFSD.RAFA.TA6AVA to XFSD.RAFA.TA6AVC (these are the files we are comparing)
2. Send out email (this is not problem...)
i have implemented above using cobol...but now need to implement same via JCL ...please suggest
ANKUL KHANDELWAL,
I wish you would have given all the requirements earlier in the first post itself...See if below jcl helps... I have kept results of intermediate arithmetic operations for you understand the logic.
This job sets Return code of 16 if previous day file is having 4% more records than current day and then later in the subsequent steps, you could use COND of JCL to make decision on emailing...