Sei sulla pagina 1di 12

CA-Easytrieve Frequently Asked Questions

I need to search a string for a specific character, and if the character is found,
replace the found character with another character.
The following example program provides this logic:

***********************************************************************
* THIS IS AN EXAMPLE OF INSPECTING EVERY BYTE FOR A CHARACTER *
* AND REPLACING THAT CHARACTER WITH A NEW CHARACTER IN A NEW FIELD *
***********************************************************************
DEFINE FROM-FIELD W 15 A VALUE 'GOHN '
DEFINE FROM-FIELD-BYTE FROM-FIELD 1 A OCCURS 15
DEFINE FROM-SUB W 2 N
***********************************************************************
* THE TO-FIELD ARRAY USES INDEXING *
***********************************************************************
DEFINE TO-FIELD W 15 A
DEFINE TO-FIELD-BYTE TO-FIELD 1 A OCCURS 15 INDEX TO-INDEX
DEFINE FIND-FIELD W 1 A VALUE 'G'
DEFINE CHANGE-TO W 1 A VALUE 'J'
*
JOB INPUT NULL
MOVE ' ' TO TO-FIELD FILL ' '
FROM-SUB = 1
TO-INDEX = 0
*
DO UNTIL FROM-SUB EQ 16
IF FROM-FIELD-BYTE (FROM-SUB) = FIND-FIELD
TO-FIELD-BYTE (FROM-SUB) = CHANGE-TO
ELSE
TO-FIELD-BYTE = FROM-FIELD-BYTE (FROM-SUB)
END-IF
TO-INDEX = TO-INDEX + 1
FROM-SUB = FROM-SUB + 1
END-DO
*
DISPLAY 'RESULTS:'
DISPLAY ' '
DISPLAY '**********************************************************'
DISPLAY 'FROM-FIELD = ' FROM-FIELD
DISPLAY '*************000000000111111******************************'
DISPLAY ' 123456789012345******************************'
DISPLAY '**********************************************************'
DISPLAY 'TO-FIELD = ' TO-FIELD
DISPLAY '*************000000000111111******************************'
DISPLAY ' 123456789012345******************************'
DISPLAY '**********************************************************'
*
STOP
*
Running this program produces:

RESULTS:

**********************************************************
FROM-FIELD = GOHN
*************000000000111111******************************
123456789012345******************************
**********************************************************
TO-FIELD = JOHN
*************000000000111111******************************
123456789012345******************************
**********************************************************
How can I use EZT+ to get sub totals and a grand total on an amount field in a
report?

Choose one or more non-quantitative fields that you want sub-totaled. Code a SEQUENCE statement
followed by the field names of the fields you want sorted and totaled. Finally, code a CONTROL statement
followed by the fields you want totaled.

How does CA-Easytrieve Plus handle EBCDIC data format files? Does it translate
the files into ASCII and then generate reports? Does it need any other tool/utility for
the translation?

CA-Easytrieve Plus reads, writes, and updates standard IBM flat files, VSAM, DB2, DATACOM, IDMS,
SUPRA, and TOTAL files in EBCDIC format on the mainframe. It does the same for ASCII files under
UNIX including ORACLE, INGRES, OPENINGRES, DB2, IDMS, and SYBASE.

On the mainframe, CA-Easytrieve Plus handles EBCDIC files. On UNIX, it handles ASCII. To convert
from EBCDIC to ASCII or from ASCII to EBCDIC you need a specific CA product -- CA-
Easytrieve/Toolkit. This product includes many ready-to-use macros including CONVEA and CONVAE.
CONVEA and CONVAE convert EBCDIC to ASCII and ASCII to EBCDIC.

I receive the message: A004 CATASTROPHIC ERROR IN MODULE A140 04


136E. What would cause this error?

This is an indication that the EZTVFM file is out of space. Increase the EZTVFM space in the JCL. VFM
space can not span packs. If more space is needed you will need to use WORK files. Using report WORK
files means that spooling is done to the respective WORK file, not to the EZTVFM. For more information
about EZTVFM, see Chapter 3 of the CA-Easytrieve Plus Installation Guide, refer to topic "OS/390
Operating System". For information on how to setup WORK files, see Chapter 11 of the CA-Easytrieve
Plus Reference Guide, refer to topic "Report Work Files."
My CA-Easytrieve program is receiving an S0C7 abend. How do I find the
statement that caused an S0C7 data exception in CA-Easytrieve?

An S0C7 data exception occurs in CA-Easytrieve programs when non-numeric data is placed in a numeric
field. The following program contains a deliberate data exception:

1 PARM LINK(EZTEST10 R) DEBUG (STATE FLOW)


2 FILE PERSNL1 FB (150 1800)
3 NAME-LAST 17 8 A HEADING('LAST' 'NAME')
4 NAME-FIRST 25 8 A HEADING('FIRST' 'NAME')
5 PAY-GROSS 94 4 P 2 HEADING('GROSS' 'PAY')
6 *
7 WS-DATA-EXCEPTION W 5 A
8 WS-NUMBER WS-DATA-EXCEPTION 5 P 0
9 *
10 JOB INPUT PERSNL1
11 WS-DATA-EXCEPTION = ' '
12 WS-NUMBER = WS-NUMBER + 1
13 PRINT RPT1
14 REPORT RPT1 LINESIZE 80
15 TITLE 01 'EZTEST10 - CONTROL BREAK ON DEPT'
16 LINE 01 PERSNL1:NAME-FIRST +
PERSNL1:NAME-LAST +
PERSNL1:NAME-LAST +
PERSNL1:PAY-GROSS +
WS-NUMBER

WS-DATA-EXCEPTION is a 5-byte alphabetic field that is redefined by the packed numeric field WS-
NUMBER. WS-DATA-EXCEPTION is set to 5 hex ‘40’ blanks and then WS-NUMBER is computed by
adding 1. This is a classic formula for an S0C7 data exception. If this happened to be a very large program
with pages and pages of code you may need to review the following two methods to determine which
instruction caused the S0C7.

One method to discover the statement number and the statements that were executed prior to the S0C7 is to
include in the PARM statement, the sub-parameter DEBUG (STATE FLOW). STATE saves the statement
number of the statement currently being executed. The statement number is then printed in the associated
abnormal termination messages. FLOW activates a trace of the statements being executed. The statement
numbers are printed in the associated analysis report. STATE caused the following to print:
12 *******A006 PROGRAM INTERRUPT - CODE 7 (DATA EXCP)

This indicates that the error occurred at statement number 12 and that the error was an S0C7 data
exception.

FLOW caused the following to print:

FLOW TABLE - MAXIMUM ENTRIES 100

10 11 12

This indicates that statements 10, 11, and 12 were executed just prior to the S0C7.

If the program abends and the PARM does not include DEBUG (STATE FLOW) you can do the following:
Find the contents of register 3.
Add hex ‘4E’ to the contents of register 3.
The contents of register 3 plus hex ‘4E’ contains the statement number in hex.
Convert the statement number in hex to decimal to find the problem statement in the compiled output
listing.
Register 3 in the sample program dump is 7D80, as the following illustrates:

R0 0000000C R1 00000006 R2 00007C95 R3 00007D80


R8 00000000 R9 000069B0 R10 80015636 R11 00008D70

Add 7D80 to hex ‘4E’ and you get 7DCE. Go to hex 7DCE in the dump

00007DC0 00009A8E 00010000 00000000 0000000C

The value at 7DCE is hex C. Convert hex C to decimal and you get 12. Statement 12 is the statement
number that caused the S0C7 data exception.

What do you do if you receive the message, " B070 VALUE NOT WITHIN ACCEPTABLE RANGE -
LINESIZE", when using CA-Endevor to manage CA-Easytrieve programs?

If you check the CA-Easytrieve Plus Options Table, you will probably find that LINESIZE is set to the
expected value of 132. Also, if you check the CA-Easytrieve program you will probably find that the
LINESIZE is either not coded and thereby using the Options Table default of 132, or that LINESIZE is
coded with an acceptable number from 80 to 132.

If there does not seem to be a problem with the CA-Easytrieve Plus LINESIZE, try running the program
outside of CA-Endevor to see if the program runs without error. If the program returns the expected output,
then the problem is due to CA-Endevor's SYSPRINT record (which is overriding the LINESIZE). Talk to
your CA-Endevor administrator so that he or she may correct the SYSPRINT record.
Do you have any performance/tuning tips?

General Performance Considerations:

When accessing multiple files, put those files on different disk devices to avoid DASD arm contention.
Use the highest priority when running the job.
Do not run other programs that use the same resources at the same time.
Use maximum file buffering.
Use optimum blocking factors.
For VSAM files that are also read by an online system, specify share options 2 or 4.
Reorganize VSAM files so that they are not fragmented.
If accessing a small number of records from a large file, read them with keys instead of sequentially.
Use disk instead of tape whenever possible.
Do not use the DEBUG parameters of COBOL (when calling subroutines).
Break down huge datasets to smaller, logical datasets.
Increase REGION size.
CA-Easytrieve Plus Specific Considerations:
Execute link-edited programs instead of compile and go.
Produce multiple reports with a single pass of the dataset(s).
Send reports to individual disk datasets to reduce VFM disk contention.
Do not use the DEBUG parameters of CA-Easytrieve in production.
Use binary searches (tables) instead of multiple nested IF statements.
Use binary fields whenever possible to perform arithmetic operations. If a 4-byte binary field is not large
enough use an 8-byte packed field.
Use indexes instead of subscripts. If you must use a subscript define it as 2 bytes binary.
When comparing fields or doing any arithmetic operation use fields that have the same data type, length
and number of decimals.
FILE BUFFERING
The BUFNO parameter of the FILE statement establishes the number of input/output buffers allocated for
the file. The default in EZT+ is two. Since minimizing the number of physical I/O operations is essential to
maximizing performance, you should experiment with larger BUFNO values. Please note this value will
only affect the buffering for sequentially organized files, such as QSAM. VSAM file buffers should be
allocated in the JCL through the use of the AMP parameter or in the VSAM file definition.

SORTING
By default, the CA-Easytrieve Plus options table provides three dynamically allocated sortwork datasets. If
you would like to increase this number or turn off this option to use your own SORTWK datasets from
your JCL, use the WORK parameter on the PARM statement.

PARM WORK 0 this will turn off any dynamic allocation by EZT+

PARM WORK 5 this will dynamically allocate 5 sortwork datasets

To change the CA-Easytrieve Plus options table to eliminate the need to code the PARM, change the
NUMWORK parameter, for example:

NUMWORK=0 this means you must always have SORTWORK DDs in your JCL

NUMWORK=5 this means you will always have five dynamically allocated sortwork datasets provided
by CA-Easytrieve Plus. You will NOT use any of the SORTWORK DDs from the JCL.
Also, when implementing a SORT activity, you can use the BEFORE parameter to identify a procedure to
pre-screen input records. Adding a SELECT clause can cut down the number of records used by the CA-
Easytrieve Plus program.

VIRTUAL FILE MANAGER (VFM)


The VFMSPAC parameter in the options table (which may be overridden with the VFM parameter in the
PARM statement) could have an important role in determining execution time. EASYTRIEVE PLUS uses
its virtual file manager (VFM) to allocate the temporary data sets required during processing. Whenever a
programmer builds a temporary file within his program by specifying VIRTUAL in the FILE statement
VFM resources are used.

Additionally, EZT+ creates work files to hold report data whenever the SEQUENCE statement is specified
in the report, or if multiple reports are generated from the same program. VFM space is 40% of the total
region, or partition space for most EZT+ programs.

Should a program exhaust the region memory specified by the above parameters, it will satisfy any
additional requirements by acquiring DASD space via the EZTVFM dataset, specified in the JCL.
Typically the EZTVFM dataset is allocated in cylinders or work DASD. In an MVS environment, you may
specify UNIT=VIO on the EZTVFM DD statement instead of UNIT=DISK or UNIT=SYSDA. The use of
VIO is quicker than DASD and the space it utilizes is not part of the region in which the program is
running.

In the case of multiple reports in the same program with a high volume of VFM usage, use of the FILE
parameter of the REPORT statement is highly recommended. Since the EZTVFM data set used for the
overflow of VFM is limited to one pack, contention for the space can be high when multiple reports are
generated, causing performance degradation. The FILE parameter enables the programmer to specify
separate work datasets to be used instead of the VFM area reducing the EZTVFM contention.

When comparing fields or doing any arithmetic operation, use fields that have the same data type, length,
and number of decimals.
How can I print detail fields from the previous record at control break time?

Use SUMCTL DTLCOPYALL on the report statement. Included are two programs. Program #1 lists the
file in REGION BRANCH sequence. Program #2 lists the file in REGION BRANCH sequence and also
displays a detail field from the record just prior to the break.

PROGRAM #1

7/01/99 11.45.47 CA-EASYTRIEVE PLUS-6.2 9904


PAGE 1
COMPUTER ASSOCIATES INTL. -FIELD INSTALLATION
PROGRAMS AND ALL SUPPORTING MATERIALS COPYRIGHT (C) 1982, 1996
BY COMPUTER ASSOCIATES INTL. INC.
1 PARM LINK(EZTEST10 R) DEBUG (STATE FLOW)
2 FILE PERSNL1 FB (150 1800)
3 REGION 1 1 N
4 BRANCH 2 2 N
5 SSN 4 5 P MASK '999-99-9999' -
HEADING('SOCIAL' 'SECURITY' 'NUMBER')
6 EMP# 9 5 N HEADING('EMPLOYEE' 'NUMBER')
7 EMPNAME 17 16 A HEADING 'EMPLOYEE NAME'
8 NAME-LAST EMPNAME 8 A HEADING('LAST' 'NAME')
9 NAME-FIRST EMPNAME +8 8 A HEADING('FIRST' 'NAME')
10 ADDRESS 37 39 A
11 ADDR-STREET 37 20 A HEADING 'STREET'
12 ADDR-CITY 57 12 A HEADING 'CITY'
13 ADDR-STATE 69 2 A HEADING 'STATE'
14 ADDR-ZIP 71 5 N HEADING('ZIP' 'CODE')
15 PAY-NET 90 4 P 2 HEADING('NET' 'PAY')
16 PAY-GROSS 94 4 P 2 HEADING('GROSS' 'PAY'
17 DEPT 98 3 N
18 DATE-OF-BIRTH 103 6 N MASK( 'Z9/99/99') -
HEADING('DATE' 'OF' 'BIRTH')
19 TELEPHONE 117 10 N MASK '(999) 999-9999' -
HEADING('TELEPHONE' 'NUMBER')
20 SEX 127 1 N HEADING('SEX' 'CODE')
21 * 1 - FEMALE
22 * 2 - MALE
23 MARITAL-STAT 128 1 A HEADING('MARITAL' 'STATUS')
24 * M - MARRIED
25 * S - SINGLE
26 JOB-CATEGORY 132 2 N HEADING('JOB' 'CATEGORY')
27 SALARY-CODE 134 2 N HEADING('SALARY' 'CODE')
28 DATE-OF-HIRE 136 6 N MASK ( 'Z9/99/99') -
HEADING('DATE' 'OF' 'HIRE')
29 JOB INPUT PERSNL1
30 PRINT RPT1
31 REPORT RPT1 LINESIZE 80
32 SEQUENCE REGION BRANCH
33 TITLE 01 'EZTEST10 - SEQUENTIAL LIST REGION BRANCH NAME GROSS'
34 LINE 01 PERSNL1:REGION +
PERSNL1:BRANCH +
PERSNL1:NAME-LAST +
PERSNL1:PAY-GROSS
OPTIONS FOR THIS RUN -
ABEXIT SNAP DEBUG (FLOW FLOWSIZ 100 STATE FLDCHK NOXREF) LINK (EZTEST10 R)
LIST (PARM FILE) PRESIZE 512
SORT (DEVICE SYSDA ALTSEQ NO MSG DEFAULT MEMORY MAX WORK 3) VFM ( 64)
DFSMS/MVS V1 R4.0 BINDER 11:46:09 THURSDAY JULY 1, 1999
BATCH EMULATOR JOB(EZTEST1 ) STEP(LKED ) PGM= IEWL

7/01/99 EZTEST10 - SEQUENTIAL LIST REGION BRANCH NAME GROSS PAGE 1

LAST GROSS
REGION BRANCH NAME PAY
1 01 WIMN 373.60
1 01 BRANDOW 804.64
1 02 BERG 759.20
1 02 NAGLE 554.40
1 03 CORNING 146.16
1 03 MANHART 344.80
1 04 ARNOLD 445.50
1 04 LARSON 283.92
1 04 BYER 396.68
1 04 TALL 492.26
2 01 HUSS 360.80
2 02 KRUSE 242.40
2 02 POWELL 243.20
2 03 DENNING 135.85
2 03 FORREST 13.80
2 03 MCMAHON 386.40
2 03 PETRIK 220.80
2 04 POST 292.00
2 05 LOYAL 295.20
2 05 VETTER 279.36
3 01 KELLY 197.60
3 01 PHILPS 253.26
3 01 WEST 736.00
3 01 YOUNG 313.60
3 02 GRECO 1,004.00
3 02 ISAAC 313.60
3 02 LACH 310.40
3 02 REYNOLDS 174.15
3 02 SMOTH 315.20
3 02 THOMPSON 250.40
3 03 EPERT 310.40
3 03 MILLER 313.60
3 03 NORIDGE 324.00
3 03 OSMON 628.00
3 03 ROGERS 329.00
3 03 STRIDE 386.40
3 04 CROCI 376.00
3 04 GREEN 365.60
3 04 MALLOW 282.40
4 01 RYAN 399.20
4 01 TALUS 460.80
4 01 WARD 183.75
4 02 HAFER 121.95
4 02 JOHNSON 712.80
4 03 JONES 804.80
4 03 WALTERS 424.00
4 03 ZOLTAN 125.00
4 04 JUDAR 591.20
7/01/99 11.45.51 CA-EASYTRIEVE PLUS-6.2 9904 PAGE 1
COMPUTER ASSOCIATES INTL. -FIELD INSTALLATION
PROGRAMS AND ALL SUPPORTING MATERIALS COPYRIGHT (C) 1982, 1996
BY COMPUTER ASSOCIATES INTL. INC.
FILE STATISTICS - CA-EASYTRIEVE PLUS 6.2 9904- 7/01/99-11.45-JSN00029
PERSNL1 48 INPUT SAM FIX BLK 150 1800
EZTR001 48 INPUT VFM FIX BLK 15 N/A

PROGRAM #2

7/01/99 15.55.33 CA-EASYTRIEVE PLUS-6.2 9904


PAGE 1
COMPUTER ASSOCIATES INTL. -FIELD INSTALLATION
PROGRAMS AND ALL SUPPORTING MATERIALS COPYRIGHT (C) 1982, 1996
BY COMPUTER ASSOCIATES INTL. INC.
1 PARM LINK(EZTEST10 R) DEBUG (STATE FLOW)
2 FILE PERSNL1 FB (150 1800)
3 REGION 1 1 N
4 BRANCH 2 2 N
5 SSN 4 5 P MASK '999-99-9999' -
HEADING('SOCIAL' 'SECURITY' 'NUMBER')
6 EMP# 9 5 N HEADING('EMPLOYEE' 'NUMBER')
7 EMPNAME 17 16 A HEADING 'EMPLOYEE NAME'
8 NAME-LAST EMPNAME 8 A HEADING('LAST' 'NAME')
9 NAME-FIRST EMPNAME +8 8 A HEADING('FIRST' 'NAME')
10 ADDRESS 37 39 A
11 ADDR-STREET 37 20 A HEADING 'STREET'
12 ADDR-CITY 57 12 A HEADING 'CITY'
13 ADDR-STATE 69 2 A HEADING 'STATE'
14 ADDR-ZIP 71 5 N HEADING('ZIP' 'CODE')
15 PAY-NET 90 4 P 2 HEADING('NET' 'PAY')
16 PAY-GROSS 94 4 P 2 HEADING('GROSS' 'PAY')
17 DEPT 98 3 N
18 DATE-OF-BIRTH 103 6 N MASK( 'Z9/99/99') -
HEADING('DATE' 'OF' 'BIRTH')
19 TELEPHONE 117 10 N MASK '(999) 999-9999' -
HEADING('TELEPHONE' 'NUMBER')
20 SEX 127 1 N HEADING('SEX' 'CODE')
21 * 1 - FEMALE
22 * 2 - MALE
23 MARITAL-STAT 128 1 A HEADING('MARITAL' 'STATUS')
24 * M - MARRIED
25 * S - SINGLE
26 JOB-CATEGORY 132 2 N HEADING('JOB' 'CATEGORY')
27 SALARY-CODE 134 2 N HEADING('SALARY' 'CODE')
28 DATE-OF-HIRE 136 6 N MASK ( 'Z9/99/99') -
HEADING('DATE' 'OF' 'HIRE')
29 WS-NAME S 8 A
30 JOB INPUT PERSNL1
31 PRINT RPT1

32 REPORT RPT1 LINESIZE 80 SUMCTL DTLCOPYALL


33 SEQUENCE REGION BRANCH
34 CONTROL REGION BRANCH
35 TITLE 01 'EZTEST1 - PRINT PERSNL FILE'
36 LINE 01 REGION +
BRANCH +
NAME-LAST +
PAY-GROSS

OPTIONS FOR THIS RUN -


ABEXIT SNAP DEBUG (FLOW FLOWSIZ 100 STATE FLDCHK NOXREF) LINK (EZTEST10 R)
LIST (PARM FILE) PRESIZE 512
SORT (DEVICE SYSDA ALTSEQ NO MSG DEFAULT MEMORY MAX WORK 3) VFM ( 64)
DFSMS/MVS V1 R4.0 BINDER 15:55:54 THURSDAY JULY 1, 1999
BATCH EMULATOR JOB(EZTEST2 ) STEP(LKED ) PGM= IEWL

7/01/99 EZTEST1 - PRINT PERSNL FILE PAGE 1

LAST GROSS
REGION BRANCH NAME PAY
1 01 WIMN 373.60
BRANDOW 804.64
1 01 BRANDOW 1,178.24
1 02 BERG 759.20
NAGLE 554.40
1 02 NAGLE 1,313.60
1 03 CORNING 146.16
MANHART 344.80
1 03 MANHART 490.96
1 04 ARNOLD 445.50
LARSON 283.92
BYER 396.68
TALL 492.26
1 04 TALL 1,618.36
1 TALL 4,601.16
2 01 HUSS 360.80
2 01 HUSS 360.80
2 02 KRUSE 242.40
POWELL 243.20
2 02 POWELL 485.60
2 03 DENNING 135.85
FORREST 13.80
MCMAHON 386.40
PETRIK 220.80
2 03 PETRIK 756.85
2 04 POST 292.00
2 04 POST 292.00
2 05 LOYAL 295.20
VETTER 279.36
2 05 VETTER 574.56
2 VETTER 2,469.81
3 01 KELLY 197.60
PHILPS 253.26
WEST 736.00
YOUNG 313.60
3 01 YOUNG 1,500.46
3 02 GRECO 1,004.00
ISAAC 313.60
LACH 310.40

7/01/99 EZTEST1 - PRINT PERSNL FILE PAGE 2

LAST GROSS
REGION BRANCH NAME PAY
3 02 REYNOLDS 174.15
SMOTH 315.20
THOMPSON 250.40
3 02 THOMPSON 2,367.75
3 03 EPERT 310.40
MILLER 313.60
NORIDGE 324.00
OSMON 628.00
ROGERS 329.00
STRIDE 386.40
3 03 STRIDE 2,291.40
3 04 CROCI 376.00
GREEN 365.60
MALLOW 282.40
3 04 MALLOW 1,024.00
3 MALLOW 7,183.61
4 01 RYAN 399.20
TALUS 460.80
WARD 183.75
4 01 WARD 1,043.75
4 02 HAFER 121.95
JOHNSON 712.80
4 02 JOHNSON 834.75
4 03 JONES 804.80
WALTERS 424.00
ZOLTAN 125.00
4 03 ZOLTAN 1,353.80
4 04 JUDAR 591.20
4 04 JUDAR 591.20
4 JUDAR 3,823.50
JUDAR 18,078.08

7/01/99 15.55.35 CA-EASYTRIEVE PLUS-6.2 9904


PAGE 1
COMPUTER ASSOCIATES INTL. -FIELD INSTALLATION
PROGRAMS AND ALL SUPPORTING MATERIALS COPYRIGHT (C) 1982, 1996
BY COMPUTER ASSOCIATES INTL. INC.
FILE STATISTICS - CA-EASYTRIEVE PLUS 6.2 9904- 7/01/99-15.55-JSN00030
PERSNL1 48 INPUT SAM FIX BLK 150 800
EZTR001 48 INPUT VFM FIX BLK 15 N/A

As you can see, the size of each module increases quite a bit once the link job is run.
Is there a way to process all matching records, even if there are duplicates on the
most major file?
The following program shows a method to make CA-Easytrieve's Synchronized File Processing work in a
way beyond which it was designed. This program will process all matching records, even if there are
duplicates on the most major file (in this example, FILEA). This example ignores any records that do not
exist on both files, you may add additional logic to handle this situation, if necessary.

This code assumes FILEA is fixed and its record length is 150, FILEB is also fixed with a record length of
100. The array is built assuming that there will be no more than 10 duplicate key records that exist on
FILEB.

FILEA
FLDA 1 10 A .* key field used in sync processing
.
.

FILEB
RECB 1 100 A .* define entire record
FLDB 10 10 A .* key field used in sync processing
.
.

ENTIRE-ARRAY W 1000 A VALUE ' ' .* length times occurs equals this length
WSB-ARRAY ENTIRE-ARRAY 100 A OCCURS 10

SAVE-KEY W 10 A .* save the key of FILEA

WS-RECB W 100 A .* unload array into this area


.
. you may need to define all fields of FILEB here
.

ARRAY-CNT W 2 B 0 VALUE 0

ARRAY-SUB W 2 B 0 VALUE 0

JOB INPUT (FILEA KEY(FLDA) FILEB KEY (FLDB))

IF MATCHED
IF FIRST-DUP FILEA
ARRAY-CNT = ARRAY-CNT + 1
IF ARRAY-CNT GT 10
DISPLAY 'ARRAY OVERLOAD - CHANGE OCCURS AMOUNT'
STOP EXECUTE
END-IF
WSB-ARRAY (ARRAY-CNT) = RECB
END-IF
.
. other program logic
.
SAVE-KEY = FLDA
END-IF

IF NOT MATCHED AND FILEA AND FLDA = SAVE-KEY


ARRAY-SUB = 1
DO WHILE ARRAY-SUB LE ARRAY-CNT
WS-RECB = WSB-ARRAY (ARRAY-SUB)
.
. other program logic
.
ARRAY-SUB = ARRAY-SUB + 1
END-DO
IF LAST-DUP FILEA
MOVE SPACES TO ENTIRE-ARRAY
ARRAY-CNT = 0
END-IF
END-IF
.
.
.

NOTE: This is just a skeleton program. Additional code should be inserted as required. This example
ignores any unmatched records from either file, you could add code to handle this situation as well.

FILEA FILEB
A A
A A
B A
B

Normally, Synchronized File Processing would process the first FILEA key A against all of the FILEB key
A records and the second key A record from FILEA would be presented as NOT MATCHED. The above
code will read the first key A record from FILEA and the first Key A record from FILEB and present that
as a MATCH, it will then read FILEB record 2 and present that as a match with the first record from
FILEA. While this processing is going on, the FILEB records are being stored in the array. Once we read
the fourth record in FILEB and encounter an unmatched key we then read ahead in FILEA, since the key of
FILEA matches the SAVE-KEY we will process the second record from FILEA against the array of FILEB
records. Record two from FILEA is the last duplicate which causes the array to be emptied. Processing
continues to the next record in FILEA which now matches the current key of FILEB, another MATCH
condition.

Potrebbero piacerti anche