01a - RPG (EN)

Managing Locked Display Files on IBM i: An Effective Solution

We are pleased to receive and share this “tip & trick” from Patrick Rizzi, which introduces a technique that allows for intervention (modification and compilation) on any display files (DSPF) in use. We all know that if a Display File is in use by one or more users, we cannot recompile it because it is “locked.”

With Patrick’s technique, we can safely modify and recompile a DSPF even while the application is open and running. The RPG program effectively works with the DSPF in QTEMP and continues operating with the “old version” until restart.

This technique can be very helpful if we consider some programs used by dozens or hundreds of users or programs that are active all day.

Here are Patrick Rizzi’s suggestions:

Problem:

How many of you have encountered the annoying issue of a locked display file on IBM i, preventing its compilation? This problem can significantly slow down the development and maintenance process of applications.

Solution:

A practical and effective solution involves using a combination of RPG and CL techniques to actively manage the lifecycle of display files in QTEMP. Here’s how to proceed:

Declaring the display file as USROPN: ○ In the RPG program, declare the display file with the USROPN keyword. This means that the control over opening and closing the file will be under your direct control.

Creating a CL program that:

  • Deletes the display file from the job’s QTEMP if it already exists.
  • Copies the display file from its original library into QTEMP.

Opening the display file:

  • In your RPG program, open the display file in QTEMP using the OPEN command.

Advantages of this solution:Flexibility: Allows you to fully control the lifecycle of the display file. ● Efficiency: Avoids locks and conflicts, ensuring quick and smooth recompilation. ● Scalability: Easily adapts to different scenarios and environments.

Example RPG code:

dcl-pr dupdspftmp extpgm('DUPDSPFTMP');
lib char(10) const;
file char(10) const;
end-pr;
dcl-f mydspfile workstn usropn;
dupdspftmp('*LIBL':’MYDSPFILE’);
open mydspfile;

Example for the CL Program (DUPDSPFTMP):

PGM PARM(&LIB &DSPF)
DCL VAR(&LIB) TYPE(*CHAR) LEN(10)
DCL VAR(&dspf) TYPE(*CHAR) LEN(10)
DLTOBJ OBJ(QTEMP/&DSPF) OBJTYPE(*FILE)
MONMSG MSGID(CPF2105)
CRTDUPOBJ OBJ(&DSPF) FROMLIB(&LIB) OBJTYPE(*FILE) TOLIB(QTEMP)
ENDPGM

We thank Patrick Rizzi for sharing this technique with the Community and encourage other Blog.Faq400 readers to do the same by sharing material and/or techniques that can be shared.

Thank you, Patrick.

Roberto

Related Posts
DB2 for i SQL – String Manipulation – POSSTR-LOCATE-LOCATE_IN_STRING (EN)

Introduction Often, in our applications, we need to work with text strings, and DB2 SQL can come in very useful Read more

DB2 for i – FAQ & Howtos (EN)

DB2 Database and SQL ... maybe the most important things on IBM i platform: here's a collection of FAQs, tips Read more

IBM i 7.4 Announcement (En)

Comes directly with the Easter egg this IBM announcement for the news of the IBM i 7.4 version, iNext version Read more

Generated Always Columns (EN)

Introduction "Generated Always Column": are columns, table fields, filled by DB2 engine: something like columns with a default value but Read more

--- Roberto De Pedrini Faq400.com

Recent Posts

Monitoring QSYSOPR Messages: SQL to Retrieve Messages and Replies

I take inspiration from a response by Michael Mayer on the Midrange.com mailing lists to someone who asked how to…

1 month ago

Why ERP is the Key to Success for Modern Businesses

Businesses are increasingly seeking tools to enhance efficiency, collaboration, and resource management. Enterprise Resource Planning (ERP) systems provide a comprehensive…

3 months ago

ACS Access Client Solution 1.1.9.5

Early April saw the release of the "Spring Version" of ACS Access Client Solution, version 1.1.9.5 Interesting new features especially…

8 months ago

Tim Rowe and Scott Forstie for CEC 2024 – Milan

If the packed agenda of sessions at Common Europe Congress 2024, June 3-6 Milan, wasn't enough for you, here's another…

8 months ago

Code for IBM i 2.10.0 – Debug IBM i App with Visual Studio Code

Debugging functions with Visual Studio Code have been available for some time but this new version 2.10.0 simplifies the handling…

8 months ago

ObjectConnect over TCP/IP

Two and a half years after my post Transferring objects with ObjectConnect and Enterprise Extender, I finally got around to…

8 months ago