View previous topic :: View next topic
|
Author |
Message |
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Hi,
I am using SYNCSORT.
I am trying to write a sort step that will do the following.
INPUT
Code: |
----+----1----+----2----+----3----+----4----+--
***************************** Top of Data *****
XXXXXXX TTTTTTTTTTT TTTTTTTT C5140097
XXXXXXX TTTTTTTTTTT TTTTTTTT C5140097
XXXXXXX QQ QQQ C51956
XXXXXXX QQ QQQ C51956
XXXXXXX QQ QQQ C51956
XXXXXXX QQ QQQ C51956
XXXXXXX BBBBB BBBBB BBBBBBB C547
XXXXXXX BBBBB BBBBB BBBBBBB C547
C547
XXXXXXX BBBBB BBBBB BBBBBBB C547
XXXXXXX BBBBB BBBBB BBBBBBB C547
C547
XXXXXXX BBBBB BBBBB BBBBBBB C547
C5475630047
C5475630047
XXXXXXX KKKKKKKKKK KKKK KKKK C5999957
XXXXXXX VVVV VVV VVVVVVVV-VVVV C5999987
XXXXXXX VVVV VVV VVVVVVVV-VVVV C5999987
|
OUTPUT
Code: |
----+----1----+----2----+----3----+----4----+--
***************************** Top of Data *****
XXXXXXX TTTTTTTTTTT TTTTTTTT C5140097
XXXXXXX QQ QQQ C51956
XXXXXXX KKKKKKKKKK KKKK KKKK C5999957
XXXXXXX VVVV VVV VVVVVVVV-VVVV C5999987
|
The logic is to consider entire record as key.
Output should not have duplicates.
And if any instance of a records has some fields missing then the entire key is NOT written to the output file. Like the below records were not written to output as they had some fields missing in an instance of that key.
Code: |
XXXXXXX BBBBB BBBBB BBBBBBB C547
C547
C5475630047
|
Can you please help me on this. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
The logic is to consider entire record as key. |
Quote: |
And if any instance of a records has some fields missing then the entire key is NOT written to the output file |
so is the key the entire record, or is the key at certain col positions? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Or are there really no rules at all. . .
You need to post what should happen in each case and why.
If you don't post the rules, this topic needs to be locked or completely deleted.
d |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Hi Dick,
Yes, The entire key is the record. In the above Input scenario...
Key -
Code: |
XXXXXXX TTTTTTTTTTT TTTTTTTT C5140097 |
was repeated 2 times so it was written to output record.
Case 2: -
Code: |
XXXXXXX BBBBB BBBBB BBBBBBB C547 |
was having 7 instances. But some instances were empty like
so this record was skipped from the output file. |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
similarly case 3:
Code: |
C5475630047
C5475630047 |
are both same but all the positions are not filled in the record so it was also skipped from the output file. There are 3 fields in the input file
1. --> Pos 1 to 8
2 --> Pos 9 to 33
3 --> Pos 34 to 47.
Please let me know incase more information is required. |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
similarly case 3:
Code: |
C5475630047
C5475630047 |
are both same but all the positions are not filled in the record so it was also skipped from the output file. There are 3 fields in the input file
1. --> Pos 1 to 8
2 --> Pos 9 to 33
3 --> Pos 34 to 47.
I hope this is clear now. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
gylbharat,
Will there be entire blank records?
Will your 3rd field(Pos 34 to 47) always have some value?
Is your input already sorted on any field?
Input RECFM/LRECL? |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Yes the file is sorted from 34 to 47. as shown in the input... And 3rd field will always have a value... RECFM = FB and input LRECL = 47. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
So, for the blank fields the data is "inherited" from the previous non-blanks, but, can actually be ignored because of the assumption that the data is "valid", ie there is always a complete key as the first one of a sequence, the other side being that a field with blanks is known to be duplicate so can be ignored.
However, what about the possibility that the file is not like that? That it should be, but it is not valid.
If the answer to one of Arun's questions, about entirely blank, is no, then you will have a key element to do the match, inherit non-blanks (for the matching only) and just do the usual processing. Any "dodgy" records will appear on the output, but for a genuine reason (file stuffed). |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
No... There will be no entirely blank records. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Here's a quick one which I think works for the OP's requirement. I'll have a look tomorrow if this could be fine tuned.
Code: |
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(34,14))),
IFTHEN=(WHEN=GROUP,BEGIN=(81,8,ZD,EQ,1),PUSH=(89:ID=8)),
IFTHEN=(WHEN=(1,8,CH,EQ,C' ',OR,9,25,CH,EQ,C' '),
OVERLAY=(81:C'00000000'))
SORT FIELDS=(89,8,CH,A,81,8,CH,A)
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(97:SEQNUM,8,ZD,RESTART=(34,14))),
IFTHEN=(WHEN=GROUP,BEGIN=(97,8,ZD,EQ,1),PUSH=(89:81,8)),
IFTHEN=(WHEN=(89,8,ZD,NE,0),
OVERLAY=(105:SEQNUM,8,ZD,RESTART=(1,47)))
OUTFIL BUILD=(1,47),INCLUDE=(105,8,ZD,EQ,1) |
SORTOUT
Code: |
XXXXXXX TTTTTTTTTTT TTTTTTTT C5140097
XXXXXXX QQ QQQ C51956
XXXXXXX KKKKKKKKKK KKKK KKKK C5999957
XXXXXXX VVVV VVV VVVVVVVV-VVVV C5999987 |
|
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Thanks Arun... This worked very well... |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
You're welcome |
|
Back to top |
|
|
|