View previous topic :: View next topic |
Author |
Message |
madisand Beginner
Joined: 29 Aug 2005 Posts: 19 Topics: 7
|
Posted: Thu Aug 24, 2006 8:55 am Post subject: Moving from packed decimal to aplhanumeric |
|
|
Hi All,
I have to move packed decimal field to aplhanumeric field.
Here is how it is
input A PIC S9(12) COMP-3
intermediate WS variables
X 9(12) COMP-3
Y 9(12) .
Output B PIC X(20).
I move A to X , X to Y & Y to B . However out of 250000 records it is failing for 5000 records & for others the populations is fine. Unable to determine the reason. Any ideas ? |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Aug 24, 2006 9:14 am Post subject: |
|
|
madisand,
How do you expect us to help you without even looking at the error records? anyways try this code to get the desired results.
Code: |
CBL ARITH(EXTEND)
IDENTIFICATION DIVISION.
PROGRAM-ID. TBL
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-COMP3 PIC S9(12) COMP-3.
01 WS-NUM PIC +9(19).
01 WS-CHAR PIC X(20).
PROCEDURE DIVISION.
MOVE -500 TO WS-COMP3
MOVE WS-COMP3 TO WS-NUM
MOVE WS-NUM TO WS-CHAR
DISPLAY 'WS-CHAR : ' WS-CHAR
DISPLAY 'WS-NUM : ' WS-NUM
GOBACK.
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
madisand Beginner
Joined: 29 Aug 2005 Posts: 19 Topics: 7
|
Posted: Thu Aug 24, 2006 9:27 am Post subject: |
|
|
I have done the similar thing though not sure why you had truncated intermediate variable
Here is one input data for which it is failing
200519801223
Hex value
q
0059023
201812F
Here is anothe data for which it passed
200404901255
Hex value
|
|
Back to top |
|
 |
madisand Beginner
Joined: 29 Aug 2005 Posts: 19 Topics: 7
|
Posted: Thu Aug 24, 2006 9:31 am Post subject: |
|
|
Ignore the word truncate but read it as extend |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
madisand Beginner
Joined: 29 Aug 2005 Posts: 19 Topics: 7
|
Posted: Thu Aug 24, 2006 10:07 am Post subject: |
|
|
In that case we can treat it as an extra move. But not sure why intermediate variable is +9(19). Under what environment it will work. Numeric integers sgould not be exceeding 9(18 ). Also how is it different if I move to X(20) from 9(12) or 9(19) |
|
Back to top |
|
 |
madisand Beginner
Joined: 29 Aug 2005 Posts: 19 Topics: 7
|
Posted: Thu Aug 24, 2006 10:09 am Post subject: |
|
|
I am getting a compilation error if a varibale is declared as +9(19) |
|
Back to top |
|
 |
madisand Beginner
Joined: 29 Aug 2005 Posts: 19 Topics: 7
|
Posted: Thu Aug 24, 2006 10:16 am Post subject: |
|
|
Just one more info that I i missed out. I compare input variable to be greater than zero then only I perform these moves. I put a display just below the comparison & for the records for which it is failing do not seems to be entering in IF condition even though they are greater than zero |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Aug 24, 2006 10:29 am Post subject: |
|
|
Quote: |
But not sure why intermediate variable is +9(19).
|
madisand,
Your input is Comp-3 which is stored in 7 bytes. Packed decimals have two digits for each character position. So your input field when expanded occupies 14 bytes and you need to consider the sign (positive or negative). So add another byte. So your intermediate variable should Idealy be defined as +9(14). (+ sign occupies 1 byte), but you are only defining 12 bytes. Now if you have a value more than 12 digits arent you truncating the value?
Quote: |
Also how is it different if I move to X(20) from 9(12) or 9(19)
|
Since your target variable is 20 bytes , I defined so +9(19) so that you can have padded zeroes in the beginning. If you move 9(12) to your target then you will have 8 spaces at the end.
Quote: |
Under what environment it will work. Numeric integers sgould not be exceeding 9(18 ).
|
Nowadays we have applications which demand more than 18 numeric digits.
Quote: |
I am getting a compilation error if a varibale is declared as +9(19)
|
If you have read carefully my job you would have found this as the first line of the pgm
and now check this link which explains about the compiler option ARITH
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/2.4.5?DT=20020923143836
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
madisand Beginner
Joined: 29 Aug 2005 Posts: 19 Topics: 7
|
Posted: Thu Aug 24, 2006 10:40 am Post subject: |
|
|
Thanks Kolusu.
But then the current approach should fail for every record processed by program & all the records have same number of characters in the input field. But only a select have failed. Seems like a data issue in the input field. I am browing thru file aid using HEX on. So far not getting any clue. I am not interested in sign. As I mentioned earier 9(12) is working for almost .25 million records but failed for a select few. My feeling is that input data is some what corrupted. As I mentioned the control of program doesnt even enter if condition where I put a display & a counter. I pasted the HEX values in this forum. Any clues based on those. Also is it possible that surrounding fields getting corrupted would impact the current field under process |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
|
|