× 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.



Ok. You convinced me... I'll do the overlay (LOL)

The old, old way was definitely difficult to understand.

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of VERNON HAMBERG Owner via RPG400-L
Sent: Wednesday, March 27, 2024 12:53 PM
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Cc: VERNON HAMBERG Owner <vhamberg@xxxxxxxxxxxxxxx>; rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: Packed Numeric stored in Char field

+++1 for overlays or pos, ----1 for pointers. And I'm not even especially pointer-phobic - I mean, I've written OAR handlers, and the data structures one uses in there are crammed full of pointers. I much prefer the more direct (to my way of thinking) of overlay or pos.


Cheers
Vern


On Wed, 27 Mar, 2024 at 11:19 AM, Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:


To: rpg programming on the ibm i (as/400 and iseries)

Hopefully, it was from the late 1900s! RPG IV has never needed from/to - it was only left in because we didn't have time to implement overlay and similar stuff that came later.

Your choice of course, but most RPGers are so pointer-phobic that (even if to me the intent is obvious) so I'm surprised you think it more readable than Overlay.


Jon P.


On Mar 27, 2024, at 11:57 AM, Greg Wilburn <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@xxxxxxxxx
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>>
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>> wrote:

Hi Greg,

Am 27.03.2024<http://27.03.2024> um 16:03 schrieb Greg Wilburn <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> 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@xxxxxxxxx
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> 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> 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@xxxxxxxxxx
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> 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>
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@xxxxxxxxxx
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> 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>
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>
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact 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 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@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.