MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Syncsort - Split input file without spliting group of record

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
TS70363
Beginner


Joined: 20 May 2010
Posts: 4
Topics: 1

PostPosted: Thu May 28, 2015 9:22 am    Post subject: Syncsort - Split input file without spliting group of record Reply with quote

Hi,

I have a tape file with approx x records - RECFM/LRECL = FB/100

A sample data in position 1,10 & 12,1
Code:

A111111111 1
A111111111 2
B222222222 3
C333333333 4
C333333333 5
C333333333 6
D444444444 7
D444444444 8
D444444444 9
D444444444 0
D444444444 A

I need to split the file in such a way that I get approx 1000000 records in my output files.
While splitting, we should take care that a group does not get split.

This means if 1000000 th record is D444444444 8, the sort should either stop copying into the first file at the end of all C333333333 or end of all D444444444 without actually splitting the group.

Is it possible to achieve using Syncsort?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu May 28, 2015 11:03 am    Post subject: Reply with quote

TS70363,

It can be done quite easily with DFSORT.

1. Code a 8 byte SEQNUM with a RESTART on your key at position 101.
2. With WHEN=GROUP push an 8 byte ID for every 1000000 records at position 109.
3. Use another WHEN=GROUP while checking for 1 in bytes 101 thru 108 and push the group key at position 109 on to position 117.
4. Now validate the counter at position 117 on OUTFIL for 1,2,3.... and just build the first 100 bytes.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
TS70363
Beginner


Joined: 20 May 2010
Posts: 4
Topics: 1

PostPosted: Fri May 29, 2015 6:15 am    Post subject: Reply with quote

Assuming my input of 1 byte & approx 5 records to be copied in each output file, I have written the below sort.

Code:

SORT FIELDS=COPY                                               
INREC IFTHEN=(WHEN=INIT,OVERLAY=(16:SEQNUM,8,ZD,RESTART=(1,1))),
      IFTHEN=(WHEN=GROUP,RECORDS=5,PUSH=(25:ID=8)),             
      IFTHEN=(WHEN=GROUP,BEGIN=(16,8,ZD,EQ,1),RECORDS=1,       
                         PUSH=(25:1,1))                         


The output is:

Code:

A              00000001 A0000001
A              00000002 00000001
A              00000003 00000001
B              00000001 B0000001
B              00000002 00000001
B              00000003 00000002
C              00000001 C0000002
C              00000002 00000002
D              00000001 D0000002
D              00000002 00000002
E              00000001 E0000003
E              00000002 00000003
E              00000003 00000003
E              00000004 00000003
E              00000005 00000003
E              00000006 00000004
E              00000007 00000004


I am now stuck as Record B (group) should either go to file 1 or file 2 but not both
Back to top
View user's profile Send private message
TS70363
Beginner


Joined: 20 May 2010
Posts: 4
Topics: 1

PostPosted: Fri May 29, 2015 6:46 am    Post subject: Reply with quote

Expected Output:

File1
Code:
A              00000001 A0000001
A              00000002 00000001
A              00000003 00000001
B              00000001 B0000001
B              00000002 00000001
B              00000003 00000002


File 2
Code:
C              00000001 C0000002
C              00000002 00000002
D              00000001 D0000002
D              00000002 00000002


File 3
Code:
E              00000001 E0000003
E              00000002 00000003
E              00000003 00000003
E              00000004 00000003
E              00000005 00000003
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri May 29, 2015 10:16 am    Post subject: Reply with quote

TS70363 wrote:

IFTHEN=(WHEN=GROUP,BEGIN=(16,8,ZD,EQ,1),RECORDS=1,
PUSH=(25:1,1))


TS70363,

what exactly do you think you will achieve with this statement? especially the RECORDS=1? Read the instructions once again especially 3 and 4. You also have your push wrong.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Fri May 29, 2015 10:31 am    Post subject: Reply with quote

I think you read too much into the word "key".


Code:
  SORT FIELDS=COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(16:SEQNUM,8,ZD,RESTART=(1,1))),
        IFTHEN=(WHEN=GROUP,RECORDS=5,PUSH=(25:ID=8)),
        IFTHEN=(WHEN=GROUP,BEGIN=(16,8,ZD,EQ,1),
                           PUSH=(34:25,8))


Gives this output:
Code:

A              00000001 00000001 00000001
A              00000002 00000001 00000001
A              00000003 00000001 00000001
B              00000001 00000001 00000001
B              00000002 00000001 00000001
B              00000003 00000002 00000001
C              00000001 00000002 00000002
C              00000002 00000002 00000002
D              00000001 00000002 00000002
D              00000002 00000002 00000002
E              00000001 00000003 00000003
E              00000002 00000003 00000003
E              00000003 00000003 00000003
E              00000004 00000003 00000003
E              00000005 00000003 00000003
E              00000006 00000004 00000003
E              00000007 00000004 00000003


You now code three OUTFILs, one for 00000001 and 0000002 and one with SAVE.
Back to top
View user's profile Send private message
TS70363
Beginner


Joined: 20 May 2010
Posts: 4
Topics: 1

PostPosted: Fri May 29, 2015 11:11 am    Post subject: Reply with quote

Dear kolusu,

Thanks for your inputs.

Dear William Collins,

Yes, I read too much into the word "key". Very Happy

Now it worked fine. Thanks,
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group