IBM AS/400 manual Procedures, NumToC

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 62
Image 62

Example of Module with Multiple

Procedures

 

 

 

 

 

 

 

 

 

 

.1/

All subprocedures

begin

and

end

with

procedure specifications.

.2/

After

the Begin-Procedure specification (B in position 24 of

 

dure

specification),

you

code

a

procedure interface

definiti

 

value,

if any,

is

defined

on the

PI

specification.

Any parame

 

listed

after

the

PI

specification.

 

 

.3/ Any variables or prototypes that are used by the subprocedur defined after the procedure interface definition.

.4/

 

The return value, if specified, is returned to the caller wit

 

 

operation.

 

 

 

 

.5/

 

If the record is not in arrears, the subprocedure returns '

 

 

procedure.

 

 

 

 

For

all

subprocedures,

and also

for a main

procedure

with prototyped

eters,

you need to define a

procedure interfacedefinition.

A

is

a

repeat of the

prototype

information

within the

definition of a

used to define the entry parameters for the procedure. The procedu

definition is also used to ensure that the

internal definition

of

the

sistent

with

the external

definition

(the prototype).

In

the

case of

are

no

entry

parameters.

 

 

 

 

 

 

 

 

 

 

 

 

Consider next the subprocedure FmtCust, which

is

shown

in

Figure 19

on

 

page 39.

FmtCust is called by ARRSRPT

to format the relevant fields of

 

into

an

output record

for

the

final

report. (The record represents a

in arrears.)

FmtCust uses

global

data,

and so does not have any input

 

It formats the data into two output

fields:

one

for

the name, and

o

address.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

One

of

the

formatting

tasks

requires

converting

a

numeric

field

to

a

c

to match the output field type. This conversion could be coded as p

procedure

itself.

However, as this is

a task that

might

be required

we decided to code the conversion as a separate

subprocedure,

NumToC

NumToChar takes as

input

a numeric parameter that is

passed

by

value.

verts the

number

to a

character field

and returns

that field

to

the

FmtCust.

 

 

 

 

 

 

 

 

38 ILE RPG for AS/400 Programmer's Guide

Page 62
Image 62
IBM AS/400 manual Procedures, NumToC