Input File Missing? Create it!



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

Input File Missing? Create it!

Postby Eagle » Thu Feb 14, 2013 2:11 am

Hello,

I'd like to know if I can use SyncSORT to check if a file exists. If the file does not exist, create it. If it already exists, copy it to a new dataset name. The purpose of doing this would be to generate in input file for my COBOL program in the next job step regardless if the input file exists or not. I can do this in multiple job steps using IDCAMS, but I was hoping to see if SyncSORT had similar functionality that can accomplish this in one step.

Input file attributes:
Record length = 500 bytes
Fixed length

I attempted to do something like this, but I received the following error:
"SORTIN - DATA SET NOT FOUND".

Any information you can provide would be greatly appreciated.
- Eagle -
User avatar
Eagle
 
Posts: 8
Joined: Thu Nov 04, 2010 8:11 pm
Has thanked: 5 times
Been thanked: 0 time

Re: Input File Missing? Create it!

Postby Robert Sample » Thu Feb 14, 2013 2:19 am

Would COBOL's SELECT OPTIONAL help you?

These users thanked the author Robert Sample for the post:
Eagle (Thu Feb 14, 2013 3:11 am)
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Input File Missing? Create it!

Postby Akatsukami » Thu Feb 14, 2013 2:28 am

Note that allocation is done for data sets specified in JCL by JES before the job begins to execute. However, you can do what I think you want to by referencing the data set in a step with a status of MOD.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day

These users thanked the author Akatsukami for the post:
Eagle (Thu Feb 14, 2013 9:35 pm)
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Input File Missing? Create it!

Postby Alissa Margulies » Thu Feb 14, 2013 9:07 pm

Hello Eagle.

Akatsukami is on the right track. Here is a sample Sort job that will not modify an existing data set, but will create it if it does not yet exist:
//STEP1 EXEC PGM=SORT                           
//SORTIN  DD DUMMY,DCB=(RECFM=FB,LRECL=500)     
//SYSOUT  DD SYSOUT=*                           
//SORTOUT DD DSN=DATA.SET.NAME,DISP=(MOD,CATLG),
//  SPACE=(CYL,(5,1),RLSE),UNIT=SYSDA       
//SYSIN   DD *                                 
  SORT FIELDS=COPY                           
/*

Hope this helps.

Regards,
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com

These users thanked the author Alissa Margulies for the post:
Eagle (Thu Feb 14, 2013 9:35 pm)
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 3 times

Re: Input File Missing? Create it!

Postby Akatsukami » Thu Feb 14, 2013 9:30 pm

Welcome back, Ms. Margulies :)
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Input File Missing? Create it!

Postby Eagle » Thu Feb 14, 2013 10:07 pm

Thank you ALL for your input.

Perhaps there is another way using SyncSort to check if File A exists. If it exists, copy File A (LRECL=500) to new File B (LRECL=500). If File A does not exist, create File B as a blank file with LRECL=500.

I tried using Rober'ts recommended COBOL SELECT OPTIONAL feature because of security reasons. I am writing code under one system that reads a file from another system. I do not have authority to write a file that does not exist from the other system. In my JCL, I changed my input file disposition to DISP=MOD. Now, when my program executes, I receive a file attribute mismatch error. The input file fromt he other system does not exist, so COBOL throws a File Status 39 error:

IGZ0201W A file attribute mismatch was detected. File SLS-ORDRS-LOAD-FILE in program XMSXAC01 had a record length of
500 and the file specified in the ASSIGN clause had a record length of 80.

How would I change the record length from 80 to 500 of a file that does not exist? I posted this here because Robert Sample had replied with this solution, however, I realize this is no longer a SyncSort issue. I will post this to a different forum, if necessary, however, I welcome a SyncSort solution as well!

Again, I appreciate your time.

Thanks!
- Eagle -
User avatar
Eagle
 
Posts: 8
Joined: Thu Nov 04, 2010 8:11 pm
Has thanked: 5 times
Been thanked: 0 time

Re: Input File Missing? Create it!

Postby Eagle » Fri Feb 15, 2013 2:06 am

I was able to resolve the file mismatch error by coding DISP=MOD,LRECL=500

However, I was hoping to be able to distinguish between an 'empty' input file and a non-existent input file. That way I could inform the end user which scenario actually occurred. Since I coded the MOD above, I believe the file is temporarily created with an LRECL of 500, which allows the COBOL to obtain a successful file open (Status Code '00') and a successful read (Status Code '00'). I was expecting to get a Status Code '05' since the file did not exist before the step ran, which would allow me to definitively notify the user that the input did not exist. But alas, I'll simply notify the user that the input file either did not exist or was empty. If I don't use MOD, I get a JCL error. Catch 22, I guess.

Thanks again!
- Eagle -
User avatar
Eagle
 
Posts: 8
Joined: Thu Nov 04, 2010 8:11 pm
Has thanked: 5 times
Been thanked: 0 time

Re: Input File Missing? Create it!

Postby Robert Sample » Fri Feb 15, 2013 2:56 am

A file status 05 code in COBOL will occur if -- and only if -- the file does not have a DD statement in the JCL, and it is coded as SELECT OPTIONAL in COBOL. Once you define the file in the JCL with DISP=MOD, the file exists as far as COBOL is concerned since it was allocated by JES before the COBOL program executed.

These users thanked the author Robert Sample for the post:
Eagle (Fri Feb 15, 2013 6:13 pm)
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Input File Missing? Create it!

Postby BillyBoyo » Fri Feb 15, 2013 5:11 am

What starts off your job? The arrival of the file from the other system?

If you want to know whether a dataset is catalogued, you can use IDCAMS LISTCAT, and set a return-code so that you can establish the outcome for step(s) in a JOB. Using IDCAMS PRINT you can, if the file exists, "print" one record, which will tell you if the dataset contains data or not, and set a return-code...

Sort can also do the "counting-and-return-code", but if you are using IDCAMS you could do them both at the same time.

I hope that the file contains a header, with at least the business/data date, and hopefuly a "logical filename". A trailer, with record count, hash counts for key fields. Then when the file is processed, all of this can be verified. An "empty" file coming from your other system should contain a header/trailer but no data. Then you know that if you receive an actual empty file, something has "gone up the swanee...".

These users thanked the author BillyBoyo for the post:
Eagle (Fri Feb 15, 2013 6:13 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post