View previous topic :: View next topic
|
Author |
Message |
huttesh
New User
Joined: 31 Oct 2008 Posts: 9 Location: bangalore
|
|
|
|
I need to copy the contents from a concatenated file to 2 different file
where I 'll extract only some particular fields. Along with this I need to
extract some other fields and remove the duplicates into file3
My Question
So how to give give 2 sort statements in syncsort. Basically I want to combine the below steps in one syncsort stepitself.step2 out put should be
written to files=3
Step1
SORT FIELDS=COPY
OUTFIL FILES=1,INCLUDE=(21,4,CH,EQ,C'MQF1')
OUTFIL FILES=2,INCLUDE=(21,4,CH,EQ,C'MQL1')
Step2
Sort fields=(21,4,CH,A,29,2,PD,A)
SUM FIELDS=NONE
Thanks a Lot |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
huttesh,
Welcome to the forums.
AFAIK, you cant give multiple SORT statements in a SYSIN card. You can either do a COPY or a SORT/MERGE operation.
BTW, do you really need unsorted records written into FILES=1 and FILES=2 ? Is it still ok if you extract the records after the SORT operation mentioned above? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
Suggest you post some sample input records and the outputs you want from those sample input records explaining the rules for creating the outputs. These do not need to be full-length records - only the fields that are needed to show your requirement.
Also, mention the recfm and lrecl of all files. |
|
Back to top |
|
|
huttesh
New User
Joined: 31 Oct 2008 Posts: 9 Location: bangalore
|
|
|
|
input records
Code: |
123456789--column position
ADKJBJBBJ---1ST RECORD
ANNMNBMK---2 ND RECORD
HDHBCBBBB--3 RD RECORD |
OUT PUT
FIRST FILE SHOULD HAVE RECORDS WHICH HAS 'A' IN POITION 1
SECOUND FILE SHOUL HAVE RECORDS WHICH HAS B IN POSITION 7
THIRD FILE SHOULD HAVE DEDUPED RECORDS AND SHOULD BE SORTED
ON POSITION 8.
The challenge I have is, I need to do all these in single syncsort step.!!!!
Thanks a lot |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
The challenge I have is, I need to do all these in single syncsort step |
huttesh,
Is that a business need? I think the focus here should be on what you're trying to achieve and NOT on whether you do in a single step or multiple steps.
Please try to respond to the questions raised here if you're expecting help from a forum. |
|
Back to top |
|
|
huttesh
New User
Joined: 31 Oct 2008 Posts: 9 Location: bangalore
|
|
|
|
I want improve the performence, hence want to do everything in one step.
I think the only way we achieve this is by giving multiple sort cards...
If your answer is you cant give multiple SORT statements in a SYSIN card.
Then I need to drop this approach.
Thanks Very much. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
If your answer is you cant give multiple SORT statements in a SYSIN card.
Then I need to drop this approach. |
Not necessarily. There may be alternatives. But you are not helping yourself by not responding to any of the questions asked here. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I want improve the performence, hence want to do everything in one step. |
Why would you believe that having only 1 step yields better performance?
The way to better performance is to reduce i/o - i mention this as there are multiple topics in the forum where the solution is "one step" but the data is passed 3 or 4 times - which can be horrible for performance.
As Arun mentioned - you need to provide the requested info for anyone to be able to help. The "Helpee" needs to humor the "Helpers"
Multiple SORT statements in a step is not an option. |
|
Back to top |
|
|
huttesh
New User
Joined: 31 Oct 2008 Posts: 9 Location: bangalore
|
|
|
|
Code:
123456789--column position
ADKJBJBBJ---1ST RECORD
ANNMNBMK---2 ND RECORD
HDHBCBBBB--3 RD RECORD
OUT PUT
FIRST FILE SHOULD HAVE RECORDS WHICH HAS 'A' IN POITION 1
SECOND FILE SHOULD HAVE RECORDS WHICH HAS B IN POSITION 7
THIRD FILE SHOULD HAVE DEDUPED RECORDS AND SHOULD BE SORTED ON POSITION 8.
We can Achive this by giving in first step
SORT FIELDS=COPY
OUTFIL FILES=1,INCLUDE=(1,1,CH,EQ,C'A')
OUTFIL FILES=2,INCLUDE=(7,1,CH,EQ,C'B')
Second Step
SORT FIELDS =(8,1,CH,A)
SUM FIELDS=NONE
My question
I don't want to read the same file in two steps as the file could have million of records
and cause performence issue? Any idea of achieving this by reading the
file only once by using syncsort in only one step?
Thank you!
|
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
huttesh wrote: |
Any idea of achieving this by reading the
file only once by using syncsort in only one step? |
If you allow files 1 & 2 to be sorted on position 8 and have dups dropped, I'd think it can be done..... |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
huttesh,
Unfortunately, your latest post just repeats what you have already told in your previous posts leaving the questions still unanswered.
Quote: |
do you really need unsorted records written into FILES=1 and FILES=2 ? |
Quote: |
Is it still ok if you extract the records into FILES=1 and FILES=2 after the SORT operation mentioned above? |
Quote: |
post some sample input records and the outputs you want from those sample input records explaining the rules for creating the outputs. These do not need to be full-length records - only the fields that are needed to show your requirement.
Also, mention the recfm and lrecl of all files. |
|
|
Back to top |
|
|
huttesh
New User
Joined: 31 Oct 2008 Posts: 9 Location: bangalore
|
|
|
|
do you really need unsorted records written into FILES=1 and FILES=2 ?
SORT FIELDS=COPY
OUTFIL FILES=1,INCLUDE=(1,1,CH,EQ,C'A')
OUTFIL FILES=2,INCLUDE=(7,1,CH,EQ,C'B')
This will take care of sorting. if it's not sorted also its fine
Is it still ok if you extract the records into FILES=1 and FILES=2 after the SORT operation mentioned above?
No. In the same sort operation I want to extract
post some sample input records and the outputs you want from those sample input records explaining the rules for creating the outputs. These do not need to be full-length records - only the fields that are needed to show your requirement.
Also, mention the recfm and lrecl of all files.
Answer
Code: (Input records from a file)
123456789--column position
ADKJBJBBJ---1ST RECORD
ANNMNBMK---2 ND RECORD
HDHBCBBBB--3 RD RECORD
OUT PUT Record expected to 3 files
FIRST FILE SHOULD HAVE RECORDS WHICH HAS 'A' IN POITION 1
SECOND FILE SHOULD HAVE RECORDS WHICH HAS B IN POSITION 7
THIRD FILE SHOULD HAVE DEDUPED RECORDS AND SHOULD BE SORTED ON POSITION 8.
We can Achive this by giving in first step
SORT FIELDS=COPY
OUTFIL FILES=1,INCLUDE=(1,1,CH,EQ,C'A')
OUTFIL FILES=2,INCLUDE=(7,1,CH,EQ,C'B')
Second Step
SORT FIELDS =(8,1,CH,A)
SUM FIELDS=NONE
My question
I don't want to read the same file in two steps as the file could have million of records
and cause performence issue? Any idea of achieving this by reading the
file only once by using syncsort in only one step? |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
I supposed that if you INREC IFTHEN and create two records for each input.
The first with the A or B and a large seqnum added to the end of the record.
The second with a C and the sort/sum field where the seqnum is in the first.
After sort/summing, OUTFIL to strip off the additional fileds.
Something like this
SORT FIELDS =(21,10,CH,A) (large seqnum)
SUM FIELDS=NONE
OUTFIL FILES=1,INCLUDE=(20,1,CH,EQ,C'A')
OUTFIL FILES=2,INCLUDE=(20,1,CH,EQ,C'B')
OUTFIL FILES=3,INCLUDE=(20,1,CH,EQ,C'C')
might work.....
Good: one pass....
Bad: more records to sort and a longer sort key.... |
|
Back to top |
|
|
huttesh
New User
Joined: 31 Oct 2008 Posts: 9 Location: bangalore
|
|
|
|
My Requirement is dif
Code: (Input records from a file)
123456789--column position
ADKJBJBBJ---1ST RECORD
ANNMNBMK---2 ND RECORD
HDHBCBBBB--3 RD RECORD
OUT PUT Record expected to 3 files
FIRST FILE SHOULD HAVE RECORDS WHICH HAS 'A' IN POITION 1
Ex
ADKJBJBBJ
ANNMNBMK
SECOND FILE SHOULD HAVE RECORDS WHICH HAS B IN POSITION 7
ex:
ADKJBJBBJ
ANNMNBMK
HDHBCBBBB
THIRD FILE SHOULD HAVE DEDUPED RECORDS AND SHOULD BE SORTED ON POSITION 8.
EX:
ADKJBJBBJ |
|
Back to top |
|
|
Douglas Wilder
Active User
Joined: 28 Nov 2006 Posts: 305 Location: Deerfield IL
|
|
|
|
Why would the third file not have the 2 nd record in it?
Code: |
ANNMNBMK---2 ND RECORD |
|
|
Back to top |
|
|
huttesh
New User
Joined: 31 Oct 2008 Posts: 9 Location: bangalore
|
|
|
|
Oh I missed it Sorry, Yes it will have the second record. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Why would the second file have the 2nd record?
Quote: |
SECOND FILE SHOULD HAVE RECORDS WHICH HAS B IN POSITION 7
ex:
Code: |
----+----+
ADKJBJBBJ
ANNMNBMK ---> no B in pos-7, still in file-2
HDHBCBBBB |
|
|
|
Back to top |
|
|
huttesh
New User
Joined: 31 Oct 2008 Posts: 9 Location: bangalore
|
|
|
|
I have corrected my inputs and outputs I am expecting. Can this be
done through a single syncsort step??
Code: (Input records from a file)
123456789--column position
ADKJBJBBJ---1ST RECORD
ANNMNBMK---2 ND RECORD
HDHBCBBBB--3 RD RECORD
OUT PUT Record expected to 3 files
FIRST FILE SHOULD HAVE RECORDS WHICH HAS 'A' IN POITION 1
Ex
ADKJBJBBJ
ANNMNBMK
SECOND FILE SHOULD HAVE RECORDS WHICH HAS B IN POSITION 7
ex:
ADKJBJBBJ
HDHBCBBBB
THIRD FILE SHOULD HAVE DEDUPED RECORDS AND SHOULD BE SORTED ON POSITION 8.
EX:
ADKJBJBBJ
ANNMNBMK |
|
Back to top |
|
|
huttesh
New User
Joined: 31 Oct 2008 Posts: 9 Location: bangalore
|
|
|
|
Code: (Input records from a file)
123456789--column position
ADKJBJBBJ---1ST RECORD
ANNMNBMK---2 ND RECORD
HDHBCBBBB--3 RD RECORD
OUT PUT
FIRST FILE SHOULD HAVE RECORDS WHICH HAS 'A' IN POITION 1
SECOND FILE SHOULD HAVE RECORDS WHICH HAS B IN POSITION 7
THIRD FILE SHOULD HAVE DEDUPED RECORDS AND SHOULD BE SORTED ON POSITION 8.
OUT PUT Record expected to 3 files
FIRST FILE SHOULD HAVE RECORDS WHICH HAS 'A' IN POITION 1
Ex
ADKJBJBBJ
ANNMNBMK
SECOND FILE SHOULD HAVE RECORDS WHICH HAS B IN POSITION 7
ex:
ADKJBJBBJ
HDHBCBBBB
THIRD FILE SHOULD HAVE DEDUPED RECORDS AND SHOULD BE SORTED ON POSITION 8.
EX:
ADKJBJBBJ
ANNMNBMK
We can Achive this by giving below aort condition in first step
SORT FIELDS=COPY
OUTFIL FILES=1,INCLUDE=(1,1,CH,EQ,C'A')
OUTFIL FILES=2,INCLUDE=(7,1,CH,EQ,C'B')
Second Step
SORT FIELDS =(8,1,CH,A)
SUM FIELDS=NONE
My question
I don't want to read the same file in two steps as the file could have million of records and cause performence issue? Any idea of achieving this by reading the file only once by using syncsort in only one step? |
|
Back to top |
|
|
bipinpeter
Active User
Joined: 18 Jun 2007 Posts: 213 Location: Cochin/Kerala/India
|
|
|
|
Hi huttesh.
Try the below sort card,
SORT FIELDS=(8,1,CH,A)
OUTFIL FILES=1,INCLUDE=(1,1,CH,EQ,C'A'),
TRAILER1=(1:C'COUNT OF A RECORDS',15:COUNT),NODETAIL
OUTFIL FILES=2,INCLUDE=(7,1,CH,EQ,C'B'),
TRAILER1=(1:C'COUNT OF B RECORDS',15:COUNT),NODETAIL
SUM FIELDS=NONE,XSUM
I didnt tested this code just check it out.....
Regards,
Bipin Peter |
|
Back to top |
|
|
|