IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to dispay packed-decimal variables using rexx ??


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
harry143

New User


Joined: 05 Nov 2007
Posts: 21
Location: hyd

PostPosted: Wed Jan 30, 2008 4:33 pm
Reply with quote

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

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Jan 30, 2008 4:37 pm
Reply with quote

Here are two previous topics:

www.ibmmainframes.com/viewtopic.php?t=17235
www.ibmmainframes.com/viewtopic.php?t=4511
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jan 30, 2008 5:21 pm
Reply with quote

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

New User


Joined: 05 Nov 2007
Posts: 21
Location: hyd

PostPosted: Thu Jan 31, 2008 5:09 pm
Reply with quote

Thanks!!!
It is working fine
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
Search our Forums:

Back to Top