IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need help regarding conversion in sort.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Mon Apr 09, 2012 4:44 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Apr 09, 2012 5:01 pm
Reply with quote

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
View user's profile Send private message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Mon Apr 09, 2012 5:52 pm
Reply with quote

Thanks a lot Bill.
Back to top
View user's profile Send private message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Mon Apr 09, 2012 9:13 pm
Reply with quote

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
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Mon Apr 09, 2012 9:57 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Mon Apr 09, 2012 10:57 pm
Reply with quote

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
View user's profile Send private message
abdul.faras

New User


Joined: 29 Feb 2008
Posts: 49
Location: Pune

PostPosted: Tue Apr 10, 2012 12:49 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Apr 10, 2012 1:13 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
Search our Forums:

Back to Top