View previous topic :: View next topic
|
Author |
Message |
ramas.kamal
New User
Joined: 03 Mar 2014 Posts: 22 Location: India
|
|
|
|
Hi,
Can you please help me to address this issue? I would like to do a check on a file that has several records. If the difference between each record in a set should be only 1 then write MAX number of it to output file. The first 6 characters of a set forms the key. If comparison is greater than 1 then write wrong set to error file.
Input:
Code: |
----+----1----+----2
JUPITER0103
JUPITER0104
JUPITER0105
SELVIAS0090
SELVIAS0091
SELVIAS0093
GORAPAK1291
SHYAMAL0008
SHYAMAL0009
|
Expected Output:
Code: |
----+----1----+----2
JUPITER0105
GORAPAK1291
SHYAMAL0009
|
Please help.
Thank you. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Why is SELVIAS0093 not in your output dataset - it is more than one different from the previous two entries? Why is GORAPAK1291 in your output dataset - you have nothing to compare it to so it cannot be more than one different?
Usual requirements: LRECL & RECFM of input/output. |
|
Back to top |
|
|
ramas.kamal
New User
Joined: 03 Mar 2014 Posts: 22 Location: India
|
|
|
|
Nic, thanks for your inputs.
LRECL = 80, RECFM=FB
My bad, actual expected output should be like this -
Code: |
----+----1----+----2
JUPITER0105
SELVIAS0091
SHYAMAL0009
|
The "SELVIAS0093" should go to error output because of more than 1 difference.
Thanks. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Add a sequence number with RESTART= for your key.
Define a GROUP for the sequence being one, which PUSHes your number and a SEQ.
OUTFIL OMIT= where current sequence not equal to sequence from start of group plus SEQ.
REMOVECC,NODETAIL,SECTIONS and TRAILER3 to output only the final record of each group. |
|
Back to top |
|
|
ramas.kamal
New User
Joined: 03 Mar 2014 Posts: 22 Location: India
|
|
|
|
Bill, thanks. I will try to work out this idea and come back. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Nic wrote: |
Why is GORAPAK1291 in your output dataset - you have nothing to compare it to so it cannot be more than one different? |
ramas.kamal,
Can you please respond to the above question?
ramas.kamal wrote: |
The first 6 characters of a set forms the key |
Looks like the key is of 7 bytes. was this a typo?
Code: |
SELVIAS0090
SELVIAS0091
SELVIAS0093
SELVIAS0094
SELVIAS0095
SELVIAS0097 |
What would be the expected output for this input if at all this is a possible scenario? |
|
Back to top |
|
|
ramas.kamal
New User
Joined: 03 Mar 2014 Posts: 22 Location: India
|
|
|
|
Arun, yes, that was typo. Key length is 7 characters.
Quote: |
Why is GORAPAK1291 in your output dataset - you have nothing to compare it to so it cannot be more than one different?
|
"GORAPAK1291" cannot be in ouput because its single record. It was my mistake for which I gave below reply -
Quote: |
My bad, actual expected output should be like this -
Code:
----+----1----+----2
JUPITER0105
SELVIAS0091
SHYAMAL0009
The "SELVIAS0093" should go to error output because of more than 1 difference.
|
Thanks. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
ramas.kamal,
Thanks for the reply. So how about the scenario where there are gaps in the numbers for the same key as shown in my previous post. |
|
Back to top |
|
|
ramas.kamal
New User
Joined: 03 Mar 2014 Posts: 22 Location: India
|
|
|
|
Arun, in case of gaps in numbers, such records should be written to error file. Only, the ones in sequence are considered.
Thanks. |
|
Back to top |
|
|
ramas.kamal
New User
Joined: 03 Mar 2014 Posts: 22 Location: India
|
|
|
|
Bill, this is what I could arrive at with your suggestion. Its part done because I did not understand this -
Quote: |
OUTFIL OMIT= where current sequence not equal to sequence from start of group plus SEQ.
|
Code: |
//STEP0001 EXEC PGM=SORT
//SORTIN DD *
JUPITER0103
JUPITER0104
JUPITER0105
SELVIAS0090
SELVIAS0091
SELVIAS0093
GORAPAK1291
SHYAMAL0008
SHYAMAL0009
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(30:SEQNUM,2,ZD,RESTART=(1,7))),
IFTHEN=(WHEN=GROUP,BEGIN=(30,2,ZD,EQ,1),PUSH=(40:8,4,50:30,2))
SORT FIELDS=(1,11,CH,A)
|
Output with above code:
Code: |
GORAPAK1291 01 1291 01
JUPITER0103 01 0103 01
JUPITER0104 02 0103 01
JUPITER0105 03 0103 01
SELVIAS0090 01 0090 01
SELVIAS0091 02 0090 01
SELVIAS0093 03 0090 01
SHYAMAL0008 01 0008 01
SHYAMAL0009 02 0008 01
|
Thanks. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK, ramas.kamal, that is good and this is how you can work things out.
One thing I missed is the START=0 for the sequence number, so you then get:
Code: |
GORAPAK1291 00 1291 01
JUPITER0103 00 0103 01
JUPITER0104 01 0103 01
JUPITER0105 02 0103 01
SELVIAS0090 00 0090 01
SELVIAS0091 01 0090 01
SELVIAS0093 02 0090 01
SHYAMAL0008 00 0008 01
SHYAMAL0009 01 0008 01 |
Your final column arises from my poor description, it was supposed to be SEQ from the PUSH on WHEN=GROUP. However, you already have a sequence number for the group, so that final column is not needed anyway.
Now, if you add column two to column 3, and arrive at your sequence number from your input, then that record is in sequence. You you can arrange that for INCLUDE=/OMIT= on OUTFIL, and use the OUTFIL reporting that I suggested to get the final one from a good group.
However, other than as an exercise, you can forget that for now, because the "requirement creep" kills this solution. You don't want groups where there is only one record (GORAPAK) and you can't get conditional processing for TRAILER3.
Code: |
JUPITER0103
JUPITER0104
JUPITER0106
JUPITER0107
JUPITER0109
JUPITER0110
|
Following up on Arun's question, can you confirm that the output you require from that is:
Good file:
Bad file:
Code: |
JUPITER0106
JUPITER0107
JUPITER0109
JUPITER0110 |
And also can you say what you'd want as output from this:
Code: |
JUPITER0103
JUPITER0105
JUPITER0106
JUPITER0107
JUPITER0109
JUPITER0110
|
All on the bad file, because 0103 after discarding the others is a unique record, which you don't want?
Arun Raj was discussing another idea, but I think you've killed both of what we had so far. There is a third at least, but what we need to see now is sample input which covers all the cases you may meet with your data, and expected output files for those samples. All in one post, in the Code tags to preserve formatting. |
|
Back to top |
|
|
ramas.kamal
New User
Joined: 03 Mar 2014 Posts: 22 Location: India
|
|
|
|
Bill and Arun, thank you very much for the details. I could have used MAX with DUPKEYS to get my MAX record but I am trying to figure out which set went out of sequence and get that to error output file so that it can be examined and do the necessary patch-up work to avoid batch abend. While, this could have been done very easily using a COBOL, it requires a program name, compilation and so on. I really do not know whether Syncsort could achieve it and if it does, how? I do not have a slightest idea. I am not coding furhter on your suggestion, because you said that idea is given up !
Now, I must admit that I am really confused after reading Bill's description of different possibilities.
Code: |
JUPITER0103
JUPITER0104
JUPITER0106
JUPITER0107
JUPITER0109
JUPITER0110
|
For the above input, yes, good file and bad file both are true.
Code: |
JUPITER0103
JUPITER0105
JUPITER0106
JUPITER0107
JUPITER0109
JUPITER0110
|
Code'd
For this set, I agree with you. Because, nothing was comparable so all went to bad file ! I will come up with sample data after looking into past backups.
However, I would like to summarize that all I need to figure out the skippage and arrest it.
Thanks a lot. |
|
Back to top |
|
|
|