IMHO the only way to handle the size and number of decimal positions
dynamically is to use dynamic embedded SQL.
Something like this:
String = 'Values(VarChar(Dec(' concat Packed_Data concat '/' concat
D_shift concat
', 31, ' concat Use_Scale concat ')) )
into ?';
PrePare DynSQL From :String;
Execute DynSQL Using :YourRtnVar;
Return YourRtnVar;
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
?Train people well enough so they can leave, treat them well enough so they
don't want to.? (Richard Branson)
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of
dlclark@xxxxxxxxxxxxxxxx
Sent: Donnerstag, 5. März 2020 23:21
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Decimal Place in Character String
"RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> wrote on 03/05/2020
05:14:34 PM:
On 2020-03-03 3:10 p.m., dlclark@xxxxxxxxxxxxxxxx
wrote:
"RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> wrote on 03/03/2020
02:48:17 PM:
If you code DECPREC(63) in your CTL-OPT, you'll get the decimal
positions in the output of %CHAR.
Thanks, Barbara. That worked but then it gives me way too
many
digits to the right of the decimal place. Is there a way to specify
the
number of decimal positions I want using a non-constant variable?
I can only think of using %DEC inside the %CHAR.
To get 5 decimal places:
result = %char(%dec(packed_data / d_shift : 63 : 5)) ;
You could put something smaller than 63, but using the maximum works ok.
Yes, but you had to hard-code the number of decimals. Since I'm
writing a generic routine that will have a variable number of decimals from
caller to caller, I need to be able to specify a variable number of
decimals. %DEC will not allow that.
Sincerely,
Dave Clark
--
int.ext: 91078
direct: (937) 531-6378
home: (937) 751-3300
Winsupply Group Services
3110 Kettering Boulevard
Dayton, Ohio 45439 USA
(937) 294-5331
****************************************************************************
*****************
This email message and any attachments is for use only by the named
addressee(s) and may contain confidential, privileged and/or proprietary
information. If you have received this message in error, please immediately
notify the sender and delete and destroy the message and all copies. All
unauthorized direct or indirect use or disclosure of this message is
strictly prohibited. No right to confidentiality or privilege is waived or
lost by any error in transmission.
****************************************************************************
*****************
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.