View previous topic :: View next topic
|
Author |
Message |
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Hi All,
I have the following requirement
I have five datasets all having RECFM=FB and LRECL=213.
File has error description at first 30 bytes and rest of it is data.
ex
File1
Code: |
Error1 Record1
Record2
Record3
Record4
Error2 Record1
Record2 |
File2
Code: |
Error1 Record5
Record6
Record7
Record8
Error2 Record7
Record9 |
Output
Code: |
Error1 Record1
Record2
Record3
Record4
Record5
Record6
Record7
Record8
Error2 Record1
Record2
Record7
Record9 |
There can be any number of errors.If any record is present in file 1 it will not be in file-2.
Can we do this using sort?
Thanks. |
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
All the records start at 32nd position. |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
rgupta71, a merge requires that all of the input datasets are already sorted in ascending order on the merging key, i.e. in your case the first 30 bytes. Then, the MERGE command combines all of the records based on that key. I have a suspicion that a MERGE is not what you're looking for here. |
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
We can sort it based on error.It is not a problem. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
We can sort it based on error.It is not a problem. |
If you can sort it on error, you can merge it. . .
You need to use the "Code" tag when posting. All you need is copy/paste frm the terminal and "Code" the info in the reply editor. Do not add spaces as this mis-aligns your data. |
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
If I sort the data all the records which have blank in the first 30 byte will come at end.
How I will I determine that which record was for which error? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
If I sort the data all the records which have blank in the first 30 byte will come at end. |
The blanks will be first not last - this is not a pc. . .
You said it was no problem and that you could sort it based on error. . .
A process is needed that propogates the "error" value to the uncoded records in both files, then merge these suppressing the error code in records 2 thru n for each output group.
What should happen if either/both iput files contain duplicates? |
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Same error can be present in both the files but every record field will be only in one file. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
If I understand what you're trying to do (and I'm not sure I do), here's a DFSORT job that will do it.
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/213)
//IN2 DD DSN=... input file2 (FB/213)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=... output file (FB/213)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'Error'),
PUSH=(214:1,30))
/*
//CTL2CNTL DD *
OPTION EQUALS
SORT FIELDS=(214,30,CH,A)
OUTREC IFOUTLEN=213,
IFTHEN=(WHEN=GROUP,KEYBEGIN=(214,30),PUSH=(214:SEQ=8)),
IFTHEN=(WHEN=(214,8,ZD,NE,1),OVERLAY=(1:30X))
/*
|
|
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Hi Frank,
It is giving error
Code: |
OPTION EQUALS
SORT FIELDS=(214,30,CH,A)
OUTREC IFOUTLEN=213,
IFTHEN=(WHEN=GROUP,KEYBEGIN=(214,30),PUSH=(214:SEQ=8)),
$
OPERAND DEFINER ERROR
IFTHEN=(WHEN=(214,8,ZD,NE,1),OVERLAY=(1:30X))
$ |
|
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
rgupta71,
Looks like you don't have PTF H which supports keybegin keyword. Change the OUTREC statements to the following
Code: |
OUTREC IFOUTLEN=213,
IFTHEN=(WHEN=INIT,OVERLAY=(244:SEQNUM,8,ZD,RESTART=(214,30))),
IFTHEN=(WHEN=(244,8,ZD,NE,1),OVERLAY=(1:30X))
|
|
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
It worked.
My input files also has header of 5 rows .Can we handle that by modifying the same sort or I should delete the data before using this sort?
Thank you all for your support. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Sigh. That depends on which input file has the header rows and what they look like. Give details and show an example.
It would have saved time if you had described your requirement completely in the first place. |
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Sorry Frank .
Both the input files have header of 5 rows. The example is same as above the only difference is that it has header of 5 rows. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
If you need to remove the first 5 records from each input file, change CTL1CNTL to:
Code: |
//CTL1CNTL DD *
OPTION SKIPREC=5
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'Error'),
PUSH=(214:1,30))
/*
|
|
|
Back to top |
|
|
|