DATA Step, Macro, Functions and more

Dataset-Abfragen unter z/OS: DSN da? DSN leer? / English: Dataset under z/OS exists? Dataset is empty?

Accepted Solution Solved
Reply
N/A
Posts: 1
Accepted Solution

Dataset-Abfragen unter z/OS: DSN da? DSN leer? / English: Dataset under z/OS exists? Dataset is empty?

Hello!

I want to distriute some coding to our users. they shouldt be able to test, in batchjobs on z/OS, if a simple sequential file exists. 

Furthermore  they should be able to test if that existing dataset is empty .

This question is not posted fpr SAS-Datasets/-libraries, but for z/OS Datasets

I'm thinking about something like the  %SYSFUNC statement.

Thank you for help or information!

Engelbert Smets

Hallo!

Ich möchte unseren Benutzern eine Möglichkeit bieten im Batchjob unter z/OS

abzufragen, ob

- eine Datei, z.B. zugeordnet über JCL oder filename, exitiert

- eine Datei, z.B. zugeordnet über JCL oder filename, exitiert, aber leer ist.

Wohlgemerkt, es handelt sich dabei nicht um eine SAS-DAtei, sondern um ander übliche z/OS-Dateien.

Im Hinterkopf denke ich da an %SYSFUNC oder so etws.

Vielen Dank für Unterstützung!

Engelbert Smets


Accepted Solutions
Solution
‎12-14-2013 04:20 PM
Super User
Super User
Posts: 7,078

Re: Dataset-Abfragen unter z/OS: DSN da? DSN leer? / English: Dataset under z/OS exists? Dataset is empty?

Posted in reply to PEP3_Team

FILEEXIST() should be able to test if a file exists.  You could also try using the FOPEN() function.

An easy way to test if a file has zero records is to read it.  For example this will set the macro variable EMPTY to 1 when there are no records in the file referenced by the filename (or DD name on MVS) of MYFILE.

%let empty=0;

data _null_;

    if eof then call symputx('EMPTY','1');

    infile MYFILE  end=eof ;

   stop;

run;

View solution in original post


All Replies
SAS Super FREQ
Posts: 709

Re: Dataset-Abfragen unter z/OS: DSN da? DSN leer?

Posted in reply to PEP3_Team

Die Chance eine Antwort zu bekommen, ist viel grösser wenn die Frage auf English gestellt wird.

SAS stellt die FILEEXIST und FEXIST zur Verfügung. Mit diesen Funktionen kann geprüft werden ob ein File existiert.

Um festzustellen, ob das File leer ist, muss man das File lesen, zum Beispiel mit dem DATA Step

Trusted Advisor
Posts: 3,215

Re: Dataset-Abfragen unter z/OS: DSN da? DSN leer? / English: Dataset under z/OS exists? Dataset is empty?

Posted in reply to PEP3_Team

Mit das Deutsch wurde ich auch auskommen. De meiste guten Handbücher und Internet Seiten sind
aber im English.  Lassen wir es zum English halten.

JCL (Job Control Language) and dataset access at the z/OS mainframe are behaving very different ot what is common at Windows or Unix.

That is:

- You cannot put an non-existing dataset into JCL

   JES-2 is skipping the job before something has run.   (first JCL-step)

- The locking on datasets is very strict organized by the use of the DISP (OLD NEW SHR).

  There are exceptions ont some types like PDS-E  or using the HFS naming approach like common in UNIX.

  That last approach is very unusual for the oldies of mainframes but it is possibe as the kernal is there.       

- Jobs that are run by a scheduler (eg TWS) normally require the verfivying of time and datasets being used/.

SAS has dedicated manual for specific Mainframe SAS language: SAS(R) 9.3 Companion for z/OS, Second Edition (DSNexist)

What are your options (You have to check with your IT support):

- bypass the TWS requirements and code SAS like the DSNexist sample

- use the TWS verifying/trigger whether a dataset exist. normally as a trigger from an other job. 

- Build a first step in the JCL that check the dataset dynamically and you next JCL-Steps being executed conditionally

- use a HFS-datasetname.

- Use the PDS-E approach als members in a shared library are not checked as long as you do not give mebernames

- use dummy-datasets with  zero records to have valid datasetnames for the JCL-JEs2 step

- Use concatenation of datasets with a default empty datset to be overwritten

- With the SAS input function use the file-var  filename option to check the real datasetname

When the goal is a collection of inputdatsets I would advice a PDS-E setup up as VBS with a lrecl of 32Kn (maximum) and a blocksize of half-track 3390.

That is the closest to the suequential way of thinking at Unix/Windos.

A Unix type (HFS) approach would be even easier but very hard to get done when your IT staff does not want you to help with that.        

---->-- ja karman --<-----
Solution
‎12-14-2013 04:20 PM
Super User
Super User
Posts: 7,078

Re: Dataset-Abfragen unter z/OS: DSN da? DSN leer? / English: Dataset under z/OS exists? Dataset is empty?

Posted in reply to PEP3_Team

FILEEXIST() should be able to test if a file exists.  You could also try using the FOPEN() function.

An easy way to test if a file has zero records is to read it.  For example this will set the macro variable EMPTY to 1 when there are no records in the file referenced by the filename (or DD name on MVS) of MYFILE.

%let empty=0;

data _null_;

    if eof then call symputx('EMPTY','1');

    infile MYFILE  end=eof ;

   stop;

run;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 595 views
  • 3 likes
  • 4 in conversation