Thierry
Seunevel |
Tech Corner |
Running AS/400 commands on many objects (1)
Deploying or maintaining AS/400 applications, you often need to execute the same command on many objects. Some commands allow the use of generic names, but many don't.
Using F9 and F4 is not very helpful, since you have to type the proper name for each object.
The tool described here addresses this issue. It allows creating and managing lists of objects, and running commands on all the objects of a list, or on subset of objects filtered by type or attribute.
|
|
| Example |
Before distributing a new library, you want to change the owner of all the objects.
The CHGOBJOWN command cannot be used with a *ALL value for the Name parameter. The normal way should be to call the command once for each object.
Using RUNMNYCMD allows achieve the process in only 2 commands:
|
|
CRTOBJPF
RUNMNYCMD
|
OBJPF(mylist) LIB(mylib) MBR(firstmbr) LIBS(BIBPGM)
CMD(CHGOBJOWN OBJ(BIBLIO/OBJET) OBJTYPE(*PGM)
NEWOWN(QPGMR))
FILE(mylist)
BIBLIO(mylib)
MBR(firstmbr)
TYPX(*PGM)
ATTRX(RPG)
|
|
- The first command, CRTOBJPF creates the list file.
In this example, the file name is mylist (parameter OBJPF), in the library mylib (parameter LIB), with a data member named firstlist (parameter MBR) and will contain all the objects in BIBPGM (paramètre LIBS)
- The command RUNMNYCMD shown here executes the command defined by the CMD parameter, in our example CHGOBJOWN on all the RPG programs of the object list created in the preceding step.
On completion of the command, a message is displayed, reporting the number of objects in the list and the number of fails. Clicking F10 with the cursor on the message line shows the detailed log of the command, with a line for each object. Failures can easily be found.
The same list refers to a logical subset of objects, and can often be used to execute more than one command.
Objects lists can be managed in different ways. Objects can be added or deleted individually through a user option of PDM, or lists can be created as results of Queries or SQL.
Working with objects lists allows much more than the simplistic example shown above.
It can be the basis of a make like tool.
While you work on a set of modifications, you add a record for each object you change to an object file associated with your changes.
In that file, you can create different members, according to your own rules. For instance, if you store application files in a library, and program objects in an other one, you can create a different object file member for each target library.
When comes the time to deploy your set of modifications, you can easily list the objects involved (using the list command provided by the tool), change object ownership, move modified objects to your test library, or to the operational libraries, or even compile all the programs involved running only few commands and beeing sure that no object will miss.
You can also create CL programs and calling commands to automate some processes like changing a file structure without any data or logical file losses, and run these commands on all physical files of an objects list.
|
|
|
© Thierry Seunevel (2004) |
www.seusoft.com |
|
|
|