Posted: Mon Apr 09, 2012 4:44 pm Post subject: Need help regarding conversion in sort.

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.

Joined: 15 Feb 2005 Posts: 7130 Location: San Jose, CA

Posted: Mon Apr 09, 2012 10:57 pm Post subject:

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.

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.

Posted: Tue Apr 10, 2012 1:13 pm Post subject: Reply to: Need help regarding conversion in sort.

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.