Before you begin
You can create an RPG main procedure or subprocedure while editing
any RPGLE member in the Remote Systems LPEX editor. A procedure is any piece
of code that can be called with a bound call, in essence, the CALLP operation
code.
About this task
To create the procedure:
Procedure
- Expand your connection until you find the file in which you want
to create the RPG procedure.
- 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
> Procedure. Or, from the workbench menu, click Source > New > Procedure.
- In the RPG Procedure wizard, select the procedure type from the Procedure
type drop-down menu.
- Enter a valid ILE RPG name in the Procedure name field.
- In the External Name (EXTPROC) field, you can enter one
of the following:
- Program (EXTPGM)
- Main procedure (EXTPROC)
- Subprocedure (EXTPROC)
- Subprocedure with CLLE calling conventions (EXTPROC(*CL))
- Subprocedure with C calling conventions and parameter widening
(EXTPROC(*CWIDEN))
- Subprocedure with C calling conventions and no parameter widening
(EXTPROC(*CNOWIDEN))
- (Optional) Enter a descriptive purpose for the procedure. This
description will appear in the code's header comments.
- Select the Exportable for use with other code (EXPORT) check
box if this procedure is exportable for use with other code. Note, however,
that if you select this check box, the wizard places both the prototype and
procedure code into the current file. After you finish the wizard, you need
to manually move the prototype into a COPY file, so that procedures can call
this prototype. You also need to enter a COPY statement into the procedure
code, at the place where you removed the prototype code.
- Select the Generate free-form calculations check
box if you want the calculations section of your RPG procedure to be in free-form
code, rather than fixed-form. The rest of the generated source (D and P specifications)
will be fixed-form code. See Converting ILE RPG
code from fixed-form to free-form for more information.
- Click Add to add a parameter to your procedure. Complete
the dialog box to define the parameter and click OK.
- (Optional) Select the Return a value check box if you want
to define a Return value. This action enables the Next button. Otherwise,
click Finish.
What to do next
If you selected
Return a value:
- Click Next to go to the Return Value page of the RPG Procedure
wizard.
- If you do not need to specify the type and length of the value, you can
select the Defined like field and enter the name of
a field, data structure, or record format that you want to use as a model
for the returned value. If you want to specify all of this information yourself,
do not check the Return Value check box and see the
next step.
- Select a return value type from the Type drop-down list. The type
that you select automatically completes a number of the other fields in this
page of the wizard, and keeps some of the fields disabled if they are not
applicable for the type of value you selected. You can modify any of the values
in the enabled fields if you want. Make sure to check the F1 help in the various
fields of this wizard if you are not sure what to enter.
Note: If the type
you selected is date or time, the format label will be set to DATFMT (for
date) or TIMFMT (for time). Then you can select the format and separator
for your date or time label. If the type you selected is data, a Class
Entry field is enabled where you can specify a valid Java™ class.
- (Optional) Enter a description for the return value. This description
will appear in the code's header comments.
- Click Finish.