Determine allocated file name

How to determine allocated file name in natural (giving workfile number)?

If you have Entire System Server (aka Natural Process) this is fairly easy. If you don’t, I don’t know of a way, unless you want to write an assembler routine and call it.

Very explaining :wink:

If you are not using ESS, you may have:

  • specified it in the JCL, then pass it on to the program. If passing on is a problem, parse the JCL if you know where it is located :twisted:

  • created it using the user-exit/dynamic allocation, then pass it on to the program needing it

I didn’t take the trouble to work it out earlier (because I’m lazy), but I ended up having to do something like this today. So here’s some code to find the dataset name for work file 1:

MOVE *INIT-USER  TO #JOB-NAME
FIND ALLOCATIONS WITH JOB-NAME = #JOB-NAME AND DDNAME = 'CMWKF01'
  DISPLAY DSNAME
END-FIND

Curtis,

Is this using ESS? We don’t have it so I don’t even know the fields of the ALLOCATIONS view. Using your code, wouldn’t you need additional criteria if you have multiple steps and if you have procs?

If there isn’t a USR routine to do it, you’ll have to write an assembler program.

Are you z/OS or z/VSE? (I’ll assume you aren’t BS2000/OSD. :smiley: )

I’ve got routines that you can use for either one.

My sample code does use ESS. ALLOCATIONS is one of the views provided by ESS. It reports the allocations of the currently executing step; you don’t have to provide step or proc information. (On the other hand, if you want to know about a step not currently executing, you’re out of luck.)

You can use USR1007

Hello florian_gaullier. Thanks for your input. I had asked pidipius’ question in a previous post but unfortunately we do not have ESS at our site.

I took a look at the SYSEXT sample program (we have Natural 4.13 installed) for USR1007 but didn’t see it returning the dataset name. “Device Name” is only 8 bytes long and is probably DDName. Here is the parameter layout used to call the module:

01 PARMS                    /*  PARAMETER LIST
   02 DEVICE-CLASS   (A08)  /*  IN/OUT : 'P'RINTER,'W'ORKFILE,'L'OGPRINT
   02 DEV-NO         (N02)  /*  IN     :  DEVICE NUMBER
   02 ERROR          (N04)  /*     OUT :  ERROR CODE
   02 ERROR-TEXT     (A72)  /*     OUT :  EXPLANATION TO ERROR CODE
   02 STAT-TX        (A32)  /*     OUT :  DEVICE STATUS TEXT
   02 STAT-CD        (A08)  /*     OUT :  DEVICE STATUS CODE
   02 SYSNO          (A03)  /*     OUT :  VSE EDITED SYS-NUMBER
   02 NUM            (N02)  /*     OUT :  PHYSICAL device number
   02 TYPE           (A08)  /*     OUT :  DEVICE TYPE
   02 NAME           (A08)  /*     OUT :  DEVICE NAME
   02 RECF           (A02)  /*     OUT :
   02 LEN            (P05)  /*     OUT :
   02 BLKS           (P05)  /*     OUT :

Do you have more info ? Thanks.