OCL to CL conversion

20 pts.
CL programming
IBM iSeries
OCL procedure
In OCL you can check a file for activity by using the an If Active command.  Is there something similar in CL programming?

Software/Hardware used:
iseries running V6R1

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you mean, does it have records, then use RTVMBRD command
If you mean is someone using the file, you can use WRKOBJLCK command
Let me know if you need more clarification

WRKOBJLCK is great but how do you use that within a CL program to determine if you can say do a CLRPFM command?

Discuss This Question: 3  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • CharlieBrowne
    You can use ALCOBJ with *EXCL to ensure no one else is using the file.
    62,385 pointsBadges:
  • TomLiotta
    ALCOBJ can give an indication if the file is "in use". But keep in mind that if the command succeeds, you should probably immediately deallocate the file. What I usually do is a sequence like this:
    ALCOBJ (<file ID> *EXCL)
    MONMSG (CPF1002) ...
    ALCOBJ (<file ID> *SHRxx)
    DLCOBJ (<file ID> *EXCL)
    Then the programming continues. That is, I try to allocate exclusively. I would have a MONMSG after the first ALCOBJ to catch a failure of exclusive access; the action to take would depend on what needed to be done for that program. If the first ALCOBJ succeeded, the second ALCOBJ would set whatever access level that I actually wanted. Once that was set, I would deallocate the initial exclusive lock. The final result is a shared lock that would only be possible if the file was "active" at the beginning. All of that might need clarification depending on what is meant by "active" and what the purpose of testing for "active" is in the first place. Usually the use of that S/36 OCL feature is inappropriate in native AS/400 procedures. It most often means that a process should be redesigned to work according to how this system can do things. For example, it might be that there is a desire to clear a file; but that it shouldn't be done while the file is "active". Well, if the file is "active" and you try to run a CLRPFM command against it, the CLRPFM command itself will report back that the file is "active". In such a case, there's no point to running a specific test ahead of time. Tom
    125,585 pointsBadges:
  • TomLiotta
    Typo -- {if the file was “active” at the beginning} should be {if the file was not “active” at the beginning.} Tom
    125,585 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: