Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

developerWorks Community:

  • Close [x]

Calling IBM i programs from EGL using Rational Business Developer

Claus Weiss, Advisory Software Consultant, IBM
Claus Weiss is an advisory software consultant with the Rational Software System i – Ecosystem team at the IBM Canada Toronto Laboratory. He has degrees in industrial engineering and computer science from the University of Hamburg in Germany. He worked as a systems engineer with IBM Germany and joined the IBM Toronto Laboratory in 1984. He was a developer and team leader for System/38 development tools. He has been a member of the Design Control Group for the AS/400 development tools. He has worked as a consultant for IBM iSeries Application Development for the past 10 years, specializing in Visual Tools. Claus is a frequent speaker at COMMON and other iSeries conferences and a six-time winner of COMMON's Speaker Excellence award. He is also the lead author of the book title "Understanding the IBM WebFacing Tool," published by IBM Press, and has co-authored several IBM Redbooks.

Summary:  This tutorial describes how to write Enterprise Generation Language (EGL) code that calls programs (RPG, COBOL, CL, CL Commands, or programs written in any supported language) on your IBM® System i5™ machine. The process for you to call an existing IBM i™ program from EGL has been very much improved in IBM® Rational® Developer for System i™ V7.1 (and later), and is incredibly simple. EGL leverages the IBM i Toolbox for Java™, which in turn utilizes the System i5’s Remote Command Host Server (QZRCSRVSD in the QSYSWRK subsystem).

Date:  19 Aug 2008
Level:  Intermediate PDF:  A4 and Letter (3472 KB | 44 pages)Get Adobe® Reader®

Activity:  290 views
Comments:  

Error handling

This looks good. If you have time left, you can add some error handling.

Handling a record not found condition

The feedback parameter will tell you whether the record access for the customer number has been successful. If the customer exists in the database, it returns a 0. Otherwise, the customer number will be returned.

Return to the pagehandler code:

  1. Right-click the white space in the page designer and select Edit Page Code.

Add the if statement as shown in Listing 3:

  1. You compare variable feedback to zero
  2. If it is not zero
    1. Use the built-in seterror function to write an error message. You concatenate the wrong customer number in the error message.
    2. You set the data structure cds to blank, so older output gets erased from the page.

Listing 3. Add the if statement
	call "GETDATAE" (cinput, cds, feedback);
	if (feedback != "0")
	    SysLib.seterror("Customer number " + cinput + " not valid"0;
	    cds = " ";
	end

The error message displays in the message control that has been added by default to the page when you added the customer number input field, as shown in Figure 43.

  1. Save the changes.
  2. Run the application again.

Figure 43. Error message
Customer number 99 not valid

Debugging the RPG program

If there are problems with calling the program on IBM I, you can use the built-in workbench integrated debugger to debug the RPG program when it gets invoked from EGL.

To do this, perform the following steps, as shown in Figure 44.

  1. Switch to the Remote System Explorer perspective.
  2. Expand the connection to the System i5 server, or create a new connection.
  3. Create a filter for the EGLLABBV7xx library.
  4. Expand the EGLLABV7xx library.
  5. Locate the GETDATAE program.
  6. Right-click the program and f select Debug (Service Entry) > Set Service Entry point.

Figure 44. Prepare to debug the program
pop-up menu

You will see a message telling you that the Service entry Point is set successfully, as shown in Figure 45.

  1. Click OK.

Figure 45. iSeries Debug Message
refresh by recompiling or updating the program

In the RSE perspective, a new view gets added. This view shows all service entry points on the system, as shown in Figure 46, and it also allows you to work with these Service Entry points.

  1. Go back to the Web perspective

Now run the CALLEGL001R.jsp again.

  1. Enter a valid customer number, such as 0010200.
  2. Click the callRPG button.

Figure 46. View showing service points
table with data

The debug perspective will display with the RPG source loaded.

  1. Set a breakpoint where you think it is needed (in Figure 47, it is set after the chain statement). To set a breakpoint, double-click in the grey column next to the line numbers.
  2. Click the debugger run button.

Figure 47. Set a breakpoint
tree view on top, code on bottom

If the chain was successful, the data will show in the variable monitor, as shown in Figure 48.

  1. Click the run button again to end the program.

Figure 48. Variables view
debug on left, variables on right

You could also debug the EGL source by performing these steps.

  1. Set a break point in the CALLEGL001R.egl source, as shown in Figure 49. Open the source in the editor, which is integrated with the debugger and allows you to set breakpoints.

Figure 49. Set a breakpoint in the source
break after function callRPG()
  1. Then start it like you normally do, but instead of selecting Run on Server, perform the following steps:
    1. Select Debug on server
    2. Enter a customer number
    3. Click the CallRPG button

The workbench switches to the debug perspective, as shown in Figure 50.


Figure 50. Debug perspective
debug on left, variables on right

The perspective looks similar to what you've seen before, but now it shows the EGL source.

  1. If the Service entry point is still active, and if you specify run in the EGL debug session, the debug perspective will show the RPG debug views, as shown in Figure 51.

Figure 51. Debug perspective
source code at bottom of view

You have completed this lab exercise.

7 of 9 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational, Sample IT projects
ArticleID=330659
TutorialTitle=Calling IBM i programs from EGL using Rational Business Developer
publish-date=08192008
author1-email=weiss@ca.ibm.com
author1-email-cc=