View previous topic :: View next topic
|
Author |
Message |
harry143
New User
Joined: 05 Nov 2007 Posts: 21 Location: hyd
|
|
|
|
I have a sequential file with some records in it. I want to write some of the records to an output file based on some calculations on the fields in the input file.
But the input file record contains packed-decimal variables. So while I am trying to extract that fields using rexx, I am unable to diplay them nor able to do any calculations sine they are packed-decimal fields.
How Can I convert the packed-decimal variables in the input file to the regural decimal format such that I can do the calculations using rexx and write into the input file. |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
just a snippet ...
adjust to your needs
Code: |
...
packed = subst(Your_record,Start_pos,Length)
number = unpack(packed)
...
exit
unpack: procedure
parse arg pack
/* Convert packed data to hex and split */
char = c2x(pack)
numb = left( char, length(char)-1 )
sign = right( char, 1 )
/* Check sign and numeric sections */
if verify(sign, "ABCDEF" ) > 0 then ,
return ""
if verify( numb, "0123456789" ) > 0 then ,
return ""
/* Check negative sign */
if pos(sign, "BD" ) > 0 then,
return -numb
else ,
return numb
|
|
|
Back to top |
|
|
harry143
New User
Joined: 05 Nov 2007 Posts: 21 Location: hyd
|
|
|
|
Thanks!!!
It is working fine |
|
Back to top |
|
|
|