Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 4650
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: 1060
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: 10327
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: 1777
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 Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Return a Non Numeric value from REXX Learncoholic CLIST & REXX 3 Fri Sep 01, 2017 8:33 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us