|
Introduction to Communications Console and CODE/400's Code/Editor
by Shannon O'Donnell
Unless you've been in a cave since last May, you know IBM released a new set of development tools called WebSphere
Development Studio along with OS/400 V5R1. These new tools, which are also available for OS/400
V4R5, contain the OS/400 licensed programs, compilers, and several PC-based development tools. If you're
curious about how to start using these new PC-based development tools, and you're ready to jump into the
21st century, then keep reading.
My goal is not to make a PC convert out of you. I simply want to show you what your options are, teach
you how to use the tools, and then let you be the one to decide which tool works best for the job at
hand. If this doesn't sound like something you're interested in, you can stop reading now. Ignorance is bliss,
but knowledge will enable you to pull down the extra bucks and allow you to buy that shiny new sports car!
If you're a, dare I say, "traditional" AS/400 programmer, you're probably a bit overwhelmed and confused
about when, why, or how to use these new PC-based tools. In fact, if you're like the majority of AS/400
programmers out there, you're probably still typing your code into SEU on a green-screen and compiling it
out of PDM. If this accurately describes you, there's no need to bow your head in shame. You are among
friends here. We're all guilty of developing applications the "old" way.
But there is an alternative to doing traditional code development the old-fashioned way. CODE/400 and its
associated tools--Code/Editor, Code/Designer, and Program Generator--allow you to edit and compile
iSeries programs directly from your PC.
Communications Console
Before you can get started with CODE/400, you must first set up and configure the Communications
Console. This console is the conduit through which all the other WebSphere development tools will
communicate with your iSeries. So setting it up is critical. You'll be glad to know, however, that once you
set it up you shouldn't ever need to touch it again.
Assuming you have WebSphere Development Studio installed on your PC, here's how to set up
Communications Console. All of these instructions are to be performed on your Windows PC:
1. Click Start
2. Click Programs
3. Click IBM WebSphere Development Tool for iSeries
4. Click Communications
5. Click Communications Console
6. Click on the Add New Server button
7. Enter the AS/400 IP address or name. (Use the name of your iSeries if you set up a local HOST
table entry on your PC. For more on that, see How Does Your Browser Find a
Web Page?")
8. Enter an alias for your iSeries that is easy to remember. You can use this alias when referring to the
iSeries from within the development tools. It also makes it easier to remember which iSeries system you're
currently working with when you have more than one defined within Communications Console.
9. Enter a default iSeries user ID and password. You don't have to enter anything into these fields. But
if you don't, you'll be prompted to log on to your iSeries each time you start Communications Console or
use one of the development tools to communicate with your iSeries.
10. When you're all done--and this is very important--click on the CHANGE button. If you don't, and
instead only click on the OK button, your new server information will not be stored. Don't ask me why it
was designed this way. Just make sure you click on CHANGE before you click OK.
11. You can also check to see if your iSeries is up to date on PTFs for the WebSphere Development
Studio tools. Just click the Check PTFs button and a list of installed and not installed (but required) PTFs
will appear (it can be a slow process) on this panel. If you don't have all the requisite PTFs installed, you
should do so before continuing. Otherwise, you may not even be able to use the rest of the WebSphere
tools.
That's all you need to do to configure Communications Console. There are more options available to you
with the Communications Console, but those I went through here are the only required options.
CODE/400
You're now ready to start working with CODE/400. Using CODE/400's Code/Editor, you can create or edit
existing source members for all of the following iSeries source types:
BAS, BND, C, CBL, CBLLE, CICSC, CICSCBL, CICSCBLLE, CICSQLCBL, CL, CLLE, CLP, CMD,
CPA, CPO, CPPLE, DSPF, H, HTML, ICF, IPF, JAVA, LF, MNUDDS, PF, PLI, PNLGRP, PRTF,
REXX, RPG, RPG36 , RPG38, RPGLE, RPG, SQLC, SQLCBL, SQLCBLLE, SQLCPPLE, SQLRPG,
SQLRPGLE, TXT, VRPG
Some of these source member types may not be familiar to you. VRPG, for example, is a source type for
VisualAge for RPG. Don't worry about it. I listed all the source types here just so you could see how
comprehensive the Code/Editor is. When you start using Code/Editor with different source member types,
you'll see that it is a smart editor. With RPG IV source member types, for example, your menu items and
prompts will be specific to the RPG IV language. For HTML source file types, the menu options and
prompts will be specific to HTML files. This "smart" editor makes developing code in multiple languages
much easier!
Using Code/Editor
To start the Code/Editor, follow these steps:
1. Click on Start
2. Click on Programs
3. Click on IBM WebSphere Development Tool for iSeries
4. Click on CODE/400
5. Click on Code/Editor
You'll need to choose what type of source file you want to work on, or open an existing source member.
Let's create a new RPG IV source member first:
1. Click on the Code/Editor icon, in the left most position of the icon tool bar. (It looks like a bright
piece of white paper.) This is the New menu item. Alternatively, you can click on File/New, from the
Code/Editor menu.
2. Now select the Source member type of RPGLE, from the New prompt panel. Leave the Local File
box checked.
For this example, we'll create an RPG IV procedure that accepts two numbers, adds them together, and then
returns the result. So the first thing we'll need to do is insert a new RPGIV Procedure. Code/Editor makes
defining all the things you'll need for creating procedures very easy.
Click on the Code/Editor menu item Actions, click on Smart Guides, and then click on Create Procedure.
You should see a panel pop up that looks very similar to the one shown in the figure below. We'll define
everything you need for your new RPG IV procedure from this Smart Guide.
Let's name the procedure Add2. Type ADD2 in the Procedure name field. Next, let's make this
procedure so that it can be used by any other ILE program. We'll do this by checking the "Exportable for
use by other code (EXPORT)" checkbox, found below the External name field. You can also add a
comment in the Purpose box to help you remember what this procedure is used for.
Since we'll be returning the product of the two numbers passed to this procedure, we want to make sure that
the "Return a value" checkbox is checked. We also need to define how many parameters will be passed into
this procedure. In our case, we want two parameters. Use the spinner next to the "How many parameters"
field to select 2 parameters. Your Smart Guide should look similar to the one shown here:

Click on the Next button, at the bottom of the panel.
As you can see in the figure below, you now need to define the characteristics of the Return parameter.
Remember, this will be used to store the result of adding two numbers, so this field should be defined as a
numeric field. Use the spinner next to the Type field to select a data type of Zoned Decimal. You can select
any other data type you want, but this one will work for our example. Now you need to define the number
of digits for that field and indicate if there are any decimal positions. Use the spinner on the Length field to
set the field length to 5 digits. Leave the Decimals field set at 0. Click the Next button to define the input
parameters. Define those fields in the same manner you defined the Return parameter.

On the parameters panels, shown in the figure below, you'll need to specify whether or not to pass the
values of the input parameters By Reference or By Value:

Which do you choose? The choice is really up to you. When you pass a field by reference, you're saying,
"Here's where my original piece of data is stored in memory. Feel free to change the actual contents of this
field from within this procedure." In other words, when passing a field by reference, you are giving the
procedure you pass the field to the ability to change the value of that field. In this example, where we are
adding two numbers to get a third, you probably don't want to do that. After all, you don't want to pass in a
4 and a 5 to this procedure and then have it arbitrarily change your 4 to a 9! That's what could happen when
you pass by reference.
Instead, you probably want to pass these input parameters to this procedure by value. This means the
procedure will get a copy of the actual value of the parameter (say 4 and 5 for this example) and not be able
to change those values. This is usually the safest way to go when passing parameters. Select the checkbox
to "Pass read-only reference (CONST)" and you'll be safe. You can also enter a field name for each of the
input parameters, as well as a description, but you don't have to.
Click on the Next button to define the remaining parameters, then click the Final button to finish the
procedure.
Now all that's left in order to complete this example is to add the code, add the two input parameters
together, and place the product into the return parameter. When you're all done, your code should look like
this:
You can add new lines of code in many ways in Code/Editor. The easiest way is to move your cursor to the
line you want to add the code to, and press the Enter key. A new blank line will be added. You can press
the F4 key to prompt for that source member line type. Press F1 on that line to display an online RPG IV
reference manual. One more thing: Make sure you add an H-spec and the NOMAIN keyword to your
source code. This will allow you to create a *SERVICE program from it and make it callable by any other
ILE program.
Verifying
Now that your new procedure is finished, you should save it on the iSeries and compile it. But before you
do that, you can "verify" it. Verifying a source member means that the Code/Editor does a "precompile" for
you, checking for syntax errors and the like. This will save you tons of time later on when you go to
actually compile it on the iSeries. To verify the program, click on the Actions menu item, then click on the
Verify menu item. You should next click on the Prompt menu item so that you can set any default compile
options. Remember, you're not actually compiling the program here, you're only verifying that it will
compile (i.e., checking for syntax and other errors). However, any compile options you specify here will
help you to further refine the verification and thereby help to ensure a smooth compile later on. Have a look
at the various options from the verification prompt window and, when you're done, click on the Submit
button.
When you get back to the Code/Editor, you'll probably see the compile listing for the program. If you don't,
it's because you selected the option for *NOLIST on the verify prompt window. To return to the actual
source member you're editing, click on the Code/Editor Windows menu item, then click Previous in Ring.
This should take you back to the RPG IV source member. Add any additional code you may need, if any,
and when you're done, run the verify option again. Everything should have verified normally that time, with
perhaps no more than one warning message telling you that a name or indicator was not referenced.
Saving the Source Member on the iSeries
Now it's time to save new RPG IV procedure to the iSeries. Remember, the verify option is not required,
but it can save you time later on when you go to compile the source member on the iSeries. Click on the
Windows menu item and select Previous in Ring to return to the actual source member. Click on the
File/Save menu item. You'll be prompted with the "Select file – Save As" panel, shown here:
Find the iSeries you defined in Communications Console and click on the plus (+) sign next to that name.
You'll need to drill down through the resulting list until you come to the library and source file where you
want to save this source member. In this example, I'll save the source member to a file named
QRPGLESRC in library SHANNON, and I'll name the source member ADD2P. Notice I named this
program ADD2P (there's a "P" on the end of that name!). I mostly did this so that it would compile
correctly (because I'm using the EXPORT keyword with the procedure) as an RPG module. I could have
avoided this by naming the actual procedure in the code something else, but this seemed like the fastest
solution to avoid compilation errors for this example. You may want to give more thought to naming your
own procedures! When you're done, you should have a panel similar to the one shown here:
Click the OK button to save the source member to the iSeries.
Compiling the Source Member on the iSeries
The source is now safely stored on your iSeries. Time to compile it! From Code/Editor, click on the
Actions menu item, then click on Compile. Next, click Prompt. You'll be prompted to create an object type
that's appropriate for your source member. Since we're creating an RPG IV object that has no main
procedure and we'll be using this prototype as a module in a *Service program, we want to create an ILE
module. The CRTRPGMOD object type should automatically be selected for you. You can change any of
the other creation parameters from the Compile panel, but when you're all done, click on the SUBMIT
button to actually create your module.
The Rest Is Up to You
You now have a *MODULE named ADD2P on your iSeries. Your next step is to create a *Service
program from it, and then you can try calling it from another ILE program. I'm not going to reiterate how to
create *Service programs in this article, since Kevin Vandever did such a great job of stepping you through
everything you need to know to create one in "The Basics of ILE Service
Programs." Go back and read that article, and apply what you learned to the new *MODULE you
created here.
Code/Editor is feature-rich. Now that you have a basic understanding of how to use it, you should start
experimenting with it to create your own programs. Remember, you can create RPG IV, COBOL, CLP, and
many other program types using Code/Editor. Play with the various menu options to see what they do.
Notice how the menu options change depending upon which type of source file you're creating or editing.
Try opening an existing source file from your iSeries and editing it with Code/Editor. But most of all, have
fun with it. Someday, IBM will probably take away SEU. Before that happens, you'll see yet another
version of CODE/400 (in fact, you'll see one later on this summer!). But spend the time now getting
familiar with this version and getting familiar with developing applications from your PC. When newer
versions come along, you'll be that much closer to being ready to use them, too.
|