MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Moving from packed decimal to aplhanumeric

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
madisand
Beginner


Joined: 29 Aug 2005
Posts: 19
Topics: 7

PostPosted: Thu Aug 24, 2006 8:55 am    Post subject: Moving from packed decimal to aplhanumeric Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Aug 24, 2006 9:14 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
madisand
Beginner


Joined: 29 Aug 2005
Posts: 19
Topics: 7

PostPosted: Thu Aug 24, 2006 9:27 am    Post subject: Reply with quote

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
View user's profile Send private message
madisand
Beginner


Joined: 29 Aug 2005
Posts: 19
Topics: 7

PostPosted: Thu Aug 24, 2006 9:31 am    Post subject: Reply with quote

Ignore the word truncate but read it as extend
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Aug 24, 2006 9:44 am    Post subject: Reply with quote

Quote:

Essentailly data is same. Approach is similar to what you have given with the exception that I create an additional intermediate varialbe whcih hold data from S9(12) comp-3 to 9(12) comp-3.


madisand,

what exactly are you hoping that 9(12) comp-3 would do ? S9(12) and 9(12) both occupy 7 bytes and both of them have the sign. Check this link for examples of how the data is stored.

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/1.3.4.7?DT=20020923143836

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
madisand
Beginner


Joined: 29 Aug 2005
Posts: 19
Topics: 7

PostPosted: Thu Aug 24, 2006 10:07 am    Post subject: Reply with quote

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
View user's profile Send private message
madisand
Beginner


Joined: 29 Aug 2005
Posts: 19
Topics: 7

PostPosted: Thu Aug 24, 2006 10:09 am    Post subject: Reply with quote

I am getting a compilation error if a varibale is declared as +9(19)
Back to top
View user's profile Send private message
madisand
Beginner


Joined: 29 Aug 2005
Posts: 19
Topics: 7

PostPosted: Thu Aug 24, 2006 10:16 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Aug 24, 2006 10:29 am    Post subject: Reply with quote

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
Code:

CBL ARITH(EXTEND)


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
View user's profile Send private message Send e-mail Visit poster's website
madisand
Beginner


Joined: 29 Aug 2005
Posts: 19
Topics: 7

PostPosted: Thu Aug 24, 2006 10:40 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Aug 24, 2006 11:24 am    Post subject: Reply with quote

madisand,

Check this link to see if this might have happened in your case.

http://www.mvsforums.com/helpboards/viewtopic.php?p=13088

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group