|
On Mar 27, 2024, at 11:57 AM, Greg Wilburn <gwilburn@xxxxxxxxxxxxxxxxxxxxxxx<mailto:gwilburn@xxxxxxxxxxxxxxxxxxxxxxx><mailto:gwilburn@xxxxxxxxxxxxxxxxxxxxxxx<mailto:gwilburn@xxxxxxxxxxxxxxxxxxxxxxx>>> wrote:
Thanks guys... I'll try the pointer approach.
Jon - the previous method was from early 2000's and was not my code... legacy ERP, so I can't change the data definition either.
But I do have my DS defined externally...
dcl-ds myRecDS extname('SA991A');
end-ds;
I think the pointer is more "readable" to someone else looking at the code.
Thanks again!
-----Original Message-----
From: RPG400-L
<rpg400-l-bounces@xxxxxxxxxxxxxxxxxx<mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx><mailto:rpg400-l-bounces@xxxxxxxxx
range.com<http://range.com>>> On Behalf Of Jon Paris
Sent: Wednesday, March 27, 2024 11:36 AM
To: RPG programming on the IBM i (AS/400 and iSeries)
<rpg400-l@xxxxxxxxxxxxxxxxxx<mailto:rpg400-l@xxxxxxxxxxxxxxxxxx><mailto:rpg400-l@xxxxxxxxxxxxxxxxxx<mailto:rpg400-l@xxxxxxxxxxxxxxxxxx>>>
Subject: Re: Packed Numeric stored in Char field
Shows how long it has been since I used from/to - couldn't work out how 8 decimals fitted into a 5 digit field and that the 8 must be a typo! Another good reason to never use from/to!
In my DS example simply change the def of packed fields to packed(9:8) and all is well.
Jon P.
On Mar 27, 2024, at 11:26 AM, Daniel Gross <daniel@xxxxxxxx<mailto:daniel@xxxxxxxx><mailto:daniel@xxxxxxxx<mailto:daniel@xxxxxxxx>>> wrote:
Hi Greg,
Am 27.03.2024<http://27.03.2024><http://27.03.2024<http://27.03.2024>> um 16:03 schrieb Greg Wilburn <gwilburn@xxxxxxxxxxxxxxxxxxxxxxx<mailto:gwilburn@xxxxxxxxxxxxxxxxxxxxxxx><mailto:gwilburn@xxxxxxxxxxxxxxxxxxxxxxx<mailto:gwilburn@xxxxxxxxxxxxxxxxxxxxxxx>>>:
The table I'm reading contains a character field IDFL03 that contains a packed decimal value.
The previous extraction method (reading the file with RPG) simply defined a DS "overlay"
D ds
D idfl03 1 5a stored here in sa326
D idpml 1 5p 8 payment multiplier
How about using a pointer?
dcl-s packedField packed(9:8) based(pointerCharField); ...
pointerCharField = %addr(idfl03);
...
// now use packedField
Another idea is using SQLs built in INTERPRET function?
SELECT INTERPRET(idfl03 AS DECIMAL(9, 8) FROM ...
This should also work.
Of course the best solution would be converting this column to a numeric value.
HTH
Daniel
P.S.: I'm on holidays right now - so no chance to check my ideas ...
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post
a message email:
RPG400-L@xxxxxxxxxxxxxxxxxx<mailto:RPG400-L@xxxxxxxxxxxxxxxxxx><mailto:RPG400-L@xxxxxxxxxxxxxxxxxx<mailto: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<mailto:RPG400-L-request@xxxxxxxxxxxxxxxxxx><mailto:RPG400-L-request@xxxxxxxxx
range.com<http://range.com>> Before posting, please take a moment to review the
archives at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx><mailto:support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx>> for any subscription related questions.
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email:
RPG400-L@xxxxxxxxxxxxxxxxxx<mailto:RPG400-L@xxxxxxxxxxxxxxxxxx><mailto:RPG400-L@xxxxxxxxxxxxxxxxxx<mailto: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<mailto:RPG400-L-request@xxxxxxxxxxxxxxxxxx><mailto:RPG400-L-request@xxxxxxxxxx
ange.com<http://ange.com>> Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx><mailto:support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx>> for any subscription related questions.
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email:
RPG400-L@xxxxxxxxxxxxxxxxxx<mailto:RPG400-L@xxxxxxxxxxxxxxxxxx><mailto:RPG400-L@xxxxxxxxxxxxxxxxxx<mailto: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<mailto:RPG400-L-request@xxxxxxxxxxxxxxxxxx><mailto:RPG400-L-request@xxxxxxxxxx
ange.com<http://ange.com>> Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx><mailto:support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx>> for any subscription related questions.
As an Amazon Associate we earn from qualifying purchases.
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.