Before you begin
You can create an RPG Java™ Method call from any ILE RPG file in
the Remote Systems LPEX editor. An RPG Java method call is a piece of ILE RPG code
that calls various Java methods, so that you can call Java methods
from your RPG program. When you specify various Java class and method information, the method
call creation wizard creates valid ILE RPG code that calls the Java methods
from your RPG program.
About this task
The New Java method call wizard will change dynamically, depending
on the selections that you make. Use the F1 help for more information on each
option as you go through the wizard. To create the RPG Java method
call:
Procedure
- Expand your connection until you find the file in which you want
to create the method call.
- Double-click the file to open it in the Remote Systems LPEX editor.
- With your cursor inside the editor view, right-click and select New
> Java Method
Call. Or, from the workbench menu, click Source > New > Java Method
Call.
- In the New Java Method Call wizard, specify the Java package
and the class you want to use for the method call. Use the Browse workspace, Browse
local, and Browse remote buttons to search for packages and classes.
When you search for class files on your local system, you can press Add
JAR file to find a file that contains the class you want to use. Use the
F1 help for more information on each option. Click Next.
- Select the Java method that you want to use. (The methods
listed are the ones available from the class selected in the previous page
of the wizard.) Click Next.
- Select the Java method parameters that you want to
use. For each parameter, you can generate an RPG field, specify its RPG name,
type, length or dimension, and whether to pass the parameter by reference
or to have a read-only reference. You can click each cell in the table to
edit the value directly. If you selected a method that does not contain parameters,
then the page will be blank, yet considered complete, with the Next button
enabled. Click Next. Note: When you produce an RPG Java method
call from ILE RPG, the ILE RPG code is mapped into Java code. For example, "char" in Java is
mapped to "1C" in ILE RPG. See the related reference topic
for more information on mapping between standard Java types and ILE RPG types. If the Java method
you selected is not static, then:
- Specify the Java constructor you want to use to construct
the Java object.
(This page, and the next one, do not appear if you previously selected a static
method, as no constructor is necessary.) Click Next.
- Specify parameters for the Java constructor selected. For each parameter,
you can generate an RPG field, specify the name, type, length, dimension,
and whether to pass the parameter by reference or to have a read-only reference.
Click Next.
- Specify the options for code generation. You can specify whether
or not to generate an RPG object for your Java class, whether or not to create a method
prototype, and where to place the generated RPG code.
- If you decide to generate an RPG object, you need to specify
an RPG name for the object and an RPG name for the object constructor.
- If you decide to generate an RPG method prototype, you need
to specify a prototype name.
- If you decide to generate a method call code, you need to specify
an RPG return field name.
- You have two choices for specifying where you want to place the
generated code:
- Distributed appropriately: to generate D-Specifications
in the D-Specification area of your code, and to generate calculations (the
code to call the method) after the cursor.
- All after current line: to generate and append the code
after the cursor.
- Click Finish.