IBM AS/400 manual Example of Module with Multiple Procedures

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 61
Image 61
Example of Module with Multiple Procedures

Example of Module with Multiple Procedures

Manual background ARRSRPT MODULE

Manual background Main Procedure

Open file, read record, write output records, close files

Manual background InArrears

Subprocedure to determine if customer record is in arrears

Manual background FmtCust

Subprocedure to format customer data into report form

Figure 17. Components of the ARRSRPT Module

Now consider the first subprocedure, InArrears, which is shown in Fig InArrears is called by the main procedure to determine if the cur arrears.

 

TIP

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

When

coding

subprocedures

that

use

global fields, you may

want

to

naming convention that shows the

item to be global. In this

example,

case

 

field

names

indicate

DDS

fields. Another option would

be to p

some

other

string

to indicate

global

scope.

 

 

 

 

 

 

 

 

 

 

If the

record is

in

arrears,

the

subprocedure returns '1' to

the

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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

 

 

 

 

 

 

*

 

 

 

 

* InArrears

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

 

 

* Parameters: (none)

 

 

 

 

 

 

 

 

* Globals: DUEDATE, AMOUNT, CurDate

 

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

 

 

* Returns: '1' if the customer is in arrears

 

 

 

 

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

 

 

 

 

 

 

*

 

 

 

P InArrears

B

 

 

 

.1/

 

 

 

D InArrears

PI

 

 

1A

.2/

 

 

 

 

 

* Local declarations

 

 

 

 

 

 

 

D DaysLate

S

 

 

10I 0

.3/

 

 

 

 

D DateDue

S

 

 

D

.3/

 

 

 

 

 

* Body of procedure

 

 

 

 

 

 

 

 

C

 

 

*ISO

 

MOVE

DUEDATE

DateDue

 

 

 

C

 

 

CurDate

SUBDUR

DateDue

DaysLate:*D

 

 

 

C

 

 

 

 

IF

DaysLate > 60 AND

 

 

 

C

 

 

 

 

 

AMOUNT > 100.00

 

 

 

 

C

 

 

 

 

RETURN

'1'

.4/

 

 

 

 

C

 

 

 

 

ELSE

 

 

 

 

 

 

 

C

 

 

 

 

RETURN

'0'

.4/ .5/

 

 

 

C

 

 

 

 

ENDIF

 

 

 

 

 

 

 

P InArrears

E

 

 

 

.1/

 

 

 

 

 

 

 

 

Figure

18.

Source for Subprocedure InArrears

 

 

 

Figure 18 shows the main elements that are common to all subprocedures

Chapter 4. Creating an Application Using Multiple37 Procedures

Page 61
Image 61
IBM AS/400 manual Example of Module with Multiple Procedures