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



On 2021-04-22 3:20 p.m., DEnglander--- via RPG400-L wrote:
I have a DDS-defined file that contains a numeric field defined as
ZONED(6) to hold MSTITEM#.

I have an ILERPG program that has a DCL-S line to define field NEWITEM# as
being like MSTITEM#. i.e.

dcl-s newitem# like(mstitem#);

Even though the MSTITEM# field is defined as ZONED, why does the ILERPG
compiler define NEWITEM# as being PACKED(6)?

Is there any way to stop this, such as a CTL-OPT line keyword or Compile
command parameter entry? ...
> ...
... I do notice that if I define an
External Data Structure as a Template, and make NEWITEM# like(the E DS
name), the compiler does preserve the ZONED.

Doug, RPG has the concept of "internal" vs "external" data type.
https://www.ibm.com/docs/en/i/7.4?topic=formats-internal-external

"Numeric, character, date, time, and timestamp fields have an internal format that is independent of the external format. The internal format is the way the data is stored in the program. The external format is the way the data is stored in files."
...
"For subfields in externally described data structures, the data formats specified in the external description are used as the internal formats of the subfields by the compiler."

As you have discovered, the default internal format for numeric fields is packed.
https://www.ibm.com/docs/en/i/7.4?topic=formats-internal-format

The general reason for allowing an internal format to be different from an external format is that RPG supports having the same field in different files with different formats. During I/O, the program field with the internal format is assigned to/from the I/O buffer with the external format, so it doesn't matter if the internal field is packed and the external field in the I/O buffer is zoned. A common scenario is having a field that is packed in a database file and zoned in a display file.

I'm not sure, but I think the reason for having a default numeric format of packed is that when RPG III was being developed, packed arithmetic was faster than zoned arithmetic. (That's still true now, although the difference is minor.)


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.