Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
oerdgie

New User

Joined: 22 Nov 2007
Posts: 55
Location: Germany

 Posted: Mon May 02, 2011 9:04 pm    Post subject: Convert numeric to packed signed decimal 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)

superk

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

 Posted: Mon May 02, 2011 9:12 pm    Post subject: Reply to: Convert numeric to packed signed decimal 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'))
prino

Senior Member

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

Posted: Mon May 02, 2011 9:16 pm    Post subject: Re: Convert numeric to packed signed decimal

 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.
enrico-sorichetti

Global Moderator

Joined: 14 Mar 2007
Posts: 10396
Location: italy

 Posted: Mon May 02, 2011 9:31 pm    Post subject: Reply to: Convert numeric to packed signed decimal
expat

Global Moderator

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

 Posted: Mon May 02, 2011 9:41 pm    Post subject: 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
oerdgie

New User

Joined: 22 Nov 2007
Posts: 55
Location: Germany

 Posted: Mon May 02, 2011 10:19 pm    Post subject: Thanks for help ! Regards
Akatsukami

Global Moderator

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

Posted: Mon May 02, 2011 10:28 pm    Post subject:

 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

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").
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm Can EDCICONV convert EBCDIC to ASCII... natt.sut IBM Tools 3 Fri Nov 17, 2017 8:46 pm Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us