Thierry Seunevel Thierry 
Seunevel 
 Tech Corner      
  Home   Missions Tech corner Download Resume Contact
Home > Tech Corner > RunMnyCmd

Running AS/400 commands on many objects (4)

. Example
. List File
. Managing list
. RunMnyCmd
. Tool's Code
The RunMnyCmd Command
This command is the heart of the tool. It allows executing the same command on all the objects contained in a list, or on all objects of a given type or attribute.

Its parameters follow :
Parameter Type Text Comment
CMD *CMDSTR 500 Command to run Text of the command to execute, using predefined conventional values for some parameters, as explained at the end of this table.
The invite screen (F4) can be used to select the parameter values.
FILE *CHAR 10 Object list file name Name of the object list file
BIBLIO *NAME Library name Library hosting the object list file
The special values *LIBL and *CURLIB can be used for this parameter..
MBR *NAME 10 Member If the object list file contains several members, this parameter allows selection of the member to be used.
The *FIRST special value can be specified, and is the default.
TYPX *CHAR 8 Object type Allows to filter the command execution to the objects of this type.
Some command are restricted to certain kind of objects.
To run this kind of command on objects of an object list file, it is better to restrict execution to objects belonging to that type.
ATTRX *CHAR 10 Attribute This parameter can be used with the preceding (TYPX) to restrict execution to object having a specific attribute value.


Defining the command parameters.
The command is run on each object of the list (filtered by type and attribute).
This means that name, library and type of each object are not known at the time where you key the command, and will change for each record in the object list file. The values of this parameters will be substituted at execution time by the corresponding columns of the file.

To be properly substituted at execution time, they have to be entered exactly as follow :
OBJET for the object name
BIBLIO for the library name (if you want to substitute the value of the library)
*PGM for the type parameter, whatever is the real type. The type parameter is always controled in the commands, so it is mandatory to use a valid one. *PGM has been choosen arbitrarely. Remember that it is replaced during execution by the type recorded for each object in the file.
All the other parameters are used as they are typed.
Examples
The following command changes the owner of all objects contained in the first member of the object list file MESOBJ in the MNYCMDLIB library.
RUNMNYCMD CMD(CHGOBJOWN OBJ(BIBLIO/OBJET) OBJTYPE(*PGM) NEWOWN(QPGMR))
  FILE(MESOBJ)
  BIBLIO(MNYCMDLIB)
  MBR(*FIRST)
The highlighted parameters are replaced during execution by the corresponding values taken from the object list file.
All the objects of the list will be treated whatever their type is.

The following example shows a way to change the hold parameter of all the printfile object defined in an object list file.
RUNMNYCMD CMD(CHGPRTF FILE(BIBLIO/OBJET) HOLD(*YES))
  FILE(MESOBJ)
  BIBLIO(MNYCMDLIB)
  MBR(*FIRST)
  TYPX(*FILE)
  ATTRX(PRTF)
The CHGPRTF can only be applied to objects of type *FILE, attribute PRTF. If the objects file list contains objects of other types, it is better to filter execution filling the parameters TYPX and ATTRX.
Otherwise, the command should run on wrong objects. As the execution failures are monitored, the command would be successful on the right objects, but the completion message and the execution log would report many failures.
Giving values to the TYPX and ATTRX parameters allows a cleaner and faster execution, and if failures are reported, its worth exploring why.

    Top  Top  Previous  Managing List | Tool's Code  Next


©  Thierry Seunevel (2004) www.seusoft.com