Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
abdul.faras

New User

Joined: 29 Feb 2008
Posts: 49
Location: Pune

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.

Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

Posted: Mon Apr 09, 2012 5:01 pm    Post subject: Reply to: Need help regarding DECCON in sort.

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
abdul.faras

New User

Joined: 29 Feb 2008
Posts: 49
Location: Pune

 Posted: Mon Apr 09, 2012 5:52 pm    Post subject: Thanks a lot Bill.
abdul.faras

New User

Joined: 29 Feb 2008
Posts: 49
Location: Pune

 Posted: Mon Apr 09, 2012 9:13 pm    Post subject: 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!!
sqlcode1

Active Member

Joined: 08 Apr 2010
Posts: 578
Location: USA

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

 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,
Frank Yaeger

DFSORT Moderator

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.
abdul.faras

New User

Joined: 29 Feb 2008
Posts: 49
Location: Pune

Posted: Tue Apr 10, 2012 12:49 pm    Post subject:

 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.
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

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.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Conversion of DLI update Jobs as BMP ... Gopinath Shanmugam IMS DB/DC 3 Wed Dec 20, 2017 12:02 pm SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm Conversion of UTF-8 to EBCDIC muralikrishnan_new COBOL Programming 1 Tue Nov 21, 2017 5:33 pm Mainframe Blocks to Tracks conversion upendrasri JCL & VSAM 1 Sat Nov 18, 2017 10:52 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us