March 2012

Mainframe - Copy one file to another file with sorted order and summed up the column

Command :
SORT FIELDS=(starting position, length, format of the variable, ascending or descending.
SUM FIELDS=(starting position, length of the variable, format of the variable)
Example :
//DDName EXEC PGM=SORT
//SORTIN DD DSN=XXXXXXXXXXXXXXXXX,
// DISP=SHR
//SORTOUT DD DSN=XXXXXXXXXXXXXXXXXXXX,
// DISP=(NEW,CATLG,DELETE),
// UNIT=XXXXX,SPACE=(XXX,(XX,XX),XXXX),
// DCB=(*.SORTIN) Output file created using properties from input file.

Mainframe Copy one file to another file with sorted order and summed up the column and write values

Copy one file to another file with sorted order and summed up the column and write values based on format which you want
Command :
SORT FIELDS=(starting position, length, format of the variable, ascending or descending.
SUM FIELDS=(starting position, length of the variable, format of the variable)
OUTREC FIELDS= (starting position, length of the variable, starting position of field which you want to edited, length of the variable, format of the variable, EDIT=(TTTTTTT))
Example :

Total the column for signed byte fields by using easytrieve

//S030 EXEC PGM=EZTPA00
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//PANDD DD DSN=XXXXXXX.XXXX.XXXXXX,DISP=SHR
//FILEIN DD DISP=SHR,DSN=XXXXXXX.XXXX.XXXXXXXX.XXXXX
//FILEOUT DD DSN=XXXXXXX.XXXX.XXXX.XXXXXXXX.XXXXXX,
// DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(050,030),RLSE),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0),UNIT=XXXXX
//SYSIN DD *

FILE FILEIN FB(250 27750)
MLN-XXXX-XXXXXX 0001 0250 A
MLN-XXXXXXXXX-XX 0001 0002 A
MLN-XXXXXXX-XX 0003 0002 A
MLN-XXXXXXXX-XX 0005 0002 A
MLN-XXXXXXX-XXXXXX 0094 0008 A
MLN-XXXXX-XXXX-XXX 0110 0011 N 02
MLN-XXXX-XXXX-XX-XXXX 0121 0011 N 02
MLN-XXXXXXXXXX-XXX 0132 0015 N 06
MLN-XXXX-XXXXX-XX 0147 0005 N
MLN-XXXX-XXXX-XX 0152 0003 N
MLN-XXXXXC-XXXX 0197 0007 N

*
FILE FILEOUT FB(250 27750)
MXN-XXXX-XXXXXD 0001 0250 A
MXN-XXXXXXXXX-XX 0001 0002 A
MXN-XXXXXXX-XX 0003 0002 A
MXN-XXXXXXX-XXXXXX 0094 0008 A
MXN-XXXXX-XXXX-XXX 0110 0011 N 02
MXN-XXXX-XXXX-XX-XXXX 0121 0011 N 02
MAX-XXXXXXXXXX-XXX 0132 0015 N 06
MXN-XXXX-XXXXX-XX 0147 0005 N
MXN-XXXX-XXXX-XX 0152 0003 N
MXN-XXXXXX-XXXX 0197 0007 N

BYPASS-COUNT W 05 N
ZERO-COUNT W 05 N
OUT-COUNT W 05 N
IN-COUNT W 05 N

JOB INPUT FILEIN FINISH EXXXXX-TERMINATION-DISPLAY
IN-COUNT = IN-COUNT + 1

IF (MLN-XXXXXX-XXXX NOT NUMERIC)
BYPASS-COUNT = BYPASS-COUNT + 1
GOTO JOB
END-IF

IF (MLN-XXXXXX-XXXX = 0 )
ZERO-COUNT = ZERO-COUNT + 1
GOTO JOB
END-IF

PRINT REPORTA
FILEOUT:MXN-XXXX-XXXXXX = FILEIN:MLN-XXXX-XXXXXX
PUT FILEOUT
OUT-COUNT = OUT-COUNT + 1

*
*---- E N D M A I N L I N E ------------*
*
EXXXXX-TERMINATION-DISPLAY. PROC
DISPLAY NEWPAGE
DISPLAY '**** PROGRAM KEYMSTER STATISTIC ****'
DISPLAY 'INPUT XXX FILE = ' IN-COUNT
DISPLAY 'XXXX BYPASS NOT NUMERIC = ' BYPASS-COUNT
DISPLAY 'XXXX BYPASS ZERO = ' ZERO-COUNT
DISPLAY ' '
DISPLAY 'OUTPUT XXX FILE = ' OUT-COUNT
DISPLAY '**** PROGRAM XXXXXXXX STATISTIC ****'
IF IN-COUNT = 0
DISPLAY ' *********************************************'
DISPLAY ' * *'
DISPLAY ' * W A R N I N G F O R E M P T Y FILE *'
DISPLAY ' * *'
DISPLAY ' * XXXXXXX.XXXX.XXXX *'
DISPLAY ' * *'
DISPLAY ' *********************************************'
END-IF
END-PROC
NEWPAGE
*-----------------------------------------------*
* REPORTING SECTION *
*-----------------------------------------------*
REPORT REPORTA SPACE 1 NOADJUST PRINTER REPORT1 +
DTLCTL EVERY
CONTROL FILEIN:MLN-XXXXXX-XXXX

TITLE 1 COL 48 'TEST XXXXXXXXXX SYSTEM'
TITLE 2 COL 1 'XXXXXXXX' +
COL 48 ' XXXXXXXXX XXXXX REPORT ' +
COL 118 'TIME' COL 124 SYSTIME
TITLE 3 ' '

HEADING TALLY ('TOT' 'TRN')
HEADING FILEIN:MLN-XXXXXXX-XXXXXX ('XXXX' 'XXXXE')
HEADING FILEIN:MLN-XXXXX-XXXX-XXX ('GXXXS' 'AMXXXT')
HEADING FILEIN:MLN-XXXX-XXXX-XX-XXXX ('XXXX' 'XXX')
HEADING FILEIN:MLN-XXXXXXXXXX-XXX ('XXXM' 'XXXXXX')
HEADING FILEIN:MLN-XXXX-XXXXX-XX ('XXXXP' ' ')
HEADING FILEIN:MLN-XXXX-XXXX-XX ('PLN' ' ')
HEADING FILEIN:MLN-XXXXXX-XXXX ('PXXT' 'AXXT')
LINE 1 -
TALLY +
FILEIN:MLN-XXXXXXX-XXXXXX +
FILEIN:MLN-XXXXX-XXXX-XXX +
FILEIN:MLN-XXXX-XXXX-XX-XXXX +
FILEIN:MLN-XXXXXXXXXX-XXX +
FILEIN:MLN-XXXX-XXXXX-XX +
FILEIN:MLN-XXXX-XXXX-XX +
FILEIN:MLN-XXXXXX-XXXX
*

Total the column for signed byte fields and retrieve the value from IMS using easytrieve

//S030 EXEC PGM=EZTPA00
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//PANDD DD DSN=XXXXXXX.XXXX.XXXXXX,DISP=SHR
//FILEIN DD DISP=SHR,DSN=XXXXXXX.XXXX.XXXXXXXX.XXXXX
//FILEOUT DD DSN=XXXXXXX.XXXX.XXXX.XXXXXXXX.XXXXXX,
// DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(050,030),RLSE),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0),UNIT=XXXXX
//SYSIN DD *

FILE FILEIN FB(250 27750)
MLN-XXXX-XXXXXX 0001 0250 A
MLN-XXXXXXXXX-XX 0001 0002 A
MLN-XXXXXXX-XX 0003 0002 A
MLN-XXXXXXXX-XX 0005 0002 A
MLN-XXXXXXX-XXXXXX 0094 0008 A
MLN-XXXXX-XXXX-XXX 0110 0011 N 02
MLN-XXXX-XXXX-XX-XXXX 0121 0011 N 02
MLN-XXXXXXXXXX-XXX 0132 0015 N 06
MLN-XXXX-XXXXX-XX 0147 0005 N
MLN-XXXX-XXXX-XX 0152 0003 N
MLN-XXXXXC-XXXX 0197 0007 N

*
FILE FILEOUT FB(250 27750)
MXN-XXXX-XXXXXD 0001 0250 A
MXN-XXXXXXXXX-XX 0001 0002 A
MXN-XXXXXXX-XX 0003 0002 A
MXN-XXXXXXX-XXXXXX 0094 0008 A
MXN-XXXXX-XXXX-XXX 0110 0011 N 02
MXN-XXXX-XXXX-XX-XXXX 0121 0011 N 02
MAX-XXXXXXXXXX-XXX 0132 0015 N 06
MXN-XXXX-XXXXX-XX 0147 0005 N
MXN-XXXX-XXXX-XX 0152 0003 N
MXN-XXXXXX-XXXX 0197 0007 N

BYPASS-COUNT W 05 N
ZERO-COUNT W 05 N
OUT-COUNT W 05 N
XX-COUNT W 05 N
XX-GE-COUNT W 05 N
IN-COUNT W 05 N
XXXX-KEY W 07 A
XXXX-CO XXXX-KEY 2 N VALUE 54
XXXX-NO XXXX-KEY +2 4 P 0

JOB INPUT FILEIN FINISH EXXXXX-TERMINATION-DISPLAY
IN-COUNT = IN-COUNT + 1

IF (MLN-XXXXXX-XXXX NOT NUMERIC)
BYPASS-COUNT = BYPASS-COUNT + 1
GOTO 0XXX-CONTINUE
END-IF

IF (MLN-XXXXXX-XXXX = 0 )
ZERO-COUNT = ZERO-COUNT + 1
GOTO 0XXX-CONTINUE
END-IF

FUNCTION = 'GU '
SSA-XXXXXXXX-LPA = '('
XXXX-NO = MLN-XXXXXX-XXXX
SSA-XXXXXXXX-KEY = XXXX-KEY
PERFORM AXXXXX-XXTRACT-XX-ROOT

0XXX-CONTINUE

PRINT REPORTA
FILEOUT:MXN-XXXX-XXXXXX = FILEIN:MLN-XXXX-XXXXXX
PUT FILEOUT
OUT-COUNT = OUT-COUNT + 1

*
*---- E N D M A I N L I N E ------------*
*
NEWPAGE
AXXXXX-XXTRACT-XX-ROOT. PROC
SSA-COUNT = 1
DLI XXXXXXXX XXXXXXXX FUNCTION +
SSANO XXX-XXXXX +
SSA (SSA-XXXXXXXX)

IF DLI-XXXXXX-CODE ^= ' ', 'GE'
PERFORM EXXXXX-TERMINATION-DISPLAY
DISPLAY FUNCTION ' SEGMENT XXXXXXXX FAILED'
PERFORM XXXXXX-ABEND-EXIT
END-IF

IF DLI-STATUS-CODE = ' '
XX-COUNT = XX-COUNT + 1
FILEIN:MLN-XXXXXXX-XXXXXX = HV01SPA1:XXXXXXXX-XXXX-XXXXXX
FILEIN:MLN-XXXX-XXXXX-XX = HV01SPA1:XXXXXXXX-XXX-XX
FILEIN:MLN-XXXX-XXXX-XX = HV01SPA1:XXXXXXXX-XXXX-XX
ELSE
XX-GE-COUNT = XX-GE-COUNT + 1
DISPLAY 'XXXXXXX NOT FOUND IN DATABASE = ' MLN-XXXXXX-XXXX
END-IF

END-PROC
*
NEWPAGE
DXXXXX-ABEND-EXIT. PROC
DISPLAY '**** IMS STATUS CODE = ' DLI-STATUS-CODE
DISPLAY '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'
DISPLAY '@ A B E N D E D S T O P E X E C U T I O N !!! @'
DISPLAY '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'
STOP
END-PROC
*
EXXXXX-TERMINATION-DISPLAY. PROC
DISPLAY NEWPAGE
DISPLAY '**** PROGRAM XXXXXXXX STATISTIC ****'
DISPLAY 'INPUT XXX FILE = ' IN-COUNT
DISPLAY 'XXXX BYPASS NOT NUMERIC = ' BYPASS-COUNT
DISPLAY 'XXXX BYPASS ZERO = ' ZERO-COUNT
DISPLAY ' '
DISPLAY 'SEGMENT XX READ = ' XX-COUNT
DISPLAY 'SEGMENT XX GE = ' XX-GE-COUNT
DISPLAY 'OUTPUT XXX FILE = ' OUT-COUNT
DISPLAY '**** PROGRAM XXXXXXXX STATISTIC ****'
IF IN-COUNT = 0
DISPLAY ' *********************************************'
DISPLAY ' * *'
DISPLAY ' * W A R N I N G F O R E M P T Y FILE *'
DISPLAY ' * *'
DISPLAY ' * XXXXXXX.XXXX.XXXX *'
DISPLAY ' * *'
DISPLAY ' *********************************************'
END-IF
END-PROC
NEWPAGE
*-----------------------------------------------*
* REPORTING SECTION *
*-----------------------------------------------*
REPORT REPORTA SPACE 1 NOADJUST PRINTER REPORT1 +
DTLCTL EVERY
CONTROL FILEIN:MLN-XXXXXX-XXXX

TITLE 1 COL 48 'TEST XXXXXXXXXX SYSTEM'
TITLE 2 COL 1 'XXXXXXXX' +
COL 48 ' XXXXXXXXX XXXXX REPORT ' +
COL 118 'TIME' COL 124 SYSTIME
TITLE 3 ' '

HEADING TALLY ('TOT' 'TRN')
HEADING FILEIN:MLN-XXXXXXX-XXXXXX ('XXXX' 'XXXXE')
HEADING FILEIN:MLN-XXXXX-XXXX-XXX ('GXXXS' 'AMXXXT')
HEADING FILEIN:MLN-XXXX-XXXX-XX-XXXX ('XXXX' 'XXX')
HEADING FILEIN:MLN-XXXXXXXXXX-XXX ('XXXM' 'XXXXXX')
HEADING FILEIN:MLN-XXXX-XXXXX-XX ('XXXXP' ' ')
HEADING FILEIN:MLN-XXXX-XXXX-XX ('PLN' ' ')
HEADING FILEIN:MLN-XXXXXX-XXXX ('PXXT' 'AXXT')
LINE 1 -
TALLY +
FILEIN:MLN-XXXXXXX-XXXXXX +
FILEIN:MLN-XXXXX-XXXX-XXX +
FILEIN:MLN-XXXX-XXXX-XX-XXXX +
FILEIN:MLN-XXXXXXXXXX-XXX +
FILEIN:MLN-XXXX-XXXXX-XX +
FILEIN:MLN-XXXX-XXXX-XX +
FILEIN:MLN-XXXXXX-XXXX
*

Using easytrieve print the report with SYSTEM date

//S030 EXEC PGM=EZTPA00
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//PANDD DD DSN=XXXXXXX.XXXX.XXXXXX,DISP=SHR
//FILEIN DD DISP=SHR,DSN=XXXXXXX.XXXX.XXXXXXXX.XXXXX
//FILEOUT DD DSN=XXXXXXX.XXXX.XXXX.XXXXXXXX.XXXXXX,
// DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(050,030),RLSE),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0),UNIT=XXXXX
//SYSIN DD *

FILE FILEIN
MLN-XXXX-XXXXXX 0001 0080 A
MLN-XXXXXXXXX-XX 0001 0002 A
MLN-XXXXXXX-XX 0003 0002 A
MLN-XXXXXXXX-XX 0005 0002 A
MLN-XXXXXXX-XXXXXX 0006 0008 A
MLN-XXXXX-XXXX-XXX 0024 0011 N 02
MLN-XXXX-XXXX-XX-XXXX 0045 0007 N 02

*
FILE FILEOUT
MXN-XXXX-XXXXXD 0001 0080 A
MXN-XXXXXXXXX-XX 0001 0002 A
MXN-XXXXXXX-XX 0004 0002 A
MXN-XXXXXXX-XXXXXX 0007 0008 A
MXN-XXXXX-XXXX-XXX 0017 0011 N 02
MXN-XXXX-XXXX-XX-XXXX 0029 0007 N 02

JOB INPUT FILEIN

IF (MLN-XXXXXX-XXXX NOT NUMERIC)
GOTO JOB
END-IF

IF (MLN-XXXXXX-XXXX = 0 )
GOTO JOB
END-IF

PRINT REPORTA
FILEOUT:MXN-XXXX-XXXXXX = FILEIN:MLN-XXXX-XXXXXX
PUT FILEOUT

*
*---- E N D M A I N L I N E ------------*
*

NEWPAGE
*-----------------------------------------------*
* REPORTING SECTION *
*-----------------------------------------------*
REPORT REPORTA SPACE 1 NOADJUST PRINTER REPORT1 +
DTLCTL EVERY
CONTROL FILEIN:MLN-XXXXXX-XXXX

TITLE 1 COL 48 'TEST XXXXXXXXXX SYSTEM' SYSDATE
TITLE 2 COL 1 'XXXXXXXX' +
COL 48 ' XXXXXXXXX XXXXX REPORT ' +
COL 118 'TIME' COL 124 SYSTIME
TITLE 3 ' '

HEADING TALLY ('TOT' 'TRN')
HEADING FILEIN:MLN-XXXXXXX-XXXXXX ('XXXX' 'XXXXE')
HEADING FILEIN:MLN-XXXXX-XXXX-XXX ('GXXXS' 'AMXXXT')

LINE 1 -
TALLY +
FILEIN:MLN-XXXXXXX-XXXXXX +
FILEIN:MLN-XXXXX-XXXX-XXX +
FILEIN:MLN-XXXX-XXXX-XX-XXXX +
FILEIN:MLN-XXXXXXXXXX-XXX

*

Ezt / Easytrieve - Validate the field if that number or not then write into output file.

//XXXX EXEC PGM=XXXXXXX
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//PANDD DD DSN=XXXXXXX.XXXX.XXXXXXXX,DISP=SHR
//*
//FILEIN DD DISP=SHR,DSN=XXXXXXX.XXXXXXXX.XXX.XXXXXXXX
//FILEOUT DD DSN=XXXXXXX.XXXX.XXXXXXXX.XXX.XXXXXXX,
// DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(250,230),RLSE),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0),UNIT=XXXXX
//SYSIN DD *

FILE FILEIN
XXXXXX-XXXX-STR 01 2 N
XXXXXXXX-XXXXX-CODE 30 3 A
XXXXXXXX-XXXX-AMT 50 6 P 2
*
FILE FILEOUT
XXX-REC 01 80 A
XXX-XXXX-CODE 1 3 A
XXX-XXXX-AMT 5 12 N 2

JOB INPUT FILEIN
IF XXXXXXXX-XXXX-AMT NUMERIC
XXX-REC = ' '
XXX-XXXX-AMT = XXXXXXXX-XXXX-AMT
XXX-XXXX-CODE = XXXXXXXX-XXXXX-CODE
PUT FILEOUT
END-IF
*

Ezt - Validate the field if that number and greater than 0 or not then write into output file.

//XXXX EXEC PGM=XXXXXXX
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//PANDD DD DSN=XXXXXXX.XXXX.XXXXXXXX,DISP=SHR
//*
//FILEIN DD DISP=SHR,DSN=XXXXXXX.XXXXXXXX.XXX.XXXXXXXX
//FILEOUT DD DSN=XXXXXXX.XXXX.XXXXXXXX.XXX.XXXXXXX,
// DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(250,230),RLSE),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0),UNIT=XXXXX
//SYSIN DD *

FILE FILEIN
XXXXXX-XXXX-STR 01 2 N
XXXXXXXX-XXXXX-CODE 30 3 A
XXXXXXXX-XXXX-AMT 50 6 P 2
*
FILE FILEOUT
XXX-REC 01 80 A
XXX-XXXX-CODE 1 3 A
XXX-XXXX-AMT 5 12 N 2

WS-AMT W 7 N VALUE 0

JOB INPUT FILEIN
IF XXXXXXXX-XXXX-AMT NUMERIC AND +
XXXXXXXX-XXXX-AMT GT 1
WS-AMT = XXX-XXXX-AMT - 1
XXXXXXXX-XXXX-AMT = WS-AMT
XXX-REC = ' '
XXX-XXXX-CODE = XXXXXXXX-XXXXX-CODE
PUT FILEOUT
WS-AMT = 0
END-IF
IF XXXXXXXX-XXXX-AMT NUMERIC AND +
XXXXXXXX-XXXX-AMT LT 1
WS-AMT = XXX-XXXX-AMT + 1
IF WS-AMT LT 0
WS-AMT = WS-AMT * - 1
XXXXXXXX-XXXX-AMT = WS-AMT
XXX-REC = ' '
XXX-XXXX-CODE = XXXXXXXX-XXXXX-CODE
PUT FILEOUT
WS-AMT = 0
END-IF
*

Validate the field if that number and greater than 0 then subtract with 1 and write into output file. Validate the field if tha

//XXXX EXEC PGM=XXXXXXX
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//PANDD DD DSN=XXXXXXX.XXXX.XXXXXXXX,DISP=SHR
//*
//FILEIN DD DISP=SHR,DSN=XXXXXXX.XXXXXXXX.XXX.XXXXXXXX
//FILEOUT DD DSN=XXXXXXX.XXXX.XXXXXXXX.XXX.XXXXXXX,
// DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(250,230),RLSE),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0),UNIT=XXXXX
//SYSIN DD *

FILE FILEIN
XXXXXX-XXXX-STR 01 2 N
XXXXXXXX-XXXXX-CODE 30 3 A
XXXXXXXX-XXXX-AMT 50 6 P 2
*
FILE FILEOUT
XXX-REC 01 80 A
XXX-XXXX-CODE 1 3 A
XXX-XXXX-AMT 5 12 N 2

WS-AMT W 7 N VALUE 0

JOB INPUT FILEIN
IF XXXXXXXX-XXXX-AMT NUMERIC AND +
XXXXXXXX-XXXX-AMT GT 1
WS-AMT = XXX-XXXX-AMT - 1
XXXXXXXX-XXXX-AMT = WS-AMT
XXX-REC = ' '
XXX-XXXX-CODE = XXXXXXXX-XXXXX-CODE
PUT FILEOUT
WS-AMT = 0
END-IF
IF XXXXXXXX-XXXX-AMT NUMERIC AND +
XXXXXXXX-XXXX-AMT LT 1
WS-AMT = XXX-XXXX-AMT + 1
IF WS-AMT LT 0
WS-AMT = WS-AMT * - 1
XXXXXXXX-XXXX-AMT = WS-AMT
XXX-REC = ' '
XXX-XXXX-CODE = XXXXXXXX-XXXXX-CODE
PUT FILEOUT
WS-AMT = 0
END-IF
*

Validate the field if that number and greater than 0 then write into output file. Validate the field if that number and lesser t

//XXXX EXEC PGM=XXXXXXX
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//PANDD DD DSN=XXXXXXX.XXXX.XXXXXXXX,DISP=SHR
//*
//FILEIN DD DISP=SHR,DSN=xxxxxxx.xxxxxx.xxxxxxxx
//FILEOUT DD DSN=xxxxxxx.xxxx.xxxxxxxx.xxxxxxxx.xxxxx,
// DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(250,230),RLSE),
// DCB=(LRECL=20,RECFM=FB,BLKSIZE=0),UNIT=xxxxx
//SYSIN DD *

FILE FILEIN
IN-xxx 21 4 P 00
IN-cds 49 8 A
*
FILE FILEOUT
OUT-xxx 01 7 N 0

JOB INPUT FILEIN
IF IN-xxx NUMERIC AND +
IN-xxx GT 0
OUT-xxx = IN-xxx
PUT FILEOUT
END-IF
IF IN-xxx NUMERIC AND +
IN-xxx LT 0
GO TO JOB
END-IF
*

//XXXX EXEC PGM=XXXXXXX
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//PANDD DD DSN=XXXXXXX.XXXX.XXXXXXXX,DISP=SHR
//*
//FILEIN DD DISP=SHR,DSN=xxxxxxx.xxxx.xxxxxxxx
//FILEOUT DD DSN=xxxxxxx.xxxx.xxxx.xxxxxxxx.xxx,
// DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(250,230),RLSE),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0),UNIT=xxxxx
//SYSIN DD *

FILE FILEIN
xxREC 01 80 A
IN-xxx 01 2 N
IN-xecx 04 4 A
IN-xec1 10 2 N

*
FILE FILEOUT
xxxREC 001 80 A

JOB INPUT FILEIN
IF IN-xxx NUMERIC AND IN-xxx = 54
xxxREC = XXREC
PUT FILEOUT
END-IF
IF IN-xecx EQ ‘1112’
xxxREC = XXREC
PUT FILEOUT
END-IF
IF IN-xecx LT ‘0’
xxxREC = XXREC
PUT FILEOUT
END-IF
IF IN-xecx GE ‘0’
xxxREC = XXREC
PUT FILEOUT
END-IF
IF IN-xecx LE ‘0’
xxxREC = XXREC
PUT FILEOUT
END-IF
IF IN-xecx GE ‘0’ OR +
IN-xec1 LE 0
xxxREC = XXREC
PUT FILEOUT
END-IF
IF IN-xec1 NE 45
xxxREC = XXREC
PUT FILEOUT
END-IF

*

//XXXX EXEC PGM=XXXXXXX
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//PANDD DD DSN=XXXXXXX.XXXX.XXXXXXXX,DISP=SHR
//*
//EZTVFM DD UNIT=SYSDA,SPACE=(CYL,(50,10))
//SYSUDUMP DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//FILEIN DD DSN=XXXXXXX.XXX.XXXX.XXX,
// DISP=SHR
//COMXXX DD DSN=XXXXXXX.XXX.XXXX.XXX.V1,
// DISP=SHR
//FILEOUT DD DSN=XXXXXXX.XXX.XXXX.XXX.XXXXXX,
// DISP=(,CATLG,DELETE),
// UNIT=XXXXX,SPACE=(CYL,(1,5),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSIN DD *
*
FILE FILEOUT
XX-REC 1 80 A
XX-AXX 1 07 N
XX-AMT 9 10 N
*
FILE FILEIN
IN-REC 1 80 A
IN-AXX 6 07 N
IX-AMT 13 10 N

FILE COMXXX
CM-REC 1 80 A
CM-AXX 6 07 N
CX-AMT 13 10 N

*
WS-DESC W 7 N VALUE 0
WS-XXXX W 7 N VALUE 0
CNT W 7 N VALUE 0
TBL-CNT1 W 7 N VALUE 0
MAX-CNT W 7 N VALUE 0
PXX-CNT W 11 N VALUE 0
LOP-CNT W 5 N VALUE 0
INDEX1 W 5 N VALUE 0
*

WS-WORK-XXXXX W 17 A OCCURS 1000
TX-AXX WS-WORK-XXXXX 07 N
TX-AMT WS-WORK-XXXXX +07 10 N

JOB INPUT NULL

TBL-CNT1 = 0
DO UNTIL EOF FILEIN
GET FILEIN
IF EOF FILEIN
DISPLAY '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '
DISPLAY ' END OF FILEIN '
MOVE MAX-CNT TO TBL-CNT1
DISPLAY 'NUM OF ENTRIES LOADED = ' MAX-CNT
DISPLAY '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '
PERFORM MACTH-XXX-YTD
ELSE
TBL-CNT1 = TBL-CNT1 + 1
TX-AXX(TBL-CNT1) = IN-AXX
TX-AMT(TBL-CNT1) = IX-AMT
END-IF
END-DO

*******************************************
MACTH-XXX-YTD. PROC
*******************************************
DO UNTIL EOF COMIN
PXX-CNT = PXX-CNT + 1
LXX-CNT = LXX-CNT + 1
IF LXX-CNT >= 1000
DISPLAY ' PRXXXXXX >> ' PXX-CNT
LOP-CNT = 0
END-IF
GET COMIN
IF EOF COMIN
DISPLAY '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '
DISPLAY ' END OF COMXXX'
DISPLAY ' TOTAL COMXXX PROCESSED ' PXX-CNT
DISPLAY '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '
STOP
ELSE
PERFORM COMPARE-XXXXX
END-IF
END-DO
END-PROC.

*******************************************
COMPARE-XXXXX. PROC
*******************************************

INDEX1 = 1
DO WHILE INDEX1 <= MAX-CNT
IF CX-AXX = TX-AXX(INDEX1) AND +
CX-AMT = TX-AMT(INDEX1)
MOVE MAX-CNT TO INDEX1
ELSE
XX-AXX = CX-AXX
OX-AMT = CX-AMT
PUT FILEOUT
END-IF

INDEX1 = INDEX1 + 1
END-DO
END-PROC.
/*

If the input file and output file is Variable format then need to use Record length to write into output file.

//XXXX EXEC PGM=XXXXXXX
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//PANDD DD DSN=XXXXXXX.XXXX.XXXXXXXX,DISP=SHR
//*
//FILEIN DD DISP=SHR,DSN=xxxxxxx.xxxx.xxxxxxxx
//FILEOUT DD DSN=xxxxxxx.xxxx.xxxx.xxxxxxxx.xxx,
// DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(250,230),RLSE),
// DCB=(LRECL=854,RECFM=VB,BLKSIZE=0),UNIT=xxxxx
//SYSIN DD *

FILE FILEIN
IN-xxx 01 2 N
IN-xecx 04 4 A
IN-xec1 10 2 N

*
FILE FILEOUT
xxxREC 001 854 A

JOB INPUT FILEIN
IF IN-xxx NUMERIC AND IN-xxx = 54
FILEOUT:RECORD-LENGTH = FILEIN:RECORD-LENGTH
PUT FILEOUT
END-IF
*