View previous topic :: View next topic
|
Author |
Message |
amitava Warnings : 1 Active User
Joined: 30 Oct 2005 Posts: 186 Location: India
|
|
|
|
Hi All,
I want to sort my input file(say - A) on the column 1-5 and 29-9. Column 29-9 is repeatative in the output file i.e. in output file it can come for more than one occurance. I want to move those records of the input fie whose 29-9 column occurance are same for more than 2 records. Am I clear to my question? E.g -
My Input File
===========================================
Code: |
ABCD XXXXX 001349259051349659 12345 1 003LESSARD
ABCD YYYYY 001349259 12345 1 003LESSARD
ABCD XXXXX 001429069039300356 12345 1 001LECHMAN
ABCD YYYYY 001429069 12345 1 001LECHMAN
ABCD XXXXX 001622738001387381 12345 1 004DICKINSON
ABCD XXXXX 001622738009743459 12345 1 004DICKINSON
ABCD XXXXX 001622738009707851 12345 1 004DICKINSON
ABCD YYYYY 001622738 12345 1 004DICKINSON
ABCD XXXXX 001625267026881000 12345 1 002MUDGE
ABCD YYYYY 001625267 12345 1 002MUDGE
|
But as number of records are more than two for 29-9 column's value - 001622738. In the output file I just want the records associated with 001622738. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Please post which sort product your organization uses.
If you are not sure, the jes output for a sort step will identify which sort product you are using. |
|
Back to top |
|
|
amitava Warnings : 1 Active User
Joined: 30 Oct 2005 Posts: 186 Location: India
|
|
|
|
Hi Dick,
Sorry I forgot to mention that my mainframe version has SYNCSORT to use. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Amitava,
I believe you will be ahead to proceed with program code. This should take only a small amount of code to accomplish.
There may be a way to do this with Syncsort/Synctool, but i've not been able to find an example that does what you want. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
amitava wrote: |
I want to sort my input file(say - A) on the column 1-5 and 29-9. Column 29-9 is repeatative in the output file i.e. in output file it can come for more than one occurance. I want to move those records of the input fie whose 29-9 column occurance are same for more than 2 records. Am I clear to my question? |
At this point, I think I understand....
Quote: |
But as number of records are more than two for 29-9 column's value - 001622738. In the output file I just want the records associated with 001622738. |
But now I am confused...
Please re-list your input and what you expect the output to be. Please provide input m& output which illustrate your conditions and exceptions. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Bill,
The output should only contain records that have a key that is a duplicate to at least two other records - not merely a single duplicate. The input is in order by this "key". (if i understand correctly. . .).
In the posted sample data, only one key fits the rule - 001622738. |
|
Back to top |
|
|
Johnson_Jiang
New User
Joined: 05 Apr 2007 Posts: 11 Location: China,ShenZhen
|
|
|
|
I think maybe you just want to pick out all those record which the count of 29-9 is more than two rows, right? Maybe no need to use program to do it, just use SORT and refer to the three steps:
1. Use SORT/Copy option to add one constant field, i.e. '00001', at the end of each record.
2. Use SORT/Sum option to sum all the records, the sum fields should be 1-5 and 29-9. After this step, you can pick out all of those records which the count of 29-9 is more than 2.
3. Use Sort/Include option to get rid of those unsuitable records.
Sample JCL:
Step1 :
//SORTIN DD DSN....
//SORTOUT DD DSN=&&TEMP01,DISP=(NEW,PASS)... <- File length should be extended to contain the field '000001'.
//SYSIN DD *
SORT FIELDS=COPY
OUTREC=(1,length of inputfile,C'000001'),CONVERT
Step2:
//SORTIN DD DSN=&&TEMP01,DISP=(OLD,PASS)
//SORTOUT DD DSN=&&TEMP02,DISP=(NEW,PASS)....
//SYSIN DD *
SORT FIELDS=(1,5,CH,A,29,9,CH,A)
SUM FIELDS=(22,6,ZD) <- Here sum by the new field
OUTREC FIELDS=(1, length of temp01)
Step3:
//SORTIN DD DSN=&&TEMP02,DISP=(OLD,PASS)
//SORTOUT DD DSN=<Your output file here>,DISP=(NEW,CATLG)....
//SYSIN DD *
SORT FIELDS=(1,5,CH,A,29,9,CH,A)
INCLUDE=(xx,xx,CH,NE,C'000001') <- Here get rid of those single record
OUTREC FIELDS=(1, length of your input file) |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Yes, i believe something like that could work (i don't believe what is posted will quite make it - try it on your system and let us know), but it is more "programmer" work than a simple program would be . . . It is also 3 steps that would have to be documented (if this was something that would be promoted to production) rather than one.
What if additional business rules are determined?
One other caution is that if the original input had 100 million records and 20 million were selected as >2 duplicates, that is 3 passes of those 20 million "keepers" and 2 passes of the 100 million (my math may be off there, but you get the idea ). A simple program would do this in one pass saving considerable machine resources. |
|
Back to top |
|
|
amitava Warnings : 1 Active User
Joined: 30 Oct 2005 Posts: 186 Location: India
|
|
|
|
Hi All,
Thanx a lot for your help and support. Dick and William-I am creating the input file obviously thru a COBOL program and this program has become so much complicated having the business logic and so; I prefered to do the reformat thru JCL. I am getting what you want to specify Dick, but really I think it will be very tough to incorporate the changes in the existing program! And including a new program for doing the reformat only I think it will be an extra burden to the system!
What do you say Dick?
Johnson - Thanks a lot for your approach! I have to run it in my system and will let you about this if any mishap happens!!! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You have not posted any of your business rules or described any of the complexity, so i cannot make much of a reply.
Unless there is something i do not understand, where is the difficulty in only writing the output when there are more than 2 records for a given key? |
|
Back to top |
|
|
amitava Warnings : 1 Active User
Joined: 30 Oct 2005 Posts: 186 Location: India
|
|
|
|
Hi Dick,
Please don't mind but as it is (IBMMAINFRAME) is a common forum I cannot post my organization's business details required for the program we have already coded or the JCL step we want to incorporate in our existing JCL.
Hey I know (Not to disclose the business processing) - this is something big people always talk about! But frankly speaking (as of mine), it will be very tough to explain you all the business details thru a mail only!
At least please don't make such a rigid response! Ha ha ha - just jocking!!! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If the requirement definition is well understood, it can be explained without giving away any "company secrets". Also, i don't believe we need "all the details" just enough info to understand what is so complex.
For giggles, look around in some of the topics and you will find this
Quote: |
At least please don't make such a rigid response! Ha ha ha |
is far less "rigid" than many replies . What it amounts to is that the more/better info provided, the better suggestions we can offer.
However, this still has not been answered
Quote: |
Unless there is something i do not understand, where is the difficulty in only writing the output when there are more than 2 records for a given key?
|
What is the difficulty in preparing the first 2 records and not writing them to the output file until there is a 3rd? It would take a small bit of code, but nothing really difficult |
|
Back to top |
|
|
|