Solved

locking files

Posted on 2014-03-10
4
260 Views
Last Modified: 2014-03-10
RPG PROGRAM A, opens 30 files, it calls a CL which is Calling another CL, which tries to clear those files. It can not clear the because RPG still has them in the stack
0
Comment
Question by:sniger
  • 3
4 Comments
 
LVL 34

Accepted Solution

by:
Gary Patterson earned 500 total points
ID: 39918618
Yes, that's right.  By design, you cannot clear a file while it is open.  Clearing a file requires an exclusive lock.  

Generally you must close the files in RPGA before calling a program that may try to clear them.

One note, and I hesitate to mention it - is that you CAN delete all the rows in a file when the file is open (as opposed to clearing them) - except for any individual rows that might be locked at the moment.

If you use embedded SQL to clear the tables:

DELETE FROM TABLE1
DELETE FROm TABLE2

SQL will pick the best method.  Clearing is best, if the required exclusive lock can be obtained.  Clearing actually frees up the disk space, where deleting doesn't.  

If an exclusive lock cannot be obtained, SQL will automatically revert to single-row deletion, and delete each row individually.  This can take much longer, uses more CPU and disk IO, and will not free the disk space, but all the active records will be removed - and if the file is set up to reuse deleted records, the some or all of the deleted space will get reused the next time the file is populated.
0
 
LVL 34

Assisted Solution

by:Gary Patterson
Gary Patterson earned 500 total points
ID: 39918635
An alternative to closing and reopening files in RPGA (that might take some significant re-engineering depending on the program structure), one solution to this problem is to rearrange your program a little.

Instead of RPGA -> CL1 -> CL2, you may want to do something like this:

CL0 calls RPGA
   When user selects a function that may require clearing files,
   terminate RPGA with *INLR = *ON and return to CL0,
   setting a return value telling CL0 to call CL1

CL0 calls CL1call CL2
   Files get cleared

CL2 returns to CL1 returns to CL0

CL0 can now call RPGA again, or do whatever needs to be done at this point.
0
 

Author Comment

by:sniger
ID: 39918640
Thanks Gary,  how about putting everything in one activation group (CALLER activation group)


would this help ?
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 39918741
Reasonable thought, but no not in this case.  Try it - it is what? - about 5 lines of code?

Rpg:

Fmyfile if              e disk
c                     read  myfile
c                     call 'TESTCLEAR'
c                     eval *INLR = *ON

Open in new window

TESTCLEAR (Clle)

clrpfm myfile

Open in new window


CLRPFM requires a system-side exclusive lock.  That means no locks on this file by anything in this job - same activation group or different activation group - or any lock in any other job on the system, either.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Owning a franchise can be the dream of a lifetime. It provides a chance for economic growth. You can be as successful as you want.  To make your franchise successful, you need to market it successfully. Here are six of the best marketing strategies …
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now