IBM AS/400 manual Example of Module with, Multiple

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 60
Image 60
Example of Module with

Example of Module with Multiple

Procedures

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In order to format the

name

and

address

properly,

FmtCust

calls

NumToCha

 

convert

the

customer number

to

a

character

field.

Because

FmtCust

want

 

the return value, the call

to

NumToChar

is

made

in

an

expression.

Figure

 

page 36

shows

the

call.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*--------------------------------------------------------------

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

* CUSTNAME and CUSTNUM are formatted to look like this:

 

 

 

 

 

 

 

 

 

*

A&P Electronics

(Customer number 157)

 

 

 

 

 

 

 

 

 

 

 

*--------------------------------------------------------------

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

C

 

 

 

EVAL

Name = CUSTNAME + ' '

 

 

 

 

 

 

 

 

 

 

C

 

 

 

 

 

+ '(Customer number '

 

 

 

 

 

 

 

 

 

C

 

 

 

 

 

+ %trimr(NumToChr(CUSTNUM)) + ')'

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure

16. Calling the NumToChar Procedure

 

 

 

 

 

 

 

 

 

 

 

The use

of

procedures

to

return

values,

as

in

the

above

figure,

allo

 

any user-defined function you require. In addition,

the use of

a pr

 

face

opens

up

a

number

of

new

options

for

parameter passing.

 

 

¹Prototyped parameters can be passed in several ways: by reference

(for

procedures

only),

or

by read-only reference. The default meth

to pass by reference. However,

passing by value or by read-only

gives

you more

options

for

passing

parameters.

¹ If the prototype indicates that

it is allowed for a given parame

able

to do one

or more

of

the

following:

– Pass *OMIT

– Leave out a parameter entirely

Pass a shorter parameter than is specified (for character and parameters, and for array parameters)

Example of Module with

Multiple

Procedures

 

 

 

Now let us look at an example

of a multiple procedures module. In this

application' we are writing a

program ARRSRPT to produce a report of a

tomers

whose

accounts

are

in

arrears. We will create the basic repo

so that

it

can be

 

bound

to

other modules, if necessary. There are

that

are

required

for this

module:

1. Determine

that

a

record

of an account from a customer file is in

2. Format the data into a form that is suitable for the report.

We

have

decided

to

code

each task as a subprocedure. Conceptually,

will

look

something

like

that

shown in Figure 17 on page 37.

36 ILE RPG for AS/400 Programmer's Guide

Page 60
Image 60
IBM AS/400 manual Example of Module with, Multiple