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



Hello Johan,

Now I'm a bit puzzled. What do I use ? ExtName or Likerec ?


LIKEREC defines a data structure to be like a record format. That record format must have already been brought into your program via an F-spec at the top of the program.

LIKEREC guarantees that the data structure is identical to the input or output buffer that the RPG program will be using to interact with the database, that's important when you want to read a raw record into the structure (which is what happens when you list the DS in the result field of a RPG I/O opcode, or if you use something like the _Rreadx() APIs.)

LIKEREC was introduced in V5R2 as part of the support for reading/writing directly from a data structure.

E DS and EXTNAME are an older mechanism, evolving from RPG III. Instead of looking for a file brought in through an F-spec, they actually go out to the external definition of the file itself.

A data structure using EXTNAME can potentially be different from the actual record layout of the file. You can add your own fields to an E DS data structure, and they can change the layout.

Also, if a file has fields that are input-only or output-only, EXTNAME's format might not match the layout of the record.

in V5R2's manual, IBM made an error where they stated that reading into a DS was supported with BOTH EXTNAME and LIKEREC. That wasn't the case in V5R2, it was an error in the manual. However, the developers decided to change the compiler to match the manual (rather than the other way around)

So in V5R3, EXTNAME was upgraded to have the *INPUT and *OUTPUT parameters to let it match a record format exactly, and was also given the ability to work in a situation where you read/write directly from a data structure. That capability wasn't originally intended.

As for which you should use in your application -- I can't really answer that. That's really up to you, and depends on the application.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.