Page 1 of 1

Combining two different records in same file

PostPosted: Thu Dec 29, 2011 12:20 am
by santosh18
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       

Re: Combining two different records in same file

PostPosted: Thu Dec 29, 2011 12:48 am
by dick scherrer
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.

Re: Combining two different records in same file

PostPosted: Thu Dec 29, 2011 12:56 am
by BillyBoyo
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.

Re: Combining two different records in same file

PostPosted: Thu Dec 29, 2011 12:58 am
by santosh18
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

Re: Combining two different records in same file

PostPosted: Thu Dec 29, 2011 1:00 am
by santosh18
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

Re: Combining two different records in same file

PostPosted: Thu Dec 29, 2011 2:43 am
by BillyBoyo
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.

Re: Combining two different records in same file

PostPosted: Thu Dec 29, 2011 1:12 pm
by santosh18
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

Re: Combining two different records in same file

PostPosted: Thu Dec 29, 2011 5:21 pm
by BillyBoyo
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.

Re: Combining two different records in same file

PostPosted: Tue Jan 31, 2012 2:44 am
by Alissa Margulies
Just a quick FYI... Support for WHEN=GROUP is included in SyncSort for z/OS 1.3.2.0 and later.

Regards,