Lesson 3 · July 2026 RPG Enhancements

RPG LIKE(*EXT): Define a Variable Like an External File Field

Learn how RPG LIKE(*EXT) can define a variable from one field in an external file without declaring the whole file or external data structure.

IBM iRPGLIKE(*EXT)External FilesJuly 2026 RPG Enhancements

LIKE(*EXT) lets RPG developers define a variable like one field in an external file, without defining the whole file or an externally described data structure.

RPG developers have used externally described files and data structures for a long time.

That is one of the strengths of IBM i development.

The database definition can drive the RPG definition.

But sometimes you do not need the whole file.

Sometimes you only need one field.

That is where LIKE(*EXT) becomes useful.

What changed?

RPG now supports LIKE(*EXT).

It lets you define a standalone variable using the definition of one field from an external file.

Conceptually:

dcl-s variableName like(*ext : 'FIELDNAME' : 'FILE');

The RPG variable gets its attributes from the external field.

That can include things like:

Simple way to remember

Use LIKE(*EXT) when you want one variable to match one external file field.

Why should you care?

Before LIKE(*EXT), if you wanted a variable to match an external file field, you often had to use one of these approaches:

dcl-f Customer usage(*input);

dcl-ds CustomerDs extname('CUSTOMER') qualified;
end-ds;

Those approaches are still valid.

But they may be more than you need if you only want one field.

With LIKE(*EXT), the intent is clearer:

Define this RPG variable like that field in that external file.

That can reduce duplication and help avoid mismatched field definitions.

Simple example

Assume you have a customer file with a field named CUSTNO.

Instead of manually defining the variable like this:

dcl-s customerNumber packed(9:0);

you can define it from the external field:

dcl-s customerNumber like(*ext : 'CUSTNO' : 'CUSTOMER');

Now the variable follows the external field definition.

If the external field is packed 9,0, the RPG variable is packed 9,0.

If the external field definition changes later, the RPG definition can stay aligned when the program is recompiled.

Example: using a customer number parameter

This can be useful in procedures.

**free
ctl-opt dftactgrp(*no);

dcl-proc getCustomerName;

  dcl-pi *n varchar(100);
    customerNumber like(*ext : 'CUSTNO' : 'CUSTOMER') const;
  end-pi;

  dcl-s customerName like(*ext : 'CUSTNAME' : 'CUSTOMER');

  // Lookup logic would go here

  return customerName;

end-proc;

The procedure parameter and local variable are tied to the external file field definitions.

That makes the code easier to maintain.

The procedure is also documenting something important:

This value should match the CUSTOMER file’s CUSTNO field.

Example: avoiding repeated manual definitions

Manual definitions can drift over time.

For example:

dcl-s orderNumber packed(9:0);
dcl-s customerNumber packed(9:0);
dcl-s itemNumber char(15);

That may be fine at first.

But if the external definition changes, the RPG variables may no longer match.

Using LIKE(*EXT) can make the connection explicit:

dcl-s orderNumber like(*ext : 'ORDNO' : 'ORDHDR');
dcl-s customerNumber like(*ext : 'CUSTNO' : 'CUSTOMER');
dcl-s itemNumber like(*ext : 'ITEMNO' : 'ITEMMAST');

Now the code tells the reader exactly where the field definitions come from.

When to use LIKE(*EXT)

Use LIKE(*EXT) when:

Good examples include:

When not to use LIKE(*EXT)

Do not use LIKE(*EXT) everywhere just because it exists.

If you are already processing a full file record, an externally described data structure may still make more sense.

If the variable is a pure working variable and not tied to a database field, a normal definition may be clearer.

For example:

dcl-s loopIndex int(10);
dcl-s retryCount int(10);
dcl-s messageText varchar(500);

These do not need LIKE(*EXT) unless they truly represent external fields.

What about externally described data structures?

LIKE(*EXT) does not replace externally described data structures.

It solves a smaller problem.

Use an externally described data structure when you need a group of fields from a file.

Use LIKE(*EXT) when you only need one field.

Need many fields?  Use EXTNAME.
Need one field?   Consider LIKE(*EXT).

PTF / release note

PTF / release note

Before using LIKE(*EXT), verify the required IBM i release level, RPG compiler PTF, SQL RPG compile support, and runtime PTFs on the systems where the program will be compiled and run.

IBM’s RPG Cafe lists LIKE(*EXT) as part of the July 2026 RPG enhancements. Check IBM’s RPG Cafe and the specific LIKE(*EXT) page for current release and PTF information before using it in real development or production environments.

Final takeaway

LIKE(*EXT) is a small enhancement, but it solves a real readability and maintenance problem.

It lets RPG code say:

This variable should be defined like this external file field.

That can reduce manual duplication, improve consistency, and make the source easier to understand.

Use it when you only need one field definition from an external file.

References

Documentation and references used for this lesson.

Comments

Share your thoughts, questions, or real-world IBM i experiences related to this article.