|
Antonio If I understand your requirement correctly, the only time this job will have members is while this job is running. You don't want this job affected by data from other jobs, and you don't want data from this job affecting other jobs. If this is so, there are a couple of different ways you can handle things. The first is to use CRTDUPOBJ to create a copy of the file in QTEMP. This is often the preferred way of stopping data from one job affecting another, because if you put members into the 'live' version of the file, and then your program abnormally ends before it removes the unwanted members, these members can affect the next job to use that file. If you use QTEMP, this problem is avoided, and there is no need to use ALCOBJ at all. The second option is to have a member (or members) that you clear each time you run the job. You can still use ALCOBJ to keep one job accessing the file at a time. One consideration with this approach is whether your members have specific names that are determined at run time (such as department number or date/time). If threy do, then you could have a dummy member to allow your ALCOBJ loack, and then create/remove whatever members you like. <Snip> Today I wrote a simple CL program that needs to take *EXCL control of a file. When this work starts, the job should have NO members at all, and the job will go adding some members. At the end of the job, all members will be removed (normal end of work). When allocating (ALCOBJ) an object of type *FILE, you can specify no member in the command (then Allocate is done on the whole object) or you can also specify the member you want to specifically allocate. In this case you get a *SHRRD on the file and a *EXCL on the Members data. So far, so good. But what happens if the file has no members at all? <End Snip>
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.