Page 1 of 1

Have to apply previous record no to next record

PostPosted: Wed Jun 13, 2012 4:50 pm
by Hariprasad K
Hi All,

I have an unload database file, having data like below.
NAME NO DEPARTMENT
AAAA 11111111 xxxxxxxxxx
BBBB s p a ces YYYYYYYYYY
CCCC s p a ces PPPPPPPPPP
DDDD s p a ces QQQQQQQQ
AAAA 22222222 xxxxxxxxxx
BBBB s p a ces YYYYYYYYYY
CCCC s p a ces PPPPPPPPPP
DDDD s p a ces QQQQQQQQ (given " s p a ces " because of separating NAME and NO column, indicate that file having spaces at that position)
I Have to take this file as input (unload) and copy those records into another file, such that
Number filed of Name ‘AAAA’ column can be applied to all columns up to ‘DDDD’, and same process for number ‘2222222’.
After sort my output file should be:
NAME NO DEPARTMENT
AAAA 11111111 xxxxxxxxxx
BBBB 11111111 YYYYYYYYYY
DDDD 11111111 PPPPPPPPPP
DDDD 11111111 QQQQQQQQ
AAAA 22222222 xxxxxxxxxx
BBBB 22222222 YYYYYYYYYY
DDDD 22222222 PPPPPPPPPP
DDDD 22222222 QQQQQQQQ

Help me on this using dfsort/syncsort. Pleae ignore if you are not getting my requirement.

Re: Have to apply previous record no to next record

PostPosted: Wed Jun 13, 2012 6:30 pm
by BillyBoyo
You want to look at WHEN=GROUP with identification of 'AAAA' in col 1,4 and PUSH for 6:6,8.

Re: Have to apply previous record no to next record

PostPosted: Wed Jun 13, 2012 8:40 pm
by Hariprasad K
Thank you Mr.Boyo for you suggestion, will try and post the same.

Re: Have to apply previous record no to next record

PostPosted: Wed Jun 13, 2012 9:05 pm
by BillyBoyo
Good for you. Don't forget to let us know, as the answer can help others with similar requirements in the future.

Re: Have to apply previous record no to next record

PostPosted: Thu Jun 14, 2012 7:36 pm
by Hariprasad K
Hi Billy,
As per you I tried like below sort card and it worked
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(01,04,CH,EQ,C'AAAA'),
PUSH=(6:6,8))

Thanks for your help on this.