Exercise 2.7: Editing an RPG source member and creating a *PGM object

Before you begin, you must complete Exercise 2.5: Opening a source member for edit and if you were unfamiliar with the editing features of the Remote Systems LPEX Editor then you must completeExercise 2.6: Reviewing Remote System LPEX Editor features.

To make it easier for you, most of the RPG source is already prepared for you. You have already opened the correct source member GETDATA in a previous exercise using the Remote Systems view.

Read through the source. It contains an F spec to access file CUSTOML3, which contains the customer data keyed by customer number. The D specs define the data structure CSTRUC that you pass back to your Web page and the CUSTNOI variable that gets passed from the Web page to this program. As well the FEEDBACK variable is defined as a 20 length character field.

The Entry parameter list is defined as:

To edit then create a *PGM object with RPG:

  1. Add the code to get the customer record and check whether the chain was successful.


    Close the member

    Your coding is complete, so let's create the program.

  2. Click the Save Save button icon on the workbench toolbar to save the member.
  3. Click the X in the Editor window title bar to close the member.
    Close member

    Be careful not to click the X on the workbench window title bar.


    Compile

  4. In the Remote Systems view, right-click the GETDATA member in source file QRPGLESRC and click Compile (Prompt) > CRTBNDRPG on the pop-up menu.

    The Create Bound RPG Program (CRTBNDRPG) dialog opens.
    CRTBNDRPG prompt

  5. In the Debugging views list, select *ALL
  6. Click OK to start to compile.

    After compile, the iSeries Error List view is shown, listing all compile errors. You may see only information and warning messages which means your compile was completed and the program object was created.
    iSeries command log

  7. Click the iSeries Commands Log tab to check that the compile was successful. This log shows the Remote System Explorer job messages.

If you get a message that there are errors in your program, go through the edit compile fix cycle.

Fixing errors

In the error list view, check the errors:

  1. Double-click the error.

    This positions the cursor in the Editor window on the statement that is wrong.

  2. Fix all errors.
  3. Save the source member.
  4. Go back to the Remote Systems view.
  5. Right-click the member to run the CRTBNDRPG command.
  6. Continue this cycle until you get a clean compile.

You have edited an RPG source member and created a program object.

Module recap

You have completed Module 2. Creating an RPG program. You have learned how to:

Now that you have created the RPG program, you can continue to Module 4. Creating a Web project.

Skip Module 3. Creating the RPG service program for your Web application (optional) as you don't need to do this set of exercises.