Exercise 6.4: Creating a user action

Before you begin, you must complete Exercise 6.3: Creating an object filter.

In PDM you can create user actions in addition to using the pre-supplied system actions. In Remote System Explorer you can do the same. You define user actions through the Work With User Actions window. User actions can be defined for iSeries libraries, objects, members and jobs as well as folders and files in any remote UNIX, Windows, Linux, Local, or IFS system.

To open the Work with User Actions wizard:

  1. Expand your iSeries connection and expand iSeries Objects if not already expanded.
    Work with user actions
  2. Expand the Library list filter if not already expanded.
  3. Right-click RSELABXX.
  4. Click User Actions > Work with User Actions on the pop-up menu.

    The Work with User Actions window opens.
    Create new object action

  5. In the right pane of the Work with User Actions window, expand New in the list, if it is not expanded already.
  6. Select Object action.

    You want to create a user action that copies a source file with data to a new source file called QJUNKSRC in the same library.
    Specify new object name

  7. In the Action field, type Copy source file for the user action name.
  8. In the Comment field, type Copy source files with data.
  9. In the Command field, type CRTDUPOBJ for the command to execute.
  10. Click Prompt to open the command prompter for this command.
    Specify parameters for create duplicate object

    This is the command you will be running:

    CRTDUPOBJ OBJ(&N) FROMLIB(&L) OBJTYPE(&T) NEWOBJ(QJUNKSRC)  DATA(*YES) 
    

Specifying user action parameters

To specify user action parameters:

  1. In the From Object field, type &N to indicate to use the name of the selected object in the Remote Systems view.
  2. In the From Library field, type &L to pick up the library name from the selected object.
  3. In the Object Type field, type &T to pick up the object type from the selected object.
  4. In the New Object field, type QJUNKSRC.
  5. Select the All parameters check box to see the additional Duplicate data parameter.

    Now the Duplicate data parameter is also shown on the prompt window.

  6. Select *YES from the Duplicate data list.
  7. Click OK.

    You return to the Work with User Actions window.

  8. Select the Refresh after check box, so that the Remote Systems view gets refreshed after the action has been run.
    Complete parameters for new object action
    Note:
    Clicking the Insert variable push button displays a list of valid replacement variables with the explanation of what they do.

    This user action is only valid for Source physical files. You need to specify this restriction so this user action will only show in pop-up menus when you right-click on a source physical file.

Specifying a restriction on a user action

To specify this restriction:

  1. Under the Defined Types list box, click FILE_SRC.
  2. Click Add beside the Defined Types list box.

    FILE_SRC is now one of the selected types. Actually since you only selected this one it is the only one.

  3. Click Create then Close.

    Now, only when you right-click on a source file, will this user action appear on the pop-up menu. For any other object type it will not appear. Back in the workbench and the Remote System view, give it a try.

    Note:
    Remember to close the payroll source member if you opened it earlier.

Trying the user action

To try your user action:

  1. Locate your filter My source files.
    Select Copy source file user action
  2. Expand the filter My source files, if it is not already expanded.
  3. Right-click the QRPGLESRC file.
  4. Click User Actions > Copy source file on the pop-up menu.

    The file gets duplicated and the list gets refreshed. Your new source file will show in the list. You can check the messages of the CL commands you are running in the RSE Communications server job by looking at the iSeries Commands log in the right hand side bottom pane of the workbench.
    Check iSeries Command log for user action completion

  5. To delete the source file QJUNKSRC that you just created, right-click QJUNKSRC.
  6. Click Delete on the pop-up menu.

    The Delete Confirmation dialog opens.

  7. Click Delete.

You have created a user action that copies a source file with data to a new source file, specified user action parameters, specified restrictions on the user action and tried the user action and you are ready to begin Exercise 6.2: Creating a library filter.