Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Selective SYNCSORT where count more than two

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Fri Jun 15, 2007 5:56 pm    Post subject: Selective SYNCSORT where count more than two
Reply with quote

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
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Jun 18, 2007 6:23 am    Post subject:
Reply with quote

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
View user's profile Send private message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Mon Jun 18, 2007 9:11 am    Post subject:
Reply with quote

Hi Dick,
Sorry I forgot to mention that my mainframe version has SYNCSORT to use.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Jun 19, 2007 1:45 am    Post subject:
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Jun 19, 2007 2:04 am    Post subject: Re: Selective SYNCSORT where count more than two
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Jun 19, 2007 2:50 am    Post subject:
Reply with quote

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
View user's profile Send private message
Johnson_Jiang

New User


Joined: 05 Apr 2007
Posts: 11
Location: China,ShenZhen

PostPosted: Tue Jun 19, 2007 7:42 am    Post subject: Re: Selective SYNCSORT where count more than two
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Jun 19, 2007 8:27 am    Post subject:
Reply with quote

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 icon_smile.gif ). A simple program would do this in one pass saving considerable machine resources.
Back to top
View user's profile Send private message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Tue Jun 19, 2007 10:43 am    Post subject:
Reply with quote

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!

icon_redface.gif What do you say Dick? icon_razz.gif

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!!! icon_wink.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Jun 19, 2007 2:01 pm    Post subject:
Reply with quote

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
View user's profile Send private message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Tue Jun 19, 2007 6:37 pm    Post subject:
Reply with quote

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! icon_biggrin.gif
At least please don't make such a rigid response! Ha ha ha - just jocking!!! icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Jun 19, 2007 8:04 pm    Post subject:
Reply with quote

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 icon_smile.gif . 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 icon_confused.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us