Strange result in SORT Arithmatic Division
Moderators: Frank Yaeger, Moderator Group
-
- Member
- Posts: 10
- Joined: Fri Jun 20, 2008 4:21 pm
- Location: Kolkata, India
Strange result in SORT Arithmatic Division
Hi all,
I have a file in which the 17th and 18th positions have two numeric fields, I want to divide the first one by the second one and populate the 43rd position with a particular edit.
The card I have used in the OUTREC for this is -
OUTREC OVERLAY=(1,33,34:C'|RATIO = ',
43:(17,6,ZD,MUL,+10000000000),DIV,28,6,ZD,
EDIT=(IIIT.TTTTT),53:C'|')
SORT FIELDS=(1,2,CH,A)
However, I am getting some strange values in the 43rd column like sown.
AK - 000001|F - 000000|M - 000001|RATIO = 0.00000|
AL - 000029|F - 000014|M - 000015|RATIO = 3571.42857|
AR - 000013|F - 000005|M - 000008|RATIO = 1700.68027|
AZ - 000032|F - 000012|M - 000020|RATIO = 1581.02766|
CA - 000242|F - 000100|M - 000142|RATIO = 975.60975|
CO - 000028|F - 000012|M - 000016|RATIO = 1403.50877|
CT - 000070|F - 000030|M - 000040|RATIO = 833.33333|
Can somebody please explain me why is this coming and what can be the remedy. I have multiplied the first field by 10000000000 as this was a requirement.
I have a file in which the 17th and 18th positions have two numeric fields, I want to divide the first one by the second one and populate the 43rd position with a particular edit.
The card I have used in the OUTREC for this is -
OUTREC OVERLAY=(1,33,34:C'|RATIO = ',
43:(17,6,ZD,MUL,+10000000000),DIV,28,6,ZD,
EDIT=(IIIT.TTTTT),53:C'|')
SORT FIELDS=(1,2,CH,A)
However, I am getting some strange values in the 43rd column like sown.
AK - 000001|F - 000000|M - 000001|RATIO = 0.00000|
AL - 000029|F - 000014|M - 000015|RATIO = 3571.42857|
AR - 000013|F - 000005|M - 000008|RATIO = 1700.68027|
AZ - 000032|F - 000012|M - 000020|RATIO = 1581.02766|
CA - 000242|F - 000100|M - 000142|RATIO = 975.60975|
CO - 000028|F - 000012|M - 000016|RATIO = 1403.50877|
CT - 000070|F - 000030|M - 000040|RATIO = 833.33333|
Can somebody please explain me why is this coming and what can be the remedy. I have multiplied the first field by 10000000000 as this was a requirement.
Regards,
Captain N.
Captain N.
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
I don't know how you got
3571.42857
from 14 and 15 with that statement. When I do it with DFSORT, I get:
3333.33333
which is what I'd expect. Here's why:
DFSORT does integer arithmetic (it throws away the decimal places), so:
(14 * 10000000000)/15 = 9333333333
There are 10 digits in that result but your edit mask of IIIT.TTTTT only has 9 digits, so the digits are mapped right to left and the first digit (the 9 gets dropped). The result is:
3333.33333
If you had 10 digits in your edit mask as IIIIT.TTTTT, the leading digit wouldn't be dropped and you'd get:
93333.3333
But I don't know where you got
3571.42857
You'd have to prove to me that DFSORT produced that result with the input you showed.
By the way, since you're using OVERLAY, you don't need 1,33 - OVERLAY will leave that data as is.
3571.42857
from 14 and 15 with that statement. When I do it with DFSORT, I get:
3333.33333
which is what I'd expect. Here's why:
DFSORT does integer arithmetic (it throws away the decimal places), so:
(14 * 10000000000)/15 = 9333333333
There are 10 digits in that result but your edit mask of IIIT.TTTTT only has 9 digits, so the digits are mapped right to left and the first digit (the 9 gets dropped). The result is:
3333.33333
If you had 10 digits in your edit mask as IIIIT.TTTTT, the leading digit wouldn't be dropped and you'd get:
93333.3333
But I don't know where you got
3571.42857
You'd have to prove to me that DFSORT produced that result with the input you showed.
By the way, since you're using OVERLAY, you don't need 1,33 - OVERLAY will leave that data as is.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Member
- Posts: 10
- Joined: Fri Jun 20, 2008 4:21 pm
- Location: Kolkata, India
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
Well, at the very least you should make the edit mask larger so you can see the full result rather than a truncated result.
It would be helpful to "display" the relevant input fields and the actual output values you received for those input fields with and without truncation, all in the same line, as well as the DFSORT messages.
It would be helpful to "display" the relevant input fields and the actual output values you received for those input fields with and without truncation, all in the same line, as well as the DFSORT messages.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Member
- Posts: 10
- Joined: Fri Jun 20, 2008 4:21 pm
- Location: Kolkata, India
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
Sanity check. Let's simplify things.
When I run this with DFSORT:
I get this output:
Please run this job and show what you get along with the //SYSOUT messages. (The output you say you get with the input and control statements you say you use doesn't seem to make any sense, so let's simplify things).
When I run this with DFSORT:
Code: Select all
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AK - 000001|F - 000000|M - 000001|
AL - 000029|F - 000014|M - 000015|
AR - 000013|F - 000005|M - 000008|
AZ - 000032|F - 000012|M - 000020|
CA - 000242|F - 000100|M - 000142|
CO - 000028|F - 000012|M - 000016|
CT - 000070|F - 000030|M - 000040|
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,2,CH,A)
OUTREC BUILD=(17,6,ZD,X,28,6,ZD,X,
(17,6,ZD,MUL,+10000000000),DIV,28,6,ZD)
/*
Code: Select all
0 1 0
14 15 9333333333
5 8 6250000000
12 20 6000000000
100 142 7042253521
12 16 7500000000
30 40 7500000000
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Member
- Posts: 10
- Joined: Fri Jun 20, 2008 4:21 pm
- Location: Kolkata, India
-
- Member
- Posts: 10
- Joined: Fri Jun 20, 2008 4:21 pm
- Location: Kolkata, India
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
You're welcome. Glad to hear it was a "user error". Thanks for letting us know. .
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
DIV - Arithmetic Division in Sort - question
Hi Frank, Good morning!
Is it possbile to round the decimal values which comes as the output while using SORT IN / OUTREC - DIV option.
I am new to this portal, if its posted somewhere else please provide me the URL.
Thank you!
Anies
Is it possbile to round the decimal values which comes as the output while using SORT IN / OUTREC - DIV option.
I am new to this portal, if its posted somewhere else please provide me the URL.
Thank you!
Anies
1) You should not address posts to individuals.
2) Frank retired some time ago and no longer participates in the forums
3) Generally, posting URLs of other forums is not encouraged.
4) This topic is 6 years old. You should not reply post to old topics.
5) Your requirement is not to do with the topic of this thread - you should have started a new thread. Maybe a moderator will split it off into its own thread.
6) Welcome to the forum!
2) Frank retired some time ago and no longer participates in the forums
3) Generally, posting URLs of other forums is not encouraged.
4) This topic is 6 years old. You should not reply post to old topics.
5) Your requirement is not to do with the topic of this thread - you should have started a new thread. Maybe a moderator will split it off into its own thread.
6) Welcome to the forum!
Regards
Nic
Nic
I Apologize, i did not get response when i started a new topic.
so writing it up here.
This is my SORT statement
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FILES=1,
OUTREC=((51,13,ZD,MUL,+10),DIV,40,11,ZD,EDIT=(TT.TT),LENGTH=5)
/*
Input:
51,13 - input - 0000000462018 - PIC 9(12)V9
40,11 - input - 00000030235 - PIC 9(11)
Output:
01.52
Actual Output must be 01.53
I was not able to get the Rounded value.
so writing it up here.
This is my SORT statement
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FILES=1,
OUTREC=((51,13,ZD,MUL,+10),DIV,40,11,ZD,EDIT=(TT.TT),LENGTH=5)
/*
Input:
51,13 - input - 0000000462018 - PIC 9(12)V9
40,11 - input - 00000030235 - PIC 9(11)
Output:
01.52
Actual Output must be 01.53
I was not able to get the Rounded value.
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page