Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to convert packed decimals to Unpacked decimals

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How to convert packed decimals to Unpacked decimals
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    Post subject: Reply to: How to convert packed decimals to Unpacked decimal
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    Post subject: Reply to: How to convert packed decimals to Unpacked decimal
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.

http://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: 6968
Location: porcelain throne

PostPosted: Thu Jan 22, 2009 4:48 pm    Post subject:
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: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Thu Jan 22, 2009 5:54 pm    Post subject:
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

Site Director


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

PostPosted: Thu Jan 22, 2009 10:05 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Convert CLIST to REXX cvnlynn CLIST & REXX 12 Tue Jun 27, 2017 2:06 am
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Convert current to hex value gopurs DFSORT/ICETOOL 4 Wed Feb 15, 2017 5:40 am
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us