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:
Opening the display file:
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
--- Roberto De Pedrini Faq400.com👉 Review: Bob Cozzi’s RPG IV to RPG Free Conversion – a useful VS Code extension for RPG modernization If…
Hello everyone, I’d like to highlight another excellent contribution by Massimo Duca, part of his ongoing IBM i & SQL…
Intrigued by some recent posts from Cristian Larsen on LinkedIn (New Release – Display File DDS Edit v 0.10.1), I…
Hello everyone, Today I’d like to draw your attention to a major new announcement from IBM: Project Bob — a…
I want to share with you a particularly useful article by Massimo Duca in the IBM i & SQL Tips…
Hello everyone, I’d like to highlight a very useful article by Marco Riva on Markonetools, where he clearly explains how…