Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

locking files

Posted on 2014-03-10
4
Medium Priority
?
272 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 35

Accepted Solution

by:
Gary Patterson earned 2000 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 35

Assisted Solution

by:Gary Patterson
Gary Patterson earned 2000 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 35

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
Media Temple is thrilled to announce the launch of our new Partner Program, specifically designed to empower digital agencies and adtech platforms by offering white-glove support and exclusive hosting enhancements to optimize their sites and their c…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Integration Management Part 2
Suggested Courses

886 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