Write a CL to update all jobds on system

40 pts.
Tags:
AS/400 jobs
CL
CL Commands
CL Procedure
JOBD
I need to write a CL that will change every jobd on our system w/o having to do it manually.

Answer Wiki

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

This will create a database file that contain s all the jobd descriptions on the system.
DSPOBJD OBJ(*ALL/*ALL) OBJTYPE(*JOBD) OUTPUT(*OUTFILE) OUTFILE(QTEMP/JOBDS)
Now write a CL program with DCLF JOBDS (or whatever name you used when you created the above file).
Read the file with RCVF
You will probably want to check the library name (ODLBNM) to see if you want to make your change.
Now you can use CHGJOB ODLBNM.ODOBNM to make whatever changes you want to,

Discuss This Question: 10  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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Mariodlg
    What parameters do you want to change ? Tell us more about it. Inittially I can tell you that you need to put the entire chgjobd command string into a variable, and then execute it using de QCMDEXC, like this; DCL VAR(&CMD) TYPE(*CHAR) LEN(600)<br> DCL VAR(&LEN) TYPE(*DEC) LEN(15 5) VALUE(600)<br> CHGVAR VAR(&CMD) VALUE('CHGJOBD JOBD(JOB) .......')') CALL PGM(QCMDEXC) PARM(&CMD &LEN)
    2,790 pointsBadges:
    report
  • CapitalT
    The only parameter I need to change in the jobd is the Initial ASP Group (INLASPGRP) from the current value to *NONE b/c we are doing away w/ the iASP on our system. This parameter can be up to 10 characters.
    40 pointsBadges:
    report
  • TomLiotta
    Simplest method is based on CharlieBrowne's suggestion. However, you should use DCLF over a file named QADSPOBJ because that is the file that defines the format from DSPOBJD. Then, after you run DSPOBJD to create QTEMP/JOBDS, run OVRDBF QADSPOBJ TOFILE(QTEMP/JOBDS). That tells your program to use your temporary file instead of the system file. The RCVF command will then receive records from your temporary file. For each job description record, run this command:
    CHGJOBD  &ODLBNM/&ODOBNM  INLASPGRP(*NONE)
    That will take the object name (&ODOBNM) and library (&ODLBNM) from each received record and set the iASP group to *NONE. The RCVF and CHGJOBD commands will be run in a loop until end-of-file. After the loop ends, run DLTOVR to remove the override that was set earlier. Then end the program. That's the basic structure, though you might want to put the CHGJOBD command inside an IF-statement. You might want to exclude various IBM-supplied job descriptions or do some other tests. Or maybe you want to run the DSPOBJD command like this:
    DSPOBJD OBJ( *ALLUSR/*ALL ) OBJTYPE(*JOBD) OUTPUT(*OUTFILE) OUTFILE(QTEMP/JOBDS)
    By specifying *ALLUSR instead of *ALL for the library, you would avoid most IBM-supplied job descriptions. Most of those should already be set for the correct INLASPGRP() setting. Code a basic CL program that you think looks correct and copy/paste it in a comment back here. We can look it over and offer more suggestions. Tom
    125,585 pointsBadges:
    report
  • CapitalT
    OK -- I created the file as you suggested & then started my CL w/ the DCLF cmd on that file. I'm not sure about the RCVF cmd (never used it b4 -- not done a whole lot of CL programming) but I've got it as: RCVF OPNID(*NONE). That's where I get confused -- I'm not familiar at all w/ the ODLBNM or CHGJOB ODLBNM.ODOBNM. Could you please elaborate? Thanks
    40 pointsBadges:
    report
  • TomLiotta
    Many of the available commands allow you to choose where output will go. The DSPOBJD command is one that lets you choose an output file as the target. But creating a database file requires having a definition for the file and all of the fields in that file. IBM supplies a set of "model files" that can be used to supply the definitions whenever you create output from those commands. The "model file" for DSPOBJD is named QADSPOBJ and it exists in library QSYS. You should never use any of the models for actual data, but you should use them for the definitions that you need. When you compile your CL programs to use those kinds of output files, you declare the model file in order to get the definitions compiled into the program. And you include an OVRDBF command when the program runs to tell your program that the actual data is in a different file that uses the same definition. If you run DSPFFD QADSPOBJ, you can scroll down to see the definitions of all of the fields in that file description. Two of those fields will be ODLBNM and ODOBNM -- the library name and the object name that that record describes. Those will be the names of the fields in your program. The compile listing of your program will include those names along with all of the other fields in that file. The names are automatically included as long as you declare the file. When you reference a field name in CL, you always use an ampersand ("&") as the first character of the name. That's what CL uses to recognize that a name is for a field (or for any variable). Each time you receive another record with the RCVF command, those fields will have new values assigned to them. The CHGJOBD command will use those values to select a different job description for each new record. Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    OK -- I created the file as you suggested & then started my CL w/ the DCLF cmd on that file. I might have misunderstood. There are two general methods that can be used. First, you can run a command to create an outfile, then compile a program directly declaring the file that you created. And second, you can do it all combined in the program so that the program does everything all together. I almost always use the second method. But now that I re-read your sentence above, it sounds like you tried to use the first method. The first method is especially tricky when you are creating the outfile in library QTEMP. Whenever you use QTEMP, everything in that library is only available in the same job. That is, if you want to compile a program over the file, the compile must run in the same job that created the outfile in QTEMP. You can't submit the job for a compile in batch. That's one reason that I use the second method with a model file. The model is always available whether I compile interactively or in batch. But when you use the second method, you should also put the command that creates the outfile into the program. That's part of keeping everything in one place. The program can compile because it references the permanent model file. And the program can run because it creates the outfile in QTEMP wherever the program is running. Copy/paste your CL into a comment. Tom
    125,585 pointsBadges:
    report
  • CapitalT
    Tom, I initially followed CharlieBrown's instructions & ran the DSPOBJD command w/ outfile being(MYLIBRARY/JOBDS2CHG) I then created a CL with this information: /*-------------------------------------------------------------------*/ dclf file(mylibrary/jobds2chg) /*-------------------------------------------------------------------*/ /* */ rcvf opnid(*none) monmsg cpg0864 exec(goto endpgm) chgjobd jobd(&odlbnm/&odobnm) inlaspgrp(*none) /*-------------------------------------------------------------------*/ I can go back and add the DSPOBJD command to my CL using the *ALLUSR library as you suggested and delete the file I had initially created -- that's no problem for me to do. I do like the 2nd method you referred to - it does seem to the better method.
    40 pointsBadges:
    report
  • TomLiotta
    I can go back and add the DSPOBJD command to my CL... No, what you have is fine and makes sense, especially since this is probably going to be a one-time run. All you need to do is add a label before the RCVF command, a GOTO {label} command after CHGJOBD, and replace (goto endpgm) with (return) in the monmsg. As long as the {mylibrary/jobds2chg} file exists when you compile the program and it still exists when you run the program, it should work. You can run the DSPOBJD command over again to replace the content of {mylibrary/jobds2chg} if you wish. Restricting the output to *ALLUSR libraries would make for a smaller set of job descriptions and skip over some that probably shouldn't be messed with. Make sure that you run DSPOBJD with enough authority to select every necessary job description, and also run the program with enough authority to change every selected job description. Tom
    125,585 pointsBadges:
    report
  • CapitalT
    [...] 10. CharlieBrowne, Mariodlg, and TomLiotta are helping CapitalT write a CL to update all jobds on system. [...]
    0 pointsBadges:
    report
  • CapitalT
    [...] 2. CharlieBrowne, Mariodlg, CapitalT, and TomLiotta pitched in to help a member write a CL to update all jobds on a system. [...]
    0 pointsBadges:
    report

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following