Joined: 20 Aug 2005 Posts: 27 Topics: 6 Location: MN
Posted: Fri Oct 07, 2005 8:32 am Post subject: Pick First , Middle and Last but one Records from File
Hi,
I have an input dataset ,whose count of records change every day . That is, the number of records in this dataset is not a constant. I want to extract the first ,middle and the 'last but one' record of this data set on a daily basis.The problem here is only with selecting the middle record as the count of records is not a constant.I have two options.But i am confused as to how to proceed with those.
Options:
1)Will i be able to divide the value got in the count parameter of sort utility by 2 and use it in a sort card to pick the required middle record.
2)Can i use a splitby option of outfile and use count/2 as a parameter for splitby .
Can someone suggest how can i proceed with any of those two options.
Thanks,
Deepthi
Joined: 20 Aug 2005 Posts: 27 Topics: 6 Location: MN
Posted: Fri Oct 07, 2005 9:21 am Post subject:
Thanks for the quick reply.For odd number of records it can be either (n+1)/2 or (n-1)/2. Moreoever ,if dataset has only one record,i want these steps in the job which selects three records to be overrided . I know ,empty datasets can be detected using Idcams and fileaid etc,Is there any similar way where a single record file can be identified . If so,i can use it to override these steps, when an single record dataset is an input, just by using COND=(RC,NE,STEPnumber) in my next step. _________________ Thanks,
Deepthi.
Our lives begin to end the day we become silent about things that matter.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Oct 07, 2005 10:08 am Post subject:
Quote:
Is there any similar way where a single record file can be identified . If so,i can use it to override these steps, when an single record dataset is an input, just by using COND=(RC,NE,STEPnumber) in my next step.
You could use the COUNT operator of DFSORT's ICETOOL:
COUNT FROM(IN) EQUAL(1)
This will give you RC=12 if IN has 1 record or RC=0 if it doesn't.
Similarly:
COUNT FROM(IN) NOTEQUAL(1)
will give you RC=0 if IN has 1 record or RC=12 if it doesn't. _________________ 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: 20 Aug 2005 Posts: 27 Topics: 6 Location: MN
Posted: Fri Oct 14, 2005 5:24 am Post subject:
Thanks Kolusu and Frank for your great solutions. And sorry for the delay in reply too.
Kolusu,
I am not clear about the syntax of AVG and MAX.Could you please explain me the Syntax of AVG=(1,8,ZD,M11,LENGTH=5) and MAX=(10,8,ZD,M11,LENGTH=5). That would be of great help.
Note: I have changed the length to 5 to suit my requirements. _________________ Thanks,
Deepthi.
Our lives begin to end the day we become silent about things that matter.
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Fri Oct 14, 2005 5:48 am Post subject:
Deepthi,
The syntax of AVG command is AVG=(start_pos, length, format, output_format, output_length)
Code:
AVG=(1,8,ZD,M11,LENGTH=5)
In the above code, you are trying to find the average of some field which is available in columns 1-8 and stored in ZD (Zoned Decimal) format. ZD is nothing but your COBOL S9(nn)V9(nn).
M11 is a pre-defined Edit mask. It is equivalent to specifying EDIT=(TTTTTT...T) where T is similar to COBOL '9'. And you force the output to be Length 5. (EDIT=(TTTTT)). Character 'I' in EDIT mask is equivalent to COBOL 'Z' (Zero Suppressor).
The same is the case with MAX operator.
Please let me know if I am not clear / if you need more information.
Thanks,
Phantom
Last edited by Phantom on Fri Oct 14, 2005 7:44 am; edited 1 time in total
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Fri Oct 14, 2005 7:54 am Post subject:
Deepthi,
There is a small change in my previous post. 'T' actually is equivalent to COBOL 9 and 'I' is equivalent to cobol 'Z'. I have corrected it. Please see the data highlighted in bold.
Joined: 20 Aug 2005 Posts: 27 Topics: 6 Location: MN
Posted: Fri Oct 14, 2005 11:09 pm Post subject:
Phantom,
Thanks a lot for that !! I was not aware of those .
Kolusu,
I noticed that in my input dataset ,the sequence number of records are already present in the first five positions.Hence, i felt there is no need of using the SEQNUM and thus modified your solution to generate a sortcard .Below is the job that i used to generate the sortcard.
I used this sortcard in the next step to get my required output.This job went fine and i got the required results.
Moreover,I understood the solution provided by you earlier clearly.I submitted ur job as it is, only changes being the record length ,as my input record length is 71,and the job abended with - ABEND S013 REASON=00000020.But i couldn't trace the reason for the above abend. Could you please let me know. _________________ Thanks,
Deepthi.
Our lives begin to end the day we become silent about things that matter.
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Sat Oct 15, 2005 11:53 am Post subject:
Deepthi,
S013 Abend due the following reasons.
Code:
Forgot the DCB information, or used the wrong DCB information.
BLKSIZE does not match the file blocksize.
BLKSIZE is not a multiple of LRECL.
PDS member name can not be found.
1. Try removing the BLKSIZE=0 from the SPACE parameter of your output file. Actually you don't have to code DCB for SORTOUT. Sort takes it automatically. So, better leave it to its discretion.
2. Do you have the sort card as a PDS Member or have you used an Inline sort card. If you have given that as a PDS Member then check whether the member name specified in the JCL is correct.
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
Posted: Sat Oct 15, 2005 2:36 pm Post subject:
Quote:
I used this sortcard in the next step to get my required output.This job went fine and i got the required results.
Deepthi,
Not exactly true. Your requirement was to get the "last but one" record along with the first and middle records. Your solution will get the "Last" record, unless the sequence number in your file starts with a zero. Starting a seqnum from zero isn't that common.
Quote:
I submitted ur job as it is, only changes being the record length ,as my input record length is 71,and the job abended with - ABEND S013 REASON=00000020.But i couldn't trace the reason for the above abend. Could you please let me know.
It would be easy for us to pinpoint the exact error if you have posted the SYSOUT error messages.
Well if my memory serves right , you get an error S013 when DCB parameters are off. I guess you created the SYMNAMES input with lrecl of 71 . A SYMNAMES DD statement data set must have the following attributes: RECFM=F or RECFM=FB and LRECL=80.
The only changes in the JCL posted by me are in the second step(STEP0200).
Joined: 20 Aug 2005 Posts: 27 Topics: 6 Location: MN
Posted: Tue Oct 18, 2005 3:04 am Post subject:
Phantom/Kolusu,
Thanks much for your responses.Phantom,I had problems with the code that Kolusu had posted in the beginning.I guess, you provided me solutions based on the code i had posted.But still,i really thank you for providing me the possible reasons for the abend and next time,i get a S013 abend,i will definitely try to remember those possibilities.
Actually,the mistake was in the record length of the SYMNAMES DD statement dataset.Since i was not aware of the attributes,I had changed the record length for the same to 71. I submitted the original job(by Kolusu) now with the right attributes for SYMNAMES dataset and the job ran fine.
Quote:
Your requirement was to get the "last but one" record along with the first and middle records. Your solution will get the "Last" record, unless the sequence number in your file starts with a zero. Starting a seqnum from zero isn't that common
I had put the requirement in the beginning that i need last but one record.This requirement came into picture because,last record in the input dataset always comprised of zeros.The sort card i created ,checked for the maximum value in the first five digit field ,and in this case,that happens to be the last but one record only.And because of this,the sort card i created ,fulfilled my requirement and picked up the last but one record.
I really thank you both and Frank too for making me gain a lot through this. _________________ Thanks,
Deepthi.
Our lives begin to end the day we become silent about things that matter.
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