We are all familiar with the SBMJOB command, but it’s rare that anyone looks beyond the first few parameters. Until you need to.

One overlooked parameter is USER which allows you to specify the name of the user profile for the job being submitted. Obviously, you need to have enough authority to use the profile in question, but if you do, the submitted job will then run with all the rights of that user. Doing this can also neatly solve potential object ownership issues.

Here’s an example. I need to duplicate a logical file in the production environment. The CRTDUPOBJ command will do this for me, but that leaves me a s the owner of the new object which can cause several object authority issues down the line.

Fortunately, I can do this:

SBMJOB CMD(CRTDUPOBJ OBJ(TheFile) FROMLIB(OldLib) OBJTYPE(*FILE) TOLIB(NewLib)) USER(QPGMR)

The CRTDUPOBJ command is executed under the QPGMR profile and the resulting object is owned by QPGMR.

SBMJOB is a remarkably flexible command and it’s well worth poking around the parameters to see just how much it is capable of.

Categories: Notes

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.