IBM AS/400 manual Creating an Application Using Multiple Procedures, Multiple Procedures Module

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 57
Image 57
Multiple Procedures Module

Multiple Procedures Module

Chapter 4. Creating an Application Using Multiple

Procedures

The ability to code more than one procedure in an ILE RPG module g enhances your ability to code a modular application. This chapter di and how you might use such a module in your application. Specifically presents:

¹ Overview of key concepts

¹ Example of module with more than one procedure

¹Coding considerations

 

Refer

to

the

end

of

this

section

to

see

where

to

look

 

for

more

 

 

on

coding

modules

with

 

multiple

procedures.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

Multiple Procedures

Module

 

Overview

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

An

ILE

program

 

consists

 

of

one

or

more

modules;

a

module

is

made

up

 

 

more proceduresprocedure. A

 

 

is any piece of code that can

be

called

 

 

bound call. ILE RPG has two kinds of procedures: a main

procedure

a

 

cedure.

The

way

to

call

a

subprocedure

is

with

a

prototyped

 

call.

 

Note:

In the RPG documentation, the term 'procedure' refers to both

 

 

 

 

subprocedures.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Main

Procedures and

Subprocedures

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

An ILE RPG module consists

of

a

main

procedure

and

zero

or

 

more

sub

 

dures.

 

(If

there

are

subprocedures,

the

main proceduremain -

 

 

is

optiona

 

dure

is

 

a

procedure

that can be specified as the program entry

 

 

receive

control

when

an

ILE

program

 

is

first

called). The

main

procedu

 

in

themain

 

source section

 

,

which

is

 

the

set

of

H,

F,

D,

I,

C,

 

and

O

s

 

that

begin

a

 

module.

In

V3R1,

all

ILE

RPG

modules had

a

 

main

proce

 

other

procedures.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A

subprocedure

 

 

is a procedure that is specified after the main sou

 

subprocedure

differs

 

from a

main

procedure

primarily

in

that:

 

 

 

¹Names that are defined within subprocedure are not accessible o subprocedure.

¹

No cycle

code is generated for the subprocedure.

¹

The

call

interface must

be

prototyped.

¹

Calls

to

subprocedures

must

be bound procedure calls.

¹Only P, D, and C specifications can be used.

Subprocedures can provide independence from other procedures because items are local. Local data items are normally stored in automatic st means that the value of a local variable is not preserved between cedure.

Copyright IBM Corp. 1994, 1999

33

Page 57
Image 57
IBM AS/400 manual Creating an Application Using Multiple Procedures, Multiple Procedures Module