i have a Zoned decimal field (start pos 31, length 9) in file, where i need to divide this field by 1000 and rounded.
using the below Syncsort syntax i could achieve it, but there is an issue with rounding.
31,9,ZD,DIV,+1000,ZD,LENGTH=9
for eg, For value 00000487C (000004873), after the above arithmetic operation, i am getting it rounded as 4.
Since 000004873/1000 gives 4.87 (more than 4.50), I need to round it to 5.
let me know what else need I need to do to achive this
Thanks
Rounding issue after computation
-
- Global moderator
- Posts: 3006
- Joined: Fri Apr 18, 2008 11:25 pm
- Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
- Referer: www.ibmmainframes.com
Re: Rounding issue after computation
how would You do it by pencil and paper ???
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
-
- Global moderator
- Posts: 3805
- Joined: Tue Jan 25, 2011 12:02 am
- Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
- Referer: Google
Re: Rounding issue after computation
Since SORT does not do rounding, why do you think you are getting it "rounded as 4"?
If you need rounding, you have to code it yourself. Something like this (untested):
The 3Z will put three zoned-decimal zeros in the first three positions of your field. The first IFTHEN will add one to the first six digits of your source number and store the result after the three zeros. The second, like an ELSE, will just store the first six digits after the three zeros.
If you need rounding, you have to code it yourself. Something like this (untested):
Code: Select all
INREC IFTHEN=(WHEN=(37,1,CH,GE,C'5'),
OVERLAY=(31:3Z,31,6,ZD,ADD,+1,LENGTH=6)),
IFTHEN=(WHEN=NONE,
OVERLAY=(31:3Z,31,6))
The 3Z will put three zoned-decimal zeros in the first three positions of your field. The first IFTHEN will add one to the first six digits of your source number and store the result after the three zeros. The second, like an ELSE, will just store the first six digits after the three zeros.
-
- Global moderator
- Posts: 2105
- Joined: Thu Jun 03, 2010 6:21 pm
- Skillset: Assembler, JCL, utilities
- Referer: zos.efglobe.com
Re: Rounding issue after computation
Assuminng 00000487C is hexadecimal, it is not "zoned decimal." It is packed decimal.
-
- Posts: 6
- Joined: Fri Apr 13, 2012 5:08 pm
- Skillset: COBOL, JCL, VSAM, DB2
- Referer: through net
Re: Rounding issue after computation
00000487C is zoned decimal value itself. The input field is zoned decimal format
-
- Global moderator
- Posts: 2105
- Joined: Thu Jun 03, 2010 6:21 pm
- Skillset: Assembler, JCL, utilities
- Referer: zos.efglobe.com
Re: Rounding issue after computation
OK. After I put up my post, I realized there was a good chance I goofed. I let my fingers get into trouble before thinking.
I'm pretty sure 000004873/1000 = 4. The remainder is dropped and lost. However, I don't use Syncsort, and it's not in the environment I use, so I can't be sure about that.
I'm pretty sure 000004873/1000 = 4. The remainder is dropped and lost. However, I don't use Syncsort, and it's not in the environment I use, so I can't be sure about that.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 3
- 5020
-
by jrcox
View the latest post
Wed Jul 29, 2020 7:52 pm
-
- 1
- 1333
-
by jcdm
View the latest post
Mon Oct 24, 2022 6:10 pm
-
- 2
- 2257
-
by Terry Heinze
View the latest post
Tue Feb 15, 2022 9:13 pm
-
-
Code conversion issue while reading JCL using REXX
by vsgurunath » Fri Jun 19, 2020 10:19 pm » in CLIST & REXX - 11
- 4292
-
by vsgurunath
View the latest post
Thu Jun 25, 2020 4:08 pm
-
-
-
Issue Create/delete ALIAS IDC3013I and then IDC3012I
by jcdm » Thu Dec 05, 2024 9:26 pm » in VSAM/SMS - 1
- 1694
-
by willy jensen
View the latest post
Fri Dec 06, 2024 12:04 am
-