View previous topic :: View next topic
|
Author |
Message |
ch.prashant
New User
Joined: 16 Sep 2006 Posts: 27 Location: Hyderabad
|
|
|
|
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 |
|
|
mainframe_help1
New User
Joined: 12 Dec 2008 Posts: 5 Location: india
|
|
|
|
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 |
|
|
rajulan
New User
Joined: 11 Jan 2008 Posts: 66 Location: India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I apologize for being thick-headed, but how can you expect to redefine a Packed-Decimal as floating-point? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|