Exercise 3.7: Editing a member and creating a service program module

Before you begin, you must complete Exercise 3.5: Open a source member for edit and if you were unfamiliar with the editing features of the Remote Systems LPEX Editor then you must complete Exercise 3.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 GETDATAS 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 gets passed back to your Web page and the CUSTNOI variable that gets passed from the Web page to this program. Also variable FEEDBACK is defined as 20 characters, to return message id and customer number in case the customer record was not found.

The prototype for procedure getrecord with the parameters is defined as the:

Note:
The external name is case sensitive. It has to match exactly what you specified in the Web Interaction wizard.

The procedure interface defines the parameters in the same way as the prototype. Inside the procedure after the procedure interface you need to add the RPG code.

Adding RPG code

To add the RPG code:


Close the member

  1. You do a CHAIN to the database and move the database fields to the local procedure structure. If the database access fails, move the MSGID and Customer number to the FEEDBACK variable.

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

Creating the service program module

To create the service program module:

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

    Be careful, don't click the X on the workbench window title bar.

  3. In the Remote Systems view, right-click GETDATAS member in QRPGLESRC and select Compile (Prompt) > CRTRPGMOD on the pop-up menu.
    Compile with prompt

    The Create RPG Module (CRTRPGMOD) dialog opens.
    CRTRPGMOD prompt

  4. In the Debugging views list, select *ALL
  5. Click OK to submit the command.

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

  6. Click the iSeries Commands Log tab to check if the compile was successful. This log shows the Remote System Explorer job messages. If you get a message that there have been errors found in your program, go through the edit compile fix cycle.

Fixing errors

In the iSeries Error List view, check the errors:

  1. Double-click on 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 CRTRPGMOD command.
  6. Continue this cycle until you get a clean compile.

Creating a service program

To create a service program:

  1. In the Remote Systems view find the GETDATAS module in library WSSLABxx.
    Note:
    If you don't see the module, right-click library WSSLABxx and click Refresh on the pop-up menu.
  2. Right-click GETDATAS module and click Create > Service Program on the pop-up menu.
    CRTSRVPGM command

    The Create Service Program (CRTSRVPGM) dialog opens.
    CRTSRVPGM prompt

  3. For the service program name, leave GETDATAS.
  4. For the library name, leave WSSLABXX.
  5. In the Export list, select *ALL.
  6. Click OK.
  7. Click the iSeries Commands Log tab at the bottom of the workbench.

    You should see a message that the Service program was created.
    iSeries Command Log

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

Module recap

You have completed Module 3. Creating the RPG service program for your Web application (optional). You have learned how to:

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