1.4 Working with Actions

You can use actions to work with the objects in the Customer Inquiry application project. Edit, compile, debug, copy are examples of actions. You can invoke actions on more than one object at a time. Let's create a new action to copy files from the ADTSLAB library to your working library. You then create another new action to copy RPG source from one file to another file within your project.

Creating a New Library

Before you can create a new action to copy files from the ADTSLAB library to your working library you need to create a new library.

Follow these steps:

  1. Select OS400 in the Server list of the Project Organizer window. In the Command line type CRTLIB and press Enter.
  2. In the Create Library dialog box, in the Name field type CUSTAPPxx where xx is a unique two digit identifier.
  3. Make sure the Type check box is unchecked to specify *TEST, because this is not a production library.

  4. Select OK. This creates a new host library called CUSTAPPxx.
  5. Type ADDLIBLE CUSTAPPxx to add the library to your library list. The library will then appear in the list of libraries on AS/400.
  6. To add the library to CPO, you need to add a new library filter. Select Filter > Add > Library filter. In the Library filter field specify CUSTAPPxx. Click OK. The library is now added to CPO.

Creating a New Action

Now you can create your new action to copy files to your working library CUSTAPPxx from the sample library ADTSLAB. First you must open the Actions notebook. The Actions notebook is where you change, add, delete and reorder actions that appear in the Project Action menu and on the object pop-up menus.

Follow these steps:

  1. Select Options > Actions. The CODE Actions notebook appears.
  2. Select the AS/400 Objects tab from the notebook. The AS/400 Object actions notebook appears.
  3. Click New action.
  4. Fill in the information as shown in the following screen capture. Ensure that the DATA parameter has a value of *YES in order that the object's data is copied to the object in the new library. To help here is the command:

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

  5. Remember to change the xx identifier for the CUSTAPP library to your identifier in the Action, Comment and Command sections of the Create AS/400 Action window.

  6. Click Create. The action is added to the list at the left of the CODE Actions window.
  7. Click Move up. The new action you just created moves to the top of the list.
  8. Click OK to activate your changes in CPO. The CODE Actions window will close.

Using the Copy Action

Now let's use your Copy to library CUSTAPPxx action to copy all the objects from the ADTSLAB library to your working library.

Follow these steps:

  1. In the CPO window, select the object filter (ADTSLAB/*OBJTYPE(*)) you previously created. All objects in the ADTSLAB library appear in the file list.
  2. Press and hold the Ctrl key and select these files: GUIDES1, APPSOURCE, CUSTINQ, CUSTOMER, CUSTOML1 and CUSTOML3.
  3. Click the right mouse button to bring up a pop-up menu with actions common to all objects.
  4. Select the Copy to library CUSTAPPxx action.
  5. Click OK on the Confirm action window. The objects are copied one at a time to your library and the results of the command are displayed in the Monitor window.

Using Project and Member-Level Actions

Now let's create a new source file and copy the data from the source file in the CUSTAPPxx library to a new source file in the CUSTAPPxx library.

First you need to use a project-level action to create a source physical file. Then you need to change the member filter to work with your new library. Finally you need to use a member-level action to copy the source member from the CUSTAPPxx library to your new source physical file in your CUSTAPPxx library.

Follow these steps:

  1. Select Project > Actions > Create source file.
  2. OK the Confirm action dialogue box. The Create Source Physical File window appears.
  3. Type RPGAPPS as the name of the file and CUSTAPPxx as the library. Optionally you can type in Customer Application as the description. To type a description you must select *USRDEF next to the Text 'description' field.
  4. Click OK to complete the file creation. When you are prompted to confirm the action, click OK. The command completes successfully and is logged in the Monitor window.

Next you need to change the member filter to work with your new library.

Follow these steps:

  1. Select the member filter (ADTSLAB/*(*)) you created previously.
  2. Click the right mouse button to bring up a pop-up menu. Select Change.
  3. Enter CUSTAPPxx in the Library field.
  4. Click OK. The filter is changed and automatically opened. Objects are added to the file list on the right of the window.

Now you can use the member filter you just changed to invoke a member-level action to copy the source from the GUIDES1 file in the CUSTAPPxx library to the RPGAPPS file in the CUSTAPPxx library.

Follow these steps:

  1. Select the member filter (CUSTAPPxx/*(*)) you just changed. All the members in the CUSTAPPxx library are displayed.
  2. In the file list, select the member GUIDES1. Click the right mouse button to bring up a pop-up menu.
  3. Select Copy source member.
  4. The Confirm action window appears. Change the confirm action to: CPYSRCF FROMFILE(CUSTAPPxx/APPSOURCE) FROMMBR(GUIDES1) TOFILE(CUSTAPPxx/RPGAPPS)
  5. Click OK to complete the copy action. The command completes successfully and is logged in the Monitor window.

Changing Filters to Use Your New Library

Now you can change the object filter to search your new library. Remember that you already have a library filter since you created this filter to view the CUSTAPPxx library in CPO.

Follow these steps:

  1. Select the object filter (ADTSLAB/*OBJTYPE(*)) you created previously.
  2. Click the right mouse button to bring up a pop-up menu. Select Change.
  3. Enter CUSTAPPxx in the Object library field.
  4. Click OK. The filter is changed and automatically opened. Objects are added to the file list on the right of the window.

Click to indicate that you've done all the steps.

This completes Exercise 1. You have been introduced to the CODE Project Organizer and are familiar with some of its components such as the filters and actions. You should now have a project called Customer Inquiry Application, some filters and actions to work with that project, and a library called CUSTAPPxx containing the objects from the ADTSLAB library.

Now you are ready to launch the CODE Designer tool from CPO to create some screens for the Customer Inquiry application.

But before you do, we recommend you do the Quiz.