Posted: Mon Nov 10, 2003 2:50 pm Post subject: Sort - Dummy record
Hi,
I am extracting records from a very large flat file and trying to load them in to a VSAM file. I am extracting the records from the flat file based on a include condition. There might be cases where there are no records in the flat file which match the selection criteria. In these cases my VSAM file is going to be empty. Is there any way I can include a dummy record record i.e a record with spaces in to the VSAM file. I.e. I want a dummy record ( all spaces) to be the first record of my sort output. this way even if I dont find any record with my selection criteria I can still have one record.
For example:
Sort fields=copy
include cond=(34,5,ch,eq,c' ')
header=' '
I want all spaces record to be present at the top.
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Mon Nov 10, 2003 3:07 pm Post subject:
Can spaces be the key of your VSAM dataset? That is, can spaces be a valid key?
If no, then concat your input file with a dataset having one record full of spaces. For your include condition, code another condition in OR which will check for spaces at the columns of the key. _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon Nov 10, 2003 3:17 pm Post subject:
krk123,
You can include a dummy record with whatever you want as the first (or only) record by using the HEADER1 and REMOVECC parameters of DFSORT's OUTFIL statement. For example:
Code:
SORT FIELDS=COPY
INCLUDE COND=(...)
OUTFIL REMOVECC,HEADER1=(...)
If you want a blank header record, you can use:
Code:
OUTFIL REMOVECC,HEADER1=(X)
_________________ 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
Yes. Spaces record is okay on VSAM file.
The other option I had is to concat a file with only one record. ( spaces). I am copying 10 VSAM's each of different file layout. I was hesitating to use this method as I have to create 10 dummy 1 record files with different file layouts.
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Tue Nov 11, 2003 3:51 am Post subject:
krk,
I have been thinking about this post.
Did we (me and Frank) really answer your question? (Frank, I do not question your ability but, I feel, we missed a point here). Or, did I miss out anything?
When the INCLUDE condition results into an empty file, you still want atleast one record in the output VSAM file. Isn't this the requirement?
If yes, then both the solutions will result into the input file records (satisfying INCLUDE condition) plus one more record. When number of records satisfying INCLUDE condition is zero, then you have that blank record.
Did I miss out anything here? _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
Posted: Tue Nov 11, 2003 9:00 am Post subject:
Cogito-Ergo-Sum,
The use of header parm will always create a record with spaces even if the input include cond result in zero records.
I guess you are questioning about the extra record being created when the include condition is satisfied .Note that krk is okay with Spaces record in the VSAM file.
Hi Cogito,
Kolusu was right. I am looking for a dummy record ( record with spaces) always. Of course I can avoid the dummy record in cases where I find the records, but I fell this is a pretty long process as I have to check the return codes etc. So I am using OUTFIL REMOVECC,HEADER1=(X) always. This will create a dummy record even if there are records which match the selection criteria. This is just to avoid the program from abending when it opens the empty VSAM file.
Thanks a lot for your time and help.
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Tue Nov 11, 2003 9:23 am Post subject:
Quote:
I guess you are questioning about the extra record being created when the include condition is satisfied .
Correct, Kolusu.
Let us say, he is OK with the spaces record. This means, the key is spaces. Theoretically, his input file can have a record with a key value less than spaces AND also, satisfy the INCLUDE condition. In such a case, he will get the record with spaces but not as the first record.
I thought, he wanted a single record for priming purposes which will not what the above solutions do. If extra record is OK, then he will have the situation which I described in the previous para.
krk, have you factored these? _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
Posted: Tue Nov 11, 2003 9:34 am Post subject:
cogito,
Quote:
Let us say, he is OK with the spaces record. This means, the key is spaces. Theoretically, his input file can have a record with a key value less than spaces AND also, satisfy the INCLUDE condition. In such a case, he will get the record with spaces but not as the first record.
The use of HEADER parm will always create a record as the first record. So even though there are keys with less than spaces, the header record with spaces will be the first record coming out of sort.
In case KRK's file is a KSDS then the job will abend with OUT OF SEQUENCE error.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Tue Nov 11, 2003 11:11 am Post subject:
Cogito,
I assumed krk123 wanted the blank record as the first record even if other records were included.
Kolusu,
Note that the HEADER1 record will be the FIRST record regardless of the values of any keys. The HEADER1 record is added as the FIRST record BEFORE the sorted records. It does NOT participate in the sort. Likewise a TRAILER1 record is added AFTER the sorted records as the LAST record.
To put it another way, HEADER and TRAILER records are strictly output records. _________________ 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
The flat file I am using is a backup of PROD KSDS file. I dont have a case of having spaces in PROD. So I think one record with spaces is fine. In case if I have spaces on PROD file my job is going to fail with out of sequence error.
Hi Cogito, Thanks for your help and your time on this.
Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
Posted: Tue Nov 11, 2003 6:33 pm Post subject:
Frank,
I agree that using header parm will always create a record which is first for a flat file. But if it is a vsam file (KSDS) and if you have a key value less then spaces then the job will abend with out of sequence error.
But krk's is backing up a vsam file to a flat file , so there is no question of out of sequnce error.
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Wed Nov 12, 2003 12:40 pm Post subject:
Out of curiosity, I tried an experiment. I just wanted to know if "deleting" a record thru" DFSORT would make the HI-U-RBA non-zero. The answer is YES (as expected).
NOTE: The VSAM must be defined with REUSE and the options VSAMIO and RESET must be turned on for in-place sorting of a VSAM dataset. _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Last edited by Cogito-Ergo-Sum on Wed Nov 12, 2003 1:54 pm; edited 1 time in total
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