View previous topic :: View next topic
Author
Message
thunderstorm New User Joined: 23 Mar 2007Posts: 35 Location: pune
Hi,
I have a requirement where i need to concatenate data from 2 or more input files and then have a single header record and have maximum date present in the header.
Important points
1. The header is present in the first record of the file
2. The date field is present in posn 23 and has the date format as YYYY-MM-DD
3. The total number of records within the file including the header record is present in the location 40 and is 5 bytes long
4. The record length of both the input files are 50 and FB
Code:
Input file 1
----+----1----+----2----+----3----+----4----+----5
ROSWELL NM2030512010-02-04 000013
11111111111111 101120
11111111111111 102000
11111111111111 104000
11111111111111 201090
22222222222222 301042
22222222222222 101310
22222222222222 102000
22222222222222 104000
22222222222222 102000
22222222222222 104000
22222222222222 201089
22222222222222 301089
Input File 2
----+----1----+----2----+----3----+----4----+----5
ROSWELL NM2030512010-02-02 000009
44444444444444 101120
44444444444444 102000
44444444444444 104000
44444444444444 201090
33333333333333 301042
33333333333333 101310
33333333333333 102000
33333333333333 104000
Output file
----+----1----+----2----+----3----+----4----+----5
ROSWELL NM2030512010-02-04 000021
11111111111111 101120
11111111111111 102000
11111111111111 104000
11111111111111 201090
22222222222222 301042
22222222222222 101310
22222222222222 102000
22222222222222 104000
22222222222222 102000
22222222222222 104000
22222222222222 201089
22222222222222 301089
44444444444444 101120
44444444444444 102000
44444444444444 104000
44444444444444 201090
33333333333333 301042
33333333333333 101310
33333333333333 102000
33333333333333 104000
Any help would be great
Back to top
Escapa Senior Member Joined: 16 Feb 2007Posts: 1399 Location: IL, USA
Does "ROSWELL" identifies Header record?
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello,
No (at least i don't believe so).
Being the first record identifies the header.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
ts,
A better question - is there anything in the header record that identifies it (e.g. non-blank in position 15, or non-blank in position 40, or ?)?
Quote:
i need to concatenate data from 2 or more input files
What is the maximum number of input files you would have?
Are you looking for a general solution that does NOT require any changes for different numbers of files? Or can you change the job depending on the number of files?
Back to top
thunderstorm New User Joined: 23 Mar 2007Posts: 35 Location: pune
Hi Frank,
The header portion till posn 22 is always constant.
ROSWELL NM203051
We can have a maximum of 3 files and that might increase as well.
So , to answer your question i am expecting a general solution that does not require any changes for any number of files.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Ok, first a couple of corrections:
For the output, you show the count as 21, but it should be 22 (13+9) ... right?
You say the count is 5 bytes long, but you show it in 40-45 which is 6 bytes.
Here's a DFSORT/ICETOOL job that will do what you asked for:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=... input file1 (FB/50)
// DD DSN=... input file2 (FB/50)
// ...
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=... output file (FB/50)
//TOOLIN DD *
SORT FROM(CON) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(51:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,7,CH,EQ,C'ROSWELL'),OVERLAY=(51:8C'0'))
SORT FIELDS=(51,8,ZD,A,23,10,CH,D)
/*
//CTL2CNTL DD *
OPTION EQUALS
SORT FIELDS=(51,8,ZD,A)
SUM FIELDS=(40,6,ZD)
OUTREC BUILD=(1,50)
/*
Back to top
thunderstorm New User Joined: 23 Mar 2007Posts: 35 Location: pune
Yes Frank , it was a calculation error on my part.
I ran the job but in the count section i am getting
000000002B instead of 0000000022
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
ts,
You could be using DFSORT with ZDPRINT=NO in effect.
Try changing the OPTION statement in CTL2CNTL to:
Code:
OPTION EQUALS,ZDPRINT
Back to top
thunderstorm New User Joined: 23 Mar 2007Posts: 35 Location: pune
Thanks frank ..it worked
Back to top
thunderstorm New User Joined: 23 Mar 2007Posts: 35 Location: pune
Frank - I take back my words..The header count should be 21 and not 22 because in the final file i want only 1 header with the correct count.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Ok, then use this DFSORT/ICETOOL job:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=... input file1 (FB/50)
// DD DSN=... input file2 (FB/50)
// ...
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=... output file (FB/50)
//TOOLIN DD *
SORT FROM(CON) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(51:SEQNUM,8,ZD,59:8C'0')),
IFTHEN=(WHEN=(1,7,CH,EQ,C'ROSWELL'),
OVERLAY=(51:8C'0',59:C'00000001'))
SORT FIELDS=(51,8,ZD,A,23,10,CH,D)
/*
//CTL2CNTL DD *
OPTION EQUALS
SORT FIELDS=(51,8,ZD,A)
SUM FIELDS=(40,6,ZD,59,8,ZD)
OUTREC IFOUTLEN=50,
IFTHEN=(WHEN=(1,7,CH,EQ,C'ROSWELL'),
OVERLAY=(40:40,6,ZD,SUB,59,8,ZD,ADD,+1,TO=ZD,LENGTH=6))
/*
Back to top
thunderstorm New User Joined: 23 Mar 2007Posts: 35 Location: pune
Thanks Frank..This is perfect
Back to top
Please enable JavaScript!