Why can’t we write data to PF using CL program?

CL Program
Why can't we  write data to PF using a CL program?

Answer Wiki

Thanks. We'll let you know when a new response is added.

The freeware run-time base option of CL for Files (CLF) provides for read/write/update/delete capability, from CL, with i databases (along with display and printer support).

Vendor response.

There is also a fee-based CL precompiler which provides enhanced productivity over the no-charge run-tme support (plus a few capabilities not supported by languages such as RPG, COBOL, and C).

The full command set of CLF can be found here. There is a charge associated with the precompiler and generation tool. There is no charge for the run-time provided commands.

Bruce Vining



There are ways of writing data to files from CL programs. You can use RUNSQLSTM or the QSHELL DB2 interface for example.


Martin Gilbert.


You can’t write to PFs with CL because CL has no facility for database updates. That’s the flat answer.

CL isn’t written as a language to manipulate database values.

If you need to write to PFs, CALL a function that does it. That’s what CL does. Call into a database language program or run a function in Qshell as suggested above.


CL, in 6.1 and later releases, supports the RUNSQL CL command. This command would allow you to use SQL INSERT statements to write new records/rows to a file/table.
Bruce Vining

Discuss This Question: 2  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Vatchy
    A CL program is basically a series of commands. Each command has a command processing program which can be either a CL or RPG program (or machine language but let's not get into that now). If you need the ability to write to a file, write your own command that calls a program to write to the file for you. That way, you can write the command the way you want it to be written, have it pass the parameters that you need passed, do the validation that you need it to do, and do the error checking that needs done when the record is written.
    1,415 pointsBadges:
  • TomLiotta
    It can be difficult to judge how easy something might be for other. It's a tricky business. There are many systems that don't have the compiler products. That can make it interesting for some basic CL programmers to create clean commands. And there are many CL programmers who have no idea how to write RPG or even COBOL, much less C or anything else. (The first three AS/400s that I bought had no HLL compilers, though I knew how to program in all of them.) I haven't seen Bruce's commands, but I've sure seen enough of his comments over many years to feel comfortable with pretty much anything he provides. Still, your point does need to made. It applies in probably the majority of cases. Tom
    125,585 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: