Combining two different records in same file



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

Combining two different records in same file

Postby santosh18 » Thu Dec 29, 2011 12:20 am

Hi,

Intention is to combine contents of two records into 1 present in the same file
Combine Record#1 & Record#2 into 1 similarly Record#3 & Record#4 into 1

I was trying to use the WHEN=GROUP by labelling every two records and then use SPLICE
INREC IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(15:ID=3,19:SEQ=2))

Our shop uses SYNCSORT FOR Z/OS 1.3.0.2R which is not the latest version of SYNCSORT hence unable to use the WHEN=GROUP

Below is the input and intended output.

Input
NO OF PTA RECORDS WRITTEN    :000000022                   
        1 //TT@7NA00 JOB (1111,,TT,999999),'TEMP JOB DLY',
NO OF PTA RECORDS WRITTEN    :000000124                   
        1 //TT@7NA01 JOB (1111,,TT,999999),'TEMP JOB',     
        1 //TT@7NA02 JOB (1111,,TT,999999),'TEMP JOB',     
NO OF PTA RECORDS WRITTEN    :000000116                   
NO OF PTA RECORDS WRITTEN    :000000103                   
        1 //TT@7NA03 JOB (1111,,TT,999999),'TEMP JOB',     
        1 //TT@7NA04 JOB (1111,,TT,999999),'TEMP JOB',     
NO OF PTA RECORDS WRITTEN    :000000098                   


Output
TT@7NA00 NO OF PTA RECORDS WRITTEN    :000000022       
TT@7NA01 NO OF PTA RECORDS WRITTEN    :000000124       
TT@7NA02 NO OF PTA RECORDS WRITTEN    :000000116       
TT@7NA03 NO OF PTA RECORDS WRITTEN    :000000103       
TT@7NA04 NO OF PTA RECORDS WRITTEN    :000000098       
santosh18
 
Posts: 4
Joined: Wed Dec 28, 2011 11:54 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Combining two different records in same file

 

Re: Combining two different records in same file

Postby dick scherrer » Thu Dec 29, 2011 12:48 am

Hello and welcome to the forum,

My 1.3 Syncsort documentation shows that when=group is available. I don't know which of the 1.3 upgrades had it first.

Looking at your input, i believe you need to find a way to recreate the input so that the data is in "group sequence". What you show is just some "stuff" that is not in groups.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Combining two different records in same file

Postby BillyBoyo » Thu Dec 29, 2011 12:56 am

You were looking at pairs of records, but it is not always the same type of record which comes first?

If it will always work with pairs, then you could split the file in two, depending on the type of record, adding a simple sequence number to each file as you do the split.

Do you have JOINKEYS? If so, it can all be done simply in one step. SPLICE I have never looked at myself, but you seem OK with that already.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Combining two different records in same file

Postby santosh18 » Thu Dec 29, 2011 12:58 am

Thanks a lot for your reply
The sysout had a syntax error message with a * at the begging of the GROUP

Is there a way to combine without the when=group
santosh18
 
Posts: 4
Joined: Wed Dec 28, 2011 11:54 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Combining two different records in same file

Postby santosh18 » Thu Dec 29, 2011 1:00 am

BillyBoyo wrote:You were looking at pairs of records, but it is not always the same type of record which comes first?

If it will always work with pairs, then you could split the file in two, depending on the type of record, adding a simple sequence number to each file as you do the split.

Do you have JOINKEYS? If so, it can all be done simply in one step. SPLICE I have never looked at myself, but you seem OK with that already.

Yes you are correct order of record is not sure. But two lines would be one group
Yes I can use join keys can you kindly guide me on the approach
santosh18
 
Posts: 4
Joined: Wed Dec 28, 2011 11:54 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Combining two different records in same file

Postby BillyBoyo » Thu Dec 29, 2011 2:43 am

The idea then is to split the file in two, and on each part-file put a sequence number starting from one (or zero, or whatever, as long as the same). Then do the join on the sequence number and do the manipulation to get your desired output.

In you JCL, mention your dsn on both the input DDs for your join.

In the control statements for the join (the cntl files) include one type of record (for instance, first byte is space) and append a generated sequence number. Do the same, but reverse the selection, for the other file. You can use INCLUDE and OMIT.

Then do the join, on the generated sequence numbers. Specify SORTED,NOSEQCHECK for each of the JOINKYES statements.

Put together your output with REFORMAT.

That's about it.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Combining two different records in same file

Postby santosh18 » Thu Dec 29, 2011 1:12 pm

Hi,

Was able to get the desired result by adding a sequence number at the end and using JOINKEYS and REFORMT

Thanks a lot for your help below is the way I achieved the desired result

Code

Sequence number generation

SORT FIELDS=COPY                               
INCLUDE COND=(11,08,CH,EQ,C'//TT@7NA')         
INREC OVERLAY(78:SEQNUM,2,ZD,START=0,INCR=1)   

Joining two rows

JOINKEYS FILE=F1,FIELDS=(78,02,A)   
JOINKEYS FILE=F2,FIELDS=(78,02,A)   
REFORMAT FIELDS=(F1:13,08,F2:1,39) 
SORT FIELDS=COPY                   
OUTREC BUILD=(1,8,C' - ',9,39)     




Intermediate Steps
//TT@7NA00 JOB (1111,,TT,999999),'RI NADD DLY',                    00
//TT@7NA01 JOB (1111,,TT,999999),'RI NADD',                        01
//TT@7NA02 JOB (1111,,TT,999999),'RI NADD',                        02
//TT@7NA03 JOB (1111,,TT,999999),'RI NADD',                        03
//TT@7NA04 JOB (1111,,TT,999999),'RI NADD',                        04


NO OF PTA RECORDS WRITTEN    :000000022                            00
NO OF PTA RECORDS WRITTEN    :000000124                            01
NO OF PTA RECORDS WRITTEN    :000000116                            02
NO OF PTA RECORDS WRITTEN    :000000103                            03
NO OF PTA RECORDS WRITTEN    :000000098                            04


Final Output

TT@7NA00 - NO OF PTA RECORDS WRITTEN    :000000022
TT@7NA01 - NO OF PTA RECORDS WRITTEN    :000000124
TT@7NA02 - NO OF PTA RECORDS WRITTEN    :000000116
TT@7NA03 - NO OF PTA RECORDS WRITTEN    :000000103
TT@7NA04 - NO OF PTA RECORDS WRITTEN    :000000098
santosh18
 
Posts: 4
Joined: Wed Dec 28, 2011 11:54 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Combining two different records in same file

Postby BillyBoyo » Thu Dec 29, 2011 5:21 pm

I'm glad you got it. Did you manage it in one step?

You sequence number isn't very big. You haven't told the JOIN that the file is sorted, and that there is no need to perform sequence checking. If you have more than 200 records on your input, things will start to pickle.

I think it will work if you tell the join the full information, no matter how big your input file, as you are only going to get 1-1 matches. However, I think it better practice for the sequence number to be at least an power-of-10 bigger than the likely maximum of your data. If you want to keep it smaller, document it, formally and in the sort cards.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Combining two different records in same file

Postby Alissa Margulies » Tue Jan 31, 2012 2:44 am

Just a quick FYI... Support for WHEN=GROUP is included in SyncSort for z/OS 1.3.2.0 and later.

Regards,
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 1 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post