× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Hi, Bill:

I know of no way to do this, outside of calling another program, passing
the character-defined parm and returning a decimal-defined parm.

For example, consider this CL solution called CVTCHRPKD:

PGM (&CHAR &PACKED)
DCL &CHAR *CHAR 8   (Assuming your packed value is 14 or 15 digits)
DCL &PACKED *CHAR 8 /* Yes, that's right; don't change format. */
CHGVAR &PACKED &CHAR
RETURN


Now, let's say your current CL program (MYPGM) has the value in question in
a variable named &VAL.

Add a variable called &VALNUM thus:

DCL &VALNUM *DEC (15 5)

CALL CVTCHRPKD (&VAL &VALNUM)

voila, you have used magic to convert the number.  Adjust field lengths as
necessary.

----

I'd be interested in knowing how that value got into the CL program as a
character in fhe first place.  Seems to me that it would be advisable, if
possible, to define the value as a packed number in the first place and be
done with it.  Any reason that cannot be accomplished?

Dennis







"Rubino, Jim" <Jim.Rubino@Fike.com>@midrange.com on 02/03/2003 02:30:02 PM

-----Original Message-----
From: bill.reger@convergys.com [mailto:bill.reger@convergys.com]
Sent: Monday, February 03, 2003 12:18 PM
To: Midrange-L@midrange.com
Subject: Packed (*CHAR) to Numeric (*DEC) in CLP


Can anyone tell me how (in a CLP) to convert a *CHAR declared variable
containing a packed numeric value into a *DEC declared variable?

Bill





As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.