× 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 Gred,

I have to second Jon - the overlay keyword is very readable and easy to understand.

I would make a small COPY file with an "template" definition for that file.

dcl-ds SA991A_T extname('SA991A');
// additional fields...
idpml packed(9:8) overlay(idfl03);
end-ds;

This makes the intent clear - and is easily reusable in many programs without a lot of fuss.

Simply write in your program:

/copy <above-copy-file>
...
dcl-ds myRecDs likeds(SA991A_T) inz;

The intent is clear - you can reuse the template in every program where you need it.

HTH and kind regards
Daniel


Am 27.03.2024 um 17:19 schrieb Jon Paris <jon.paris@xxxxxxxxxxxxxx>:
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> 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> 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>
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> wrote:
Hi Greg,
Am 27.03.2024 um 16:03 schrieb Greg Wilburn <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 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.

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

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

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


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.