How to join records in Easytrieve internal SORT?

800 views Asked by At

I've a requirement, where I need to extract 2 types of records from a single input file & join them for EZT report processing. Currently, I've written an ICETOOL step to perform the extraction followed by the join. The output of the ICETOOL step is fed to the Easytrieve report step. Extraction card is as below -

SORT    FIELDS=(14,07,PD,A)
OUTFILE FNAMES=FILE010,INCLUDE=(25,03,CH,EQ,C'010')
OUTFILE FNAMES=FILE011,INCLUDE=(25,04,CH,EQ,C'011')
OPTION  DYNALLOC=(SYSDA,05)

Here is the join card -

SORT     FIELDS=(14,07,PD,A)
JOINKEYS F1=FILE010,FIELDS=(14,07,A),SORTED,NOSEQCHK
JOINKEYS F2=FILE011,FIELDS=(14,07,A),SORTED,NOSEQCHK
REFORMAT FIELDS=(F1:14,07,
                 F2,25,10)
OUTREC   BUILD=(1,17,80:X),VTOF
OPTION   DYNALLOC=(SYSDA,05)

I'm wondering if it was possible to perform the above SORT/ICETOOL operations within EasyTrive. I've used the Easytrieve internal SORT but it was for the simple extractions. Can we perform the join operation within the Easytrieve?

Note - The idea is to have a single EZT step.

1

There are 1 answers

1
Srinivasan JV On

You can make use Synchronized File Processing facility (SFP) in Easytrieve to acheive the task. Read more about it here.

FILE FILE010
KEY1 14 7 N
*
FILE FILE011
KEY2 14 7 N
FIELD1 25 10 A
*
FILE OUTFILE FB(80 0)
OKEY 1 7 N
OFIELD 8 10 A
*
WS-COUNT W 5 N VALUE 0
*
JOB INPUT FILE010 KEY KEY1 FILE011 KEY KEY2 FINISH(DIS)
*
IF EOF FILE010
STOP
END-IF
*
IF MATCHED
OKEY = KEY1
OFIELD = FIELD1
WS-COUNT = WS-COUNT + 1
PUT OUTFILE
END-IF
*
DIS. PROC
DISPLAY 'RECORDS WRITTEN: ' WS-COUNT
END-PROC

Please note,

  • Above code isn't tested, it's just a draft showing the idea on file matching using Easytrieve to achieve the task.
  • Data types to the data items are assumed. You may have to change them suitably.
  • You may have to define the variable input datasets in the FILE statement.
  • You may add more statements within the IF MATCHED condition for the creation of report.

Hope this helps!