Need to Pass previous record data to next line



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

Need to Pass previous record data to next line

Postby Hariprasad K » Wed Oct 01, 2014 4:31 pm

Hi,

I want to take previous record key value and need to update it next record which does not have a key.

Input file as below:
1111 aaaa
2222 bbbb
        cccc
        dddd
3333 eeee
4444 fffff
        gggg


Output file should be like below:
1111 aaaa
2222 bbbb
2222 cccc
2222 dddd
3333 eeee
4444 fffff
4444 gggg


Thanks in advacne !

Code'd
Hariprasad K
 
Posts: 19
Joined: Sat Feb 25, 2012 5:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to Pass previous record data to next line

Postby BillyBoyo » Wed Oct 01, 2014 5:17 pm

If you use the Code tags and the Preview button, you can preserve spacing.

You need IFTHEN=(WHEN=GROUP....

I'm not sure if SyncSORT (or your SyncSORT) has KEYBEGIN. If not, use IFTHEN=(WHEN=INIIT to set a sequence number with RESTART, then in the WHEN=GROUP use BEGIN with a value of one for your sequence number. You PUSH the key to the existing position of the key PUSH=(1:1,4) and it will be copied to each record.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Need to Pass previous record data to next line

Postby Hariprasad K » Wed Oct 01, 2014 5:22 pm

Hi Billy,

Thanks for your suggestion, it would be great if you can provide more details on this.
Hariprasad K
 
Posts: 19
Joined: Sat Feb 25, 2012 5:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to Pass previous record data to next line

Postby BillyBoyo » Wed Oct 01, 2014 6:03 pm

OK, but you have SyncSORT and I don't even know the particular version you have.

It's easier than I made out anyway. You just need WHEN=GROUP with a BEGIN for your key not being space, then the PUSH. Try it.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Need to Pass previous record data to next line

Postby Hariprasad K » Wed Oct 01, 2014 6:25 pm

Thanks Billy, I tried and it's given correct results.. Thank you much for your guidelines.

Here is the sort card:
First step:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,NE,C' '),PUSH=(40:ID=1))

Second step:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(40,1),
PUSH=(1:1,4))
Hariprasad K
 
Posts: 19
Joined: Sat Feb 25, 2012 5:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to Pass previous record data to next line

Postby BillyBoyo » Wed Oct 01, 2014 7:19 pm

Try this now in one step:

SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,NE,C' '),PUSH=(1:1,4))
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Need to Pass previous record data to next line

Postby Hariprasad K » Wed Oct 01, 2014 8:36 pm

Great, it worked as I expected, I used to read all your suggestions posted in this site. Really appreciate your efforts for reading and giving suggestions for all users.
Hariprasad K
 
Posts: 19
Joined: Sat Feb 25, 2012 5:17 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post