Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Convert numeric to packed signed decimal

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 55
Location: Germany

PostPosted: Mon May 02, 2011 9:04 pm    Post subject: Convert numeric to packed signed decimal
Reply with quote

Hi Folks,

how can I convert a numeric value into a packed signed decimal in REXX ?

Examples :
123 converted to '123C'x (positiv)
4456 converted to '04456D'x (negativ)
Back to top
View user's profile Send private message

superk

Moderator Team Head


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

PostPosted: Mon May 02, 2011 9:12 pm    Post subject: Reply to: Convert numeric to packed signed decimal
Reply with quote

Add these to your collection of common procedures:

/* packed to decimal */
p2d: procedure
arg pd
Return (translate(right(C2X(pd),1),'-- ','BDACEF')||left(C2X(pd),length(C2X(pd))-1)) + 0

/* decimal to packed */
d2p: procedure
arg dec
If dec < 0 then s = 'D'; else s = 'C'
n = space(translate(dec,,'+-.')s,0)
Return X2C(right(n,length(n)+length(n)//2,'0'))
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1002
Location: Oostende, Belgium

PostPosted: Mon May 02, 2011 9:16 pm    Post subject: Re: Convert numeric to packed signed decimal
Reply with quote

oerdgie wrote:

how can I convert a numeric value into a packed signed decimal in REXX ?

Examples :
123 converted to '123C'x (positiv)
4456 converted to '04456D'x (negativ)


4456 is positive.

Anyway, strip the sign, concatenate the number with 'C' (+) or 'D' (-) and use x2c(whatever). REXX will take care of the potential added initial zero.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10231
Location: italy

PostPosted: Mon May 02, 2011 9:31 pm    Post subject: Reply to: Convert numeric to packed signed decimal
Reply with quote

see
here
http://ibmmainframes.com/viewtopic.php?t=27921&highlight=rexx+pack+unpack
and here
http://ibmmainframes.com/viewtopic.php?t=41407&highlight=rexx+pack+unpack
and here
http://ibmmainframes.com/viewtopic.php?t=31547&postdays=0&postorder=asc&start=15
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Mon May 02, 2011 9:41 pm    Post subject:
Reply with quote

Hey guys, quite a few of us are getting on in years, what's going to happen when we're gone and nobody can ever work out how to search or find a manual icon_evil.gif
Back to top
View user's profile Send private message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 55
Location: Germany

PostPosted: Mon May 02, 2011 10:19 pm    Post subject:
Reply with quote

Thanks for help ! icon_smile.gif

Regards
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1753
Location: Bloomington, IL

PostPosted: Mon May 02, 2011 10:28 pm    Post subject:
Reply with quote

expat wrote:
Hey guys, quite a few of us are getting on in years, what's going to happen when we're gone and nobody can ever work out how to search or find a manual icon_evil.gif

See if you can find the short story "MS Found in a Library" (not to be confused with Poe's "MS Found in a Bottle").
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Convert current to hex value gopurs DFSORT/ICETOOL 4 Wed Feb 15, 2017 5:40 am
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us