Posted: Tue Jun 03, 2008 11:25 am Post subject: SORT Utility to save excluded records to a different dataset
Members,
I have a dataset with 10 records as below and the SORT card is created by a program in STEP1 which i am making use of it in this step and i am showing it in SYSIN for understanding purpose.
Now when i run this job in the SORTOUT Dataset USERID.TEST.OUT1 i will have 3 records
Code:
ABC
A11
ACC
Now what i want is i want to store the 7 excluded records in a different dataset say USERID.TEST.OUT2 in the same step if possible.
So i expect USERID.TEST.OUT2
Code:
DEF
XYZ
GHJ
YYY
BBB
KKK
LLL
If it is possible can anybody help me out .
I have one more question ,can we form a SORT code like below to use in the same step2 code at run time as it is a batch JCL which will also solve the process.
I could understand the problem why it did not work at the first time and i am clear.
Now i have a question the SORT CARD created by the program in step1 could be of the following types based on some conditions:
Code:
SORT FIELDS=(541,10,CH,A,1,41,CH,A)
or
Code:
SORT FIELDS=(541,10,CH,A,1,41,CH,A)
INCLUDE COND=(541,3,CH,NE,C'111')
or
Code:
SORT FIELDS=(541,10,CH,A,1,41,CH,A)
INCLUDE COND=(541,3,CH,NE,C'111',AND,
541,3,CH,NE,C'123',AND,
541,3,CH,NE,C'126')
And there could be only 10 maximum conditions in the INCLUDE condition as these values could be populated from an array of maximum 10 elements , how can i form the sort code for step 2 to look something like based on conditons:
Code:
//SYSIN DD *
SORT FIELDS=(541,10,CH,A,1,41,CH,A)
/*
If i my SORT FIELDS has no include condition then how can i save the excluded records which means there will no exluded records.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon Jun 09, 2008 9:47 am Post subject:
Quote:
If i my SORT FIELDS has no include condition then how can i save the excluded records which means there will no exluded records.
Huh? If there are no excluded records, then how can you save them? If you just have a SORT statement with an OUTFIL INCLUDE statement, then only the included records will be written to the OUTFIL data set.
If you want to use OUTFIL statements and write all of the records to one data set and none of the records to another data set, you can use DFSORT control statements like this:
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Please let me know how we can form the SORT CODE to be used in Step 2 and there can be maximum 10 conditions in the Include statement as they get populated from an array of 10 elements.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon Jun 09, 2008 2:15 pm Post subject:
I don't know what you mean by "how we can form the SORT CODE to be used in Step 2".
If you have a program that is generating the SORT statement, just have it generate the OUTFIL statements as well. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
What i mean exactly is the step1 generates the SORT code which can be of different conditions , now i have to use a sort card formated to have OUTFIL statements in Step 2 for that how i can form the SORT code without doing in the program.
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
Posted: Tue Jun 10, 2008 3:15 am Post subject:
My interpretation is that you have a step that generates a sort control record and this can have 1 or more lines. These reocrds are writtne to a file which are then used as SYSIN in the sort step.You do not want to change the program (why?) to add an OUTFIL statement but want that added to the sort control records. Why do you not put the O~UTFIL statement into a separate file and concatenate it to the sort step's SYSIN? _________________ Utility and Program control cards are NOT, repeat NOT, JCL.
Thanks for your help so far.I am sorry and i am wrong in my understanding.Basically the SORT code created by the program will be of the format:
Code:
SORT FIELDS=(541,10,CH,A,1,41,CH,A)
INCLUDE COND=(541,3,CH,NE,C'111')
OR
SORT FIELDS=(541,10,CH,A,1,41,CH,A)
INCLUDE COND=(541,3,CH,NE,C'111',AND,
541,3,CH,NE,C'123',AND,
541,3,CH,NE,C'126')
OR
SOMETHING DIFFERENT
There could be maximum 10 different conditions in the INCLUDE COND as they get populated from an array.
Now my question is i want to use the dataset created by the program with SORT CODE as shown above and form a formatted SORT CODE as below which i can use as a SORT CODE in further step down , please help me how i can generate the formatted SORT CODE
and i do not want to change the program.
OR
SORT FIELDS=(541,10,CH,A,1,41,CH,A)
OUTFIL FNAMES=OUT1,INCLUDE=(541,3,CH,NE,C'111',AND,
541,3,CH,NE,C'123',AND,
541,3,CH,NE,C'126')
OUTFIL FNAMES=OUT2,SAVE
OR
SOMETHING DIFFERENT
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Tue Jun 10, 2008 11:47 am Post subject:
Here's a DFSORT job that will take the control statements generated by your program and convert them to the control statements you want. I'm assuming your program generates the DFSORT INCLUDE statement with 'INCLUDE COND=' starting in position 5.
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
Posted: Tue Jun 10, 2008 11:56 am Post subject:
That is much better, now an incomplete set of sort control cards are created in one step and they are then manipulated in a second step before being used in the third step. That is much better then admitting that the original program to produce the sort control cards needed to be changed.
Craig, while I understand your comment about changing the original program I could see some reason as why the original program should not be changed - one of the reasons could be that its a common program used in many places and this specific customization OUTFIL FNAMES=OUT2,SAVE may be applicable only in this JCL. You don't want to change all the other JCL's to have OUT2 dd name dummied out. Again, this is just my guess and may not be the actual reason by original poster...
What happens by Frank's code is it will not find any include cond and it will make OUT1 as empty dataset and OUT2 as a dataset with records exactly copied into OUT2 which is not the requirement for me.So what i have done is:
It is creating OUT1 with records as well as OUT2 with records but the SORT i guess is treating it in a different way and what is happening is if the input file has 100 records in this case where there were no include cond , OUT1 is having 100 records with lot of mismatches and OUT2 is having more than 100 records and i am really not sure why is this happening.Please help me to solve this problem.Is it because of the SORT FIELDS ? As per the logic OUT1 should have 100 records exactly as SORTIN has and OUT2 should be empty in this case.
Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
Posted: Mon Jul 14, 2008 10:25 am Post subject:
yadav2005,
If your input contained only
Code:
SORT FIELDS=(541,10,CH,A,1,41,CH,A)
, do you need to copy the entire file into one file? ie. OUT1 and Out2 would be an empty file? _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum