Now, I have one more file which contains total percentage,
3)Third file:
Code:
Percentage
-------------
90
Here, I have to check if 25>90 then set the return code of the step to 8 else set the return code to 4.
Its FB file and LRECL=20 for all of the files.
Please treat the values provided as the sample data.I mean all the time these 3 input files will be containing only one record.
Yes the RC values are fixed in all the time.
Sorry for getting you misunderstood on this,
Just the numbers are the actual data present in al off these files, please idnore all the headers and '---'.
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
prino wrote:
The time between your first and last posting is 1h26m. Wasn't that enough to code a simple COBOL, PL/I or REXX program to do what's needed?
Wrote, compiled, linked, and tested a PL/I program in 00:33. My mainframe is running hella slow due to storage issues just now, else I probably could have knocked ten minutes off that time.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
Here, I have to check if 25>90 then set the return code of the step to 8 else set the return code to 4.
Passing back RC=4 or RC=8 with DFSORT is not straightforward. Passing back RC=0 or RC=4 would be.
As others have said, DFSORT is probably NOT the ideal program for this kind of thing. We could probably cobble something together to do it but a simple program in PL/I, REXX, COBOL, etc would probably be a better choice.
Akatsukami, Prino:
Yes, you all are right, but I don't have a requirement to include any COBOL, REXX,PL/I modules, otherwise I would not have posted this here.
Moreover, I am trying to do this with the help of SAS (Client is ok with it)parallely, but any help related to DFSORT would be appriciated.
Quote:
Passing back RC=4 or RC=8 with DFSORT is not straightforward. Passing back RC=0 or RC=4 would be.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Here's the cobble requested:
Since there are only a total of three input records, and their order can be guaranteed if you get the concatenation correct, this uses two GROUPs to pass data from one record to another and then calculate on that another record.
If you bust your warning percentage, no record is written to file F1 OUTFIL, and the NULLOFL=RC4 gets you your 4. If not busted, a record of inconsequential content is written and you get the 0 because there is data on the file.
Don't gouge yourself on the nails. An expert cobbler could make a better job of it, I'm sure.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOFF1 DD DUMMY this is to get the RC0/RC4, but content is not relevant
//SORTIN DD your amout used dataset
// DD your maximum amount dataset
// DD your warning percentage dataset
//SORTOUT DD your calculated percentage output dataset
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,RECORDS=3,PUSH=(21:1,2,SEQ=1)),
IFTHEN=(WHEN=(23,1,CH,EQ,C'2'),
OVERLAY=(5:21,2,ZD,MUL,+100,
DIV,1,2,ZD,
TO=ZD,LENGTH=2))
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(23,1,CH,EQ,C'2'),PUSH=(30:5,2)),
IFTHEN=(WHEN=(23,1,CH,EQ,C'3',
AND,30,2,CH,GT,1,2,CH),
OVERLAY=(5:C'X'))
OUTFIL INCLUDE=(23,1,CH,EQ,C'2'),BUILD=(5,2,80:X)
OUTFIL FILES=F1,INCLUDE=(5,1,CH,NE,C'X',
AND,23,1,CH,EQ,C'3'),BUILD=(1,80),
NULLOFL=RC4
But I don't see the % is getting calculated based on the file1 and file 2. I actually would like to get % done by the use of file1 and file2 record and then check that % value with % value present in the file3.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
Rohit Umarjikar wrote:
Kolusu,
Thanks for the update.
But I don't see the % is getting calculated based on the file1 and file 2. I actually would like to get % done by the use of file1 and file2 record and then check that % value with % value present in the file3.
Hope I am keeping my words same.
Ok My mistake about not calculating the % but how did you arrive at the percentage?
5 = (20 * X)/100 and now I need to calculate the X?
in the above case X would result in 25.
What happens if File1 value is greater than file 2 value? or it exceeds 100?
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
Rohit Umarjikar wrote:
Yes, you are right the 25 value should be the %.
And file1 value will be at max equals to file 2 value so it will be max of 100%.
Rohit Umarjikar,
You only show 2 digit values and when you calculate the percentage it might result in 3 digits (100%) and you want to compare this to a 2 digit number. Is the data just 2 bytes? or 3 bytes? There are no checks to see if the numbers you pass are valid numbers. what happens if the input has negative numbers or spaces or zeroes?
Assuming that each of the input file has just 1 record and the first 2 bytes have the data,
here is a job which would set the return code to 4 if the calculated percentage is NOT equal to the percentage value in file 3.