MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sort - Dummy record
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
krk123
Beginner


Joined: 03 Jun 2003
Posts: 58
Topics: 19

PostPosted: Mon Nov 10, 2003 2:50 pm    Post subject: Sort - Dummy record Reply with quote

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.

Please let me know if I am not clear on this.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Mon Nov 10, 2003 3:07 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Nov 10, 2003 3:17 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
krk123
Beginner


Joined: 03 Jun 2003
Posts: 58
Topics: 19

PostPosted: Mon Nov 10, 2003 3:22 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
krk123
Beginner


Joined: 03 Jun 2003
Posts: 58
Topics: 19

PostPosted: Mon Nov 10, 2003 3:33 pm    Post subject: Reply with quote

Hi Frank,
I used OUTFIL REMOVECC,HEADER1=(X) and it worked exactly the way I wanted. Thanks a lot.

Hi Cogito, thanks for your help.

Krk123
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Nov 11, 2003 3:51 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Tue Nov 11, 2003 9:00 am    Post subject: Reply with quote

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.

The spaces record can be used as prime record.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
krk123
Beginner


Joined: 03 Jun 2003
Posts: 58
Topics: 19

PostPosted: Tue Nov 11, 2003 9:22 am    Post subject: Reply with quote

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.

Regards,
Krk123.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Nov 11, 2003 9:23 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Tue Nov 11, 2003 9:34 am    Post subject: Reply with quote

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.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Nov 11, 2003 11:11 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
krk123
Beginner


Joined: 03 Jun 2003
Posts: 58
Topics: 19

PostPosted: Tue Nov 11, 2003 2:10 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12377
Topics: 75
Location: San Jose

PostPosted: Tue Nov 11, 2003 6:33 pm    Post subject: Reply with quote

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.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Nov 11, 2003 11:58 pm    Post subject: Reply with quote

Oh OK!

Key value less than spaces will not make it to the KSDS as it will cause an out-of-sequence error.

Thanks everyone for your time for discussing this.
_________________
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.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Wed Nov 12, 2003 12:40 pm    Post subject: Reply with quote

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).

Here is the ICETOOL (of DFSORT) job that I used.

Code:

//STEP     EXEC PGM=ICETOOL,       
//            COND=(0,LT)           
//TOOLIN   DD *                     
 COPY FROM(IN01) TO(T1)   USING(CPY1)
 COPY FROM(T1)   TO(OT01)           
 SORT FROM(OT01) TO(OT02) USING(SRT1)
/*                                 
//IN01     DD *                     
KEY 1 ANG2                         
KEY 2 QFAH                         
KEY 3 FFFF                         
KEY 4 BBBB                         
KEY 5 KRUK                         
KEY 6 BBBB                         
/*                                 
//T1       DD DSN=&&TEMP001,       
//            DISP=(,PASS)         
//OT01     DD DSN=XXXXXXX.TEMP.KSDS,
//            DISP=OLD             
//OT02     DD DSN=XXXXXXX.TEMP.KSDS,
//            DISP=OLD             
//CPY1CNTL DD *                     
 OUTFIL FNAMES=T1,                 
        INCLUDE=(7,4,CH,EQ,C'ZZZZ'),
        REMOVECC,                   
        HEADER1=(X)                 
/*                                 
//SRT1CNTL DD *                     
 OPTION VSAMIO,RESET               
 SORT   FIELDS=(1,5,CH,A)           
 OMIT   COND=(1,5,CH,EQ,C' ')       
/*                                 
//DFSMSG   DD SYSOUT=*             
//TOOLMSG  DD SYSOUT=*             
//*                                 


LISTC info at define and 0 records:

Quote:

ALLOCATION
SPACE-TYPE------CYLINDER HI-A-RBA---------7372800
SPACE-PRI-------------10 HI-U-RBA---------------0
SPACE-SEC--------------0


After "delete":

Quote:

ALLOCATION
SPACE-TYPE------CYLINDER HI-A-RBA---------7372800
SPACE-PRI-------------10 HI-U-RBA----------737280
SPACE-SEC--------------0


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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group