View previous topic :: View next topic
Author
Message
vissubhai New User Joined: 07 Nov 2007Posts: 12 Location: Hyderabad
Hi All,
I have two input flat files of record length 625. Each file contain more than a million records. Each record contain two fields. The Record-Type which is of 1 byte and Data-Description which is of 624 bytes
Now I need to merge these two files based on the following criteria:
1. If record-type is 0, it is the file header. The output file should contain only one file header.
2. If record-type is 1, it is the merchant header. The output file should contain only one merchant header.
3.If the record-type is 2, it is the merchant data record. The output should the merged records from files 1 and 2.
4.If the record-type is 3, it is the merchant trailer record. The ouput file should only one merchant trailer by adding the counts present in the two files.
5.If record-type is 9, it is the file trailer. The output file should contain only one file trailer.
Let me provide you the sample inputs and output:
File1
0ABCDEFGHIJKLMN
1
2000123456789012
2000123456789013
2000123456789015
3123
9
File2
0ABCDEFGHIJK
1
2000123456789012
2000123456789013
2000123456789018
2000123456789019
3200
9
Output File
0ABCDEFGHIJKLMN
1
2000123456789012
2000123456789012
2000123456789013
2000123456789013
2000123456789015
2000123456789018
2000123456789019
3323
9
Guess I am clear with the requirements.
Viswanath.
Back to top
krisprems Active Member Joined: 27 Nov 2006Posts: 649 Location: India
You could use this SORT JCL if you dont need the records starting with 2 to be sorted as you have shown in your o/p/.
Code:
//*******************************************************
//STEP001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
0ABCDEFGHIJKLMN
1
2000123456789012
2000123456789013
2000123456789015
3123
9
0ABCDEFGHIJK
1
2000123456789012
2000123456789013
2000123456789018
2000123456789019
3200
9
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION EQUALS
OMIT COND=(1,1,ZD,EQ,9)
INREC IFTHEN=(WHEN=INIT,OVERLAY(81:SEQNUM,8,ZD,
90:3C'0')),
IFTHEN=(WHEN=(1,1,ZD,EQ,3),OVERLAY=(81:8X,90:2,3)),
IFTHEN=(WHEN=(1,1,ZD,LT,2),OVERLAY=(81:8X))
SORT FIELDS=(1,1,CH,A,81,8,CH,A)
SUM FIELDS=(90,3,ZD)
OUTREC IFTHEN=(WHEN=(1,1,ZD,EQ,3),OVERLAY=(2:90,3)),IFOUTLEN=80
OUTFIL REMOVECC,TRAILER2=(C'9')
/*
SORTOUT
Code:
0ABCDEFGHIJKLMN
1
2000123456789012
2000123456789013
2000123456789015
2000123456789012
2000123456789013
2000123456789018
2000123456789019
3323
9
If it is a must to have the records starting with 2 to be exactly as you have shown please confirm.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Viswanath,
Here's a DFSORT job that will do what you asked for:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file2 (FB/625)
//SYM DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=SYM,INCLUDE=(1,1,CH,EQ,C'3'),
BUILD=(C'T3_CT,+',2,3,80:X)
OUTFIL FNAMES=T2,INCLUDE=(1,1,CH,EQ,C'2')
/*
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN01 DD DSN=... input file1 (FB/625)
//SORTIN02 DD DSN=&&T2,DISP=(OLD,PASS)
//SORTOUT DD DSN=.. output file (FB/625)
//SYSIN DD *
OPTION EQUALS
MERGE FIELDS=(1,625,CH,A)
OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,C'3'),
OVERLAY=(2:2,3,ZD,ADD,T3_CT,EDIT=(TTT)))
/*
The SORTOUT data set for step S2 would have:
Code:
0ABCDEFGHIJKLMN
1
2000123456789012
2000123456789012
2000123456789013
2000123456789013
2000123456789015
2000123456789018
2000123456789019
3323
9
Back to top
vissubhai New User Joined: 07 Nov 2007Posts: 12 Location: Hyderabad
Thanks krisprems and Frank. Your information is very valuable.
Frank,
I am getting the following syntax error while running your job.
WER268A OUTREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
The syntax error is at the ADD,T3_CT in the OUTREC statement.
I guess the above job does not work for syncsort.
Back to top
murmohk1 Senior Member Joined: 29 Jun 2006Posts: 1436 Location: Bangalore,India
vissubhai,
The solution suggested by Frank is a DFSORT one and your shop has SYNCSORT.
Back to top
krisprems Active Member Joined: 27 Nov 2006Posts: 649 Location: India
vissubhai,
Can you provide the complete SYSOUT information?
Back to top
Alissa Margulies SYNCSORT Support Joined: 25 Jul 2007Posts: 496 Location: USA
Viswanath,
Frank's solution should work if you are running SyncSort for z/OS 1.2.1.0 or later.
If you would like further assistance, please post the complete SyncSort message output.
Back to top
Please enable JavaScript!