View previous topic :: View next topic
|
Author |
Message |
spradeepece
New User
Joined: 25 Jun 2008 Posts: 19 Location: Chennai
|
|
|
|
Hello,
I have the following scenario, where the input file is organized in blocks. An 'AA' marks the start of a new block. Within a block, there can be sub-blocks that starts with BB and ends with DD. Data in column 3 is same across a block.
I need to find the number of sub-blocks within each block (count to be displayed in AA record)
Input File
Code: |
AA1
BB1
DD1
BB1
CC1
DD1
BB1
DD1
AA2
BB2
DD2 |
Output file
Code: |
AA1 03
BB1
DD1
BB1
CC1
DD1
BB1
DD1
AA2 01
BB2
DD2 |
The following code may not be the efficient one but works fine.
Code: |
INREC IFTHEN=(WHEN=INIT,BUILD=(1:1,3,4:SEQNUM,4,ZD,
8:SEQNUM,2,ZD,RESTART=(3,1))),
IFTHEN=(WHEN=(1,2,CH,EQ,C'DD'),OVERLAY=(10:C'01')),
IFTHEN=(WHEN=(1,2,CH,NE,C'DD'),OVERLAY=(10:C'00'))
SORT FIELDS=(3,1,CH,A)
SUM FIELDS=(10,2,ZD),XSUM |
In the next step, the sortout and the XSUM files were merged using the below sort card,
Code: |
SORT FIELDS=(4,4,CH,A)
OUTFIL FNAMES=SORTOUT,
IFTHEN=(WHEN=(1,2,CH,EQ,C'AA'),
BUILD=(1:1,3,X,5:10,2)),
IFTHEN=(WHEN=(1,2,CH,NE,C'AA'),
BUILD=(1:1,3,3X)) |
But I need some expertise to have this sort in single step/a better one.
(Sorry if i ve been in the wrong forum)
Thanks
- Pradeep |
|
Back to top |
|
|
spradeepece
New User
Joined: 25 Jun 2008 Posts: 19 Location: Chennai
|
|
|
|
Hi All,
Any luck ?
- Pradeep
* I sent a PM to Syncsort concerning this. - Kevin |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
You can achieve it in a single step SYNCTOOL without much sort overhead in some alternate way. but i doubt if you can save a data pass. |
|
Back to top |
|
|
spradeepece
New User
Joined: 25 Jun 2008 Posts: 19 Location: Chennai
|
|
|
|
Yes Arun.
It can be done using Synctool. But I should say that data pass within same step is not practised in our org.
Thanks
- Pradeep |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Even using multiple steps i think you can save a bit of "sort" overhead. I will try to post a bit of code.
What are your input/output file attributes. Also which version of sort you're using? You'll find it in your sysout. |
|
Back to top |
|
|
spradeepece
New User
Joined: 25 Jun 2008 Posts: 19 Location: Chennai
|
|
|
|
Yes Arun.
Any efficient logic to get this done would be fine. Single step solution would be just an added value.
Thanks
- Pradeep |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Why the need for a single step. As Arun has said, it may not be possible to reduce the number of data passes, so wht is the great thing about spending time and money on a solution that doesn't use any less cpu or elapsed time ? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Adding to what expat has told, If you find any difficulty in posting the requested info let us know, we'll help you. |
|
Back to top |
|
|
spradeepece
New User
Joined: 25 Jun 2008 Posts: 19 Location: Chennai
|
|
|
|
Arun / Expat,
I am OK for multiple step, provided the logic is better. Wherein I dont remove duplicates using XSUM, and merge them again in the next step. Which I feel is a bit of revamping work.
Was just curious if there could be another solution.
Thanks anyways. I ve got it done already.
Thanks
- Pradeep |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
Was just curious if there could be another solution |
There can be multiple solutions for the same problem. And there may be better solutions than the one you have got.
It is upto you to decide which one you want to go with. |
|
Back to top |
|
|
|