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

How to convert packed decimals to Unpacked decimals


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ch.prashant

New User


Joined: 16 Sep 2006
Posts: 27
Location: Hyderabad

PostPosted: Thu Jan 22, 2009 12:30 pm
Reply with quote

Hi all,
I have a amount field in my Input file containing Comp-3 value and I want it to convert into comp-2 value .

Can I declare the Input amount field as AMOUNT PIC S9(11)V99 COMP-3.

and the output amount field as OUT-AMOUNT PIC S9(11)V99.


and can I move the amount like this

MOVE AMOUNT TO OUT-AMOUNT.

will it work,But for me I am getting S0C7 abend if I Convert like this.
Please suggest me the proper syntax.
Back to top
View user's profile Send private message
mainframe_help1

New User


Joined: 12 Dec 2008
Posts: 5
Location: india

PostPosted: Thu Jan 22, 2009 12:57 pm
Reply with quote

we can do it by using Redefine clause.
AMOUNT PIC S9(11)V99 COMP-3.


OUT-AMOUNT REDEFINES AMOUNT PIC S9(11)V99 COMP-2.
Back to top
View user's profile Send private message
rajulan

New User


Joined: 11 Jan 2008
Posts: 66
Location: India

PostPosted: Thu Jan 22, 2009 1:29 pm
Reply with quote

Yes . As Mainframe_help1 said you can redefine it. There is some correction in his code too.

To mainframe_help1,

You can not code like you have coded because comp-2 does not have pic clause.

In addition to that please go through the below link to get some information.

www.ibmmainframes.com/about26892.html

Thanks,
Rajulan.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jan 22, 2009 4:48 pm
Reply with quote

I apologize for being thick-headed, but how can you expect to redefine a Packed-Decimal as floating-point?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Jan 22, 2009 5:54 pm
Reply with quote

Dick: you can redefine a packed decimal value to floating point by completely and totally changing the value, making it pretty much unrelated to the original value? Alternate explanation: person doing the posting has absolutely no clue about internal formats of packed decimal and floating point numbers?

Why not use
Code:
     03  AMOUNT          PIC S9(11)V99 COMP-3.
     03  OUT-AMOUNT      COMP-2.
.
.
.
     IF  AMOUNT NUMERIC
         MOVE AMOUNT          TO OUT-AMOUNT
     END-IF.
Note that the IF test is critical since the original problem staement indicated that there's a very good chance the AMOUNT field is not numeric to start with.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jan 22, 2009 10:05 pm
Reply with quote

Hello,

Quote:
I have a amount field in my Input file containing Comp-3 value and I want it to convert into comp-2 value .

Can I declare the Input amount field as AMOUNT PIC S9(11)V99 COMP-3.

and the output amount field as OUT-AMOUNT PIC S9(11)V99.
Why is comp-2 mentioned? Moving packed-decimal (PIC S9(11)V99 COMP-3) to zoned-decimal (PIC S9(11)V99) is completely valid - providing the comp-3 data is properly signed numeric. If it is not, there will be an 0c7.

Why do you believe you want/need floating-point? Rarely (if ever) is packed-decimal business data moved to a floating-point field. . .
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
Search our Forums:

Back to Top