|
View previous topic :: View next topic
|
| Author |
Message |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
I have 3 input files,
1) First file:
Total1
---------
05
2)Second file:
Total1
---------
20
output file should be.
Percentage
--------------
25
Now, I have one more file which contains total percentage,
3)Third file:
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. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, we'd need the full shebang,
Recfms/lrecls of all files. Start/length of all fields relevant. Sample data for all three input files, in the Code tags please.
Are the RC values fixed in stone? |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
I have 3 input files,
1) First file:
| Code: |
Total1
---------
05 |
2)Second file:
| Code: |
Total1
---------
20 |
output file should be.
| Code: |
Percentage
--------------
25 |
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. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Please ignore this reply alone. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You are showing three records on each input file. Do you mean one data record plus two heading records?
Isn't this a bit of "overkill"? |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
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 '---'. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Hello Bill,
Please consider it as a only data records, no headers and '-----'. |
|
| Back to top |
|
 |
prino
Senior Member

Joined: 07 Feb 2009 Posts: 1325 Location: Vilnius, Lithuania
|
|
|
|
| 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? |
|
| Back to top |
|
 |
Akatsukami
Global Moderator

Joined: 03 Oct 2009 Posts: 1787 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. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

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. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
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. |
I am ok with these RC (i.e. 0 and 4) |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Rohit Umarjikar wrote: |
[...]
I am ok with these RC (i.e. 0 and 4) |
Funny. I thought I asked about that yesterday. Maybe I was misunderstood. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
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 |
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Thanks Bill,
I would try this one. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Rohit Umarjikar,
The condition to set the RC is
| Code: |
IF (file1 value + file2 value ) = File3 Value
SET RC=0
ELSE
SET RC=4
END-IF
|
Use the following DFSORT JCL which will give you the desired results. Just concatenate file1 and file2 and treat it as single file and sum the values.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DSN=Your input Lrecl 20 File1,DISP=SHR
// DD DSN=Your input Lrecl 20 File2,DISP=SHR
//*
//INB DD Your input Lrecl 20 File3,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS F1=INA,FIELDS=(21,1,A)
JOINKEYS F2=INB,FIELDS=(21,1,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,3,F2:1,3)
INCLUDE COND=(1,3,ZD,EQ,4,3,ZD)
OPTION COPY,NULLOUT=RC4
//*
//JNF1CNTL DD *
INREC BUILD=(C'0',1,2,21:C'1')
SUM FIELDS=(1,3,ZD)
//*
//JNF2CNTL DD *
OPTION STOPAFT=1
INREC BUILD=(C'0',1,2,21:C'1')
//* |
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
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. |
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
| and the posts go on and on and on and on... |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Sometimes.... |
|
| Back to top |
|
 |
Skolusu
Senior Member
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? |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
| Quote: |
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? |
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%. |
|
| Back to top |
|
 |
Skolusu
Senior Member
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.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DSN=Your input Lrecl 20 File1,DISP=SHR
// DD DSN=Your input Lrecl 20 File2,DISP=SHR
//*
//INB DD Your input Lrecl 20 File3,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(21,1,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(21,1,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,8,F2:1,3)
INREC OVERLAY=(15:(5,3,ZD,MUL,+100),DIV,1,3,ZD,EDIT=(TTT))
OUTFIL NULLOFL=RC4,INCLUDE=(9,3,ZD,EQ,15,3,ZD)
//*
//JNF1CNTL DD *
OPTION STOPAFT=2
INREC IFTHEN=(WHEN=INIT,BUILD=(C'0',1,2,21:SEQNUM,1,ZD)),
IFTHEN=(WHEN=GROUP,RECORDS=3,PUSH=(5:1,3))
//*
//JNF2CNTL DD *
OPTION STOPAFT=1
INREC BUILD=(C'0',1,2,21:C'2')
//* |
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
|
|
Thanks Skolusu...
Great help |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|