IBM AS/400 manual Example of an ILE RPG Program, Part 2 of 3. A Sample Payroll Calculation Program

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 35
Image 35
Figure 4 (Part 2 of 3). A Sample Payroll Calculation Program

Example of an ILE RPG Program

*

------------------------------------------------------------------------

 

 

 

 

 

 

 

 

*

* Constant Declarations

 

 

 

 

 

 

*

*

------------------------------------------------------------------------

 

 

 

 

 

 

 

 

*

D Heading1

 

 

C

 

'NUMBER

NAME

 

RATE

H-

D

 

 

 

 

 

OURS

BONUS

PAY

'

 

D Heading2

 

 

C

 

'______

________________

______

_-

D

 

 

 

 

 

____

_______

__________'

 

*

------------------------------------------------------------------------

 

 

 

 

 

 

 

 

*

* Prototype Definition for subprocedure CalcPay

 

 

*

*

------------------------------------------------------------------------

 

 

 

 

 

 

 

 

*

D CalcPay

 

 

PR

8P 2

 

 

 

 

 

 

D

Rate

 

 

 

5P 2 VALUE

 

 

 

 

 

D

Hours

 

 

 

10U 0 VALUE

 

 

 

 

 

D

Bonus

 

 

 

5P 2 VALUE

 

 

 

 

 

*

------------------------------------------------------------------------

 

 

 

 

 

 

 

 

*

* For each record in the transaction file (TRANSACT), if the ￿employee

*

* is found, compute the employee's pay and

print the details￿.

 

*

*

------------------------------------------------------------------------

 

 

 

 

 

 

 

 

*

C

TRN_NUMBER

CHAIN

EMP_REC

 

 

 

 

99

 

C

 

 

 

IF

NOT *IN99

 

 

 

 

 

C

 

 

 

EVAL

PAY = CalcPay(EMP_RATE : TRN_HOURS :

 

C

 

 

 

 

 

 

TRN_BONUS)

 

 

C

 

 

 

ENDIF

 

 

 

 

 

 

 

*

------------------------------------------------------------------------

 

 

 

 

 

 

 

 

*

* Report Layout

 

 

 

 

 

 

 

*

*

-- print the heading lines if 1P is on

 

 

 

 

*

*

-- if the record is found (indicator 99

is off) print the payro￿ll

*

*

details otherwise print an exception

record

 

 

*

*

-- print 'END OF LISTING' when LR is on

 

 

 

 

*

*

------------------------------------------------------------------------

 

 

 

 

 

 

 

 

*

OQSYSPRT

H

 

1P

 

2 3

 

 

 

 

 

O

 

 

 

 

 

 

35

'PAYROLL REGISTER'

 

O

 

 

 

*DATE

 

Y

60

 

 

 

 

O

 

H

 

1P

 

2

 

 

 

 

 

O

 

 

 

 

 

 

60

Heading1

 

 

O

 

H

 

1P

 

2

 

 

 

 

 

O

 

 

 

 

 

 

60

Heading2

 

 

O

 

D

N1PN99

 

2

 

 

 

 

 

O

 

 

 

TRN_NUMBER

 

5

 

 

 

 

O

 

 

 

EMP_NAME

 

24

 

 

 

 

O

 

 

 

EMP_RATE

L

33

 

 

 

 

O

 

 

 

TRN_HOURS

L

40

 

 

 

 

O

 

 

 

TRN_BONUS

L

49

 

 

 

 

O

 

 

 

Pay

 

 

60

'$

0. '

 

 

O

 

D

N1P 99

 

2

 

 

 

 

 

O

 

 

 

TRN_NUMBER

 

5

 

 

 

 

O

 

 

 

 

 

 

35

'** NOT ON EMPLOYEE FILE **'

O

 

T

 

LR

 

 

 

 

 

 

 

O

 

 

 

 

 

 

33

'END OF LISTING'

 

 

Figure 4 (Part 2 of 3). A Sample Payroll Calculation Program

Chapter 1. Overview of the RPG IV Programming11Language

Page 35
Image 35
IBM AS/400 manual Example of an ILE RPG Program, Part 2 of 3. A Sample Payroll Calculation Program