IBM AS/400 manual Methods for Processing Disk Files, Sequential-by-Key Processing, Example

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 319
Image 319
Sequential-by-Key Processing, Example 1

Methods for Processing Disk Files

as the ENUM field plus the WEEKNO (week number) field, which is a co key.

*****************************************************************

*

PROGRAM NAME:

YTDRPT1

 

 

*

* RELATED FILES:

EMPL1

(Logical

File)

*

*

 

PRINT

(Printer

File)

*

*

DESCRIPTION:

This program shows an example of processing

*

*

 

records using the

sequential-by-key method.

*

*

 

This program prints out each employee's

*

*

 

information and weekly hours worked.

*

*****************************************************************

FPRINT

O

F

80

PRINTER

FEMPL1

IP

E

 

K DISK

*A record-identifying indicator is assigned to each record￿; these

*record-identifying indicators are used to control proces￿sing for

*the different record types.

IEMPREC

01

I*

 

IRCWEEK

02

I*

 

*Since the EMPL1 file is read sequentially by key, for

*a valid employee number, the ENUM in a RCWEEK record

*must be the same as the ENUM in the last retrieved EMPREC

*record. This must be checked for and is done here by saving

*ENUMs of the EMPREC record into the field EMPNO and compar￿ing

*it with the ENUMs read from RCWEEK records.

*If the ENUM is a valid one, *IN12 will be seton. *IN12 is

*used to control the printing of the RCWEEK record.

C

 

 

SETOFF

 

 

 

12

C

01

 

MOVE

ENUM

EMPNO

5 0

C*

 

 

 

 

 

 

 

C

 

 

IF

(*IN02='1') AND (ENUM=EMPNO)

 

C

 

 

SETON

 

 

 

12

C

 

 

ENDIF

 

 

 

 

OPRINT

H

1P

2

6

 

 

O

 

 

 

 

40

'EMPLOYEE WEEKLY WORKING '

O

 

 

 

 

52

'HOURS REPORT'

 

O

 

H

01

1

 

 

 

O

 

 

 

 

12

'EMPLOYEE: '

 

O

 

 

ENAME

 

32

 

 

O

 

H

01

1

 

 

 

O

 

 

 

 

12

'SERIAL #: '

 

O

 

 

ENUM

 

17

 

 

O

 

 

 

 

27

'DEPT: '

 

O

 

 

EDEPT

 

30

 

 

O

 

 

 

 

40

'TYPE: '

 

O

 

 

ETYPE

 

41

 

 

O

 

H

01

1

 

 

 

O

 

 

 

 

20

'WEEK #'

 

O

 

 

 

 

50

'HOURS WORKED'

 

O

 

D

12

1

 

 

 

O

 

 

WEEKNO

 

18

 

 

O

 

 

EHWRK

3

45

 

 

 

 

 

 

Figure

147.

Sequential-by-Key Processing, Example 1

 

Chapter 16. Accessing Database 295Files

Page 319
Image 319
IBM AS/400 manual Methods for Processing Disk Files, Sequential-by-Key Processing, Example, Accessing Database 295Files