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

- Select OK. This
creates a new host library called CUSTAPPxx.
- Type ADDLIBLE CUSTAPPxx
to add the library to your library list. The library will then appear in the list of
libraries on AS/400.
- 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:
- Select Options >
Actions. The CODE Actions notebook appears.
- Select the AS/400 Objects
tab from the notebook. The AS/400 Object actions notebook appears.
- Click New action.
- 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)
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.
- Click Create. The
action is added to the list at the left of the CODE Actions window.
- Click Move up.
The new action you just created moves to the top of the list.
- 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:
- In the CPO window, select the
object filter (ADTSLAB/*OBJTYPE(*)) you previously created. All objects
in the ADTSLAB library appear in the file list.
- Press and hold the Ctrl
key and select these files: GUIDES1, APPSOURCE, CUSTINQ, CUSTOMER, CUSTOML1
and CUSTOML3.
- Click the right mouse button to
bring up a pop-up menu with actions common to all objects.
- Select the Copy to library
CUSTAPPxx action.
- 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:
- Select Project >
Actions > Create source file.
- OK the Confirm
action dialogue box. The Create Source Physical File window appears.
- 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.
- 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:
- Select the member filter (ADTSLAB/*(*))
you created previously.
- Click the right mouse button to
bring up a pop-up menu. Select Change.
- Enter CUSTAPPxx in
the Library field.
- 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:
- Select the member filter (CUSTAPPxx/*(*))
you just changed. All the members in the CUSTAPPxx library are displayed.
- In the file list, select the
member GUIDES1. Click the right mouse button to bring up a pop-up menu.
- Select Copy source member.
- The Confirm action window appears.
Change the confirm action to: CPYSRCF FROMFILE(CUSTAPPxx/APPSOURCE) FROMMBR(GUIDES1)
TOFILE(CUSTAPPxx/RPGAPPS)
- 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:
- Select the object filter (ADTSLAB/*OBJTYPE(*))
you created previously.
- Click the right mouse button to
bring up a pop-up menu. Select Change.
- Enter CUSTAPPxx in
the Object library field.
- 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.