Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Syncsort - Checking records for a difference of 1

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
ramas.kamal

New User


Joined: 03 Mar 2014
Posts: 22
Location: India

PostPosted: Thu Apr 10, 2014 2:07 pm    Post subject: Syncsort - Checking records for a difference of 1
Reply with quote

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
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1712
Location: UK

PostPosted: Thu Apr 10, 2014 3:49 pm    Post subject: Reply to: Syncsort - Checking records for a difference of 1
Reply with quote

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
View user's profile Send private message
ramas.kamal

New User


Joined: 03 Mar 2014
Posts: 22
Location: India

PostPosted: Thu Apr 10, 2014 5:50 pm    Post subject: Reply to: Syncsort - Checking records for a difference of 1
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Apr 10, 2014 7:14 pm    Post subject: Reply to: Syncsort - Checking records for a difference of 1
Reply with quote

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
View user's profile Send private message
ramas.kamal

New User


Joined: 03 Mar 2014
Posts: 22
Location: India

PostPosted: Fri Apr 11, 2014 2:08 pm    Post subject: Reply to: Syncsort - Checking records for a difference of 1
Reply with quote

Bill, thanks. I will try to work out this idea and come back.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Fri Apr 11, 2014 2:34 pm    Post subject:
Reply with quote

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
View user's profile Send private message
ramas.kamal

New User


Joined: 03 Mar 2014
Posts: 22
Location: India

PostPosted: Fri Apr 11, 2014 3:36 pm    Post subject: Reply to: Syncsort - Checking records for a difference of 1
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Fri Apr 11, 2014 3:41 pm    Post subject:
Reply with quote

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
View user's profile Send private message
ramas.kamal

New User


Joined: 03 Mar 2014
Posts: 22
Location: India

PostPosted: Fri Apr 11, 2014 4:10 pm    Post subject: Reply to: Syncsort - Checking records for a difference of 1
Reply with quote

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
View user's profile Send private message
ramas.kamal

New User


Joined: 03 Mar 2014
Posts: 22
Location: India

PostPosted: Fri Apr 11, 2014 4:29 pm    Post subject: Reply to: Syncsort - Checking records for a difference of 1
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri Apr 11, 2014 4:55 pm    Post subject: Reply to: Syncsort - Checking records for a difference of 1
Reply with quote

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:
Code:
JUPITER0104


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
View user's profile Send private message
ramas.kamal

New User


Joined: 03 Mar 2014
Posts: 22
Location: India

PostPosted: Fri Apr 11, 2014 5:27 pm    Post subject: Reply to: Syncsort - Checking records for a difference of 1
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 1 Fri Dec 02, 2016 9:47 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us