View previous topic :: View next topic
|
Author |
Message |
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
I/P Field PIC S9(14).
O/P Field PIC S9(13)V9(02) COMP-3.
There is no decimal point or value (after decimal point) in input.
But output need to have the decimal point (and 2 zeros after point).
COBOL move example:
Code: |
I/P
0000000009476F
FFFFFFFFFFFFFC
00000000094766
O/P
mÎ-
00009760
0000460C
|
Sort card I used:
OVERLAY=(X:Y,14,ZD,TO=PD,LENGTH=8
O/P I got
Code: |
.....mÎ%
00000976
0000046C
|
The O/P from SORT is missing the 00 after decimal point.
This is what I see in the manual.
Quote: |
deccon,to or (deccon),to
specifies that a converted decimal constant is to appear in the reformatted
OUTFIL output record. The decimal constant must be in the form +n or −n
where n is 1 to 31 decimal digits. The sign (+ or −) must be specified. A
decimal constant produces a signed, 31-digit zoned decimal (ZD) result to be
converted as specified.
The default number of digits (d) used for conversion is 15 for a decimal
constant with 1 to 15 significant digits, or 31 for a decimal constant with 16 to
31 significant digits.
See to under p,m,f,to for further details on the to fields you can use.
Sample Syntax:
OUTFIL FNAMES=OUT1,
OUTREC=(6:+0,TO=PD,LENGTH=6,+0,TO=PD,LENGTH=6,/,
6: (-4096),ZD,LENGTH=12)
|
But I am not able to apply this to my problem.
Your guidance is much appreciated. Thanks in advance. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You aren't trying to convert a Constant, so forget that bit.
There are no decimal places in fields which Sort supports, therefore all decimal places are implied.
To imply two decimal places in your packed field, you can multiply by +100. Something like the following:
Code: |
OVERLAY=(X:Y,14,ZD,MUL,+100,TO=PD,LENGTH=8 |
|
|
Back to top |
|
|
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
Thanks a lot Bill. |
|
Back to top |
|
|
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
Is there any other way to do this...?
Just curious... if somebody adds decimal to the input file then the output value will be different than expected.
Please correct me if my understanding is wrong!! |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
abdul.faras wrote: |
I/P Field PIC S9(14).
O/P Field PIC S9(13)V9(02) COMP-3.
There is no decimal point or value (after decimal point) in input.
But output need to have the decimal point (and 2 zeros after point).
|
What is the expected output for the input value 12345678901234?
Thanks, |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
But output need to have the decimal point (and 2 zeros after point). |
You said this in your first post and somebody showed you how to do what you asked for.
Quote: |
Just curious... if somebody adds decimal to the input file then the output value will be different than expected. |
Now you are saying something else and it's not even clear what you're saying. Please describe your COMPLETE requirement clearly with examples of input and expected output for ALL cases you have to handle. Then somebody can give you a COMPLETE solution without wasting their time or yours. |
|
Back to top |
|
|
abdul.faras
New User
Joined: 29 Feb 2008 Posts: 49 Location: Pune
|
|
|
|
sqlcode1 wrote: |
What is the expected output for the input value 12345678901234?
Thanks, |
its: 12345678901234.00
By Somebody, I meant someone else in our team.
I am considering a hypothetical situation if the i/p fields PIC clause is changed to 9(12)V9(2) then in that case the sort card would definitely need to be revisited. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You are unclear about whether an actual decimal point exists in your input or should exist in your output.
Code: |
123456789 No Decimal Point (implied to right of last digit)
12345678900 Two implied decimal places, Decimal Point implied to left of (in this example) trailing zeros
|
If "someone" changes the input to the second from the first, then you have to change the processing of the output (to nothing).
No data, except "edited" data, data formatted for output, contains actual decimal places. "Formats" are defined to interpret the data, with implied decimal places. In your task as stated you are reformatting the data to match a description in a program which has two decimal places but you are starting with an integer. So you add two zeros to the right (and you could do it that exact way) so that the next program down the line finds it lined-up for two implied decimal places.
If you have an "actual" decimal point in the data, then there is no need to do anything, whatever is processing the data must (if it is working) already understand the decimal point. |
|
Back to top |
|
|
|