Rational Developer for System z, Version 7.6

Allocating a partitioned data set

This sample demonstrates how to programmatically allocate a partitioned data set with a particular set of data set characteristics.

Sample Scenario

Right-click the MVS™ Files subsystem for the appropriate connection and then select the API Sample Actions > Allocate PDS action.

Artwork for allocatePdsMenu

A sample partitioned data set is allocated. The name of the allocated data set is hardcoded in the action as the constant DATASET_NAME.

Artwork for allocatePdsResults

If the data set already exists, it is deleted and then reallocated. The following messages are sent to system output.

Artwork for allocatePdsConsole

Sample Code Walk-through

Checking for the Existence of a Data Set on the MVS File System

The run method of the sample starts by making sure that the data set it is about to create does not already exist. First, it obtains the ZOSCatalog for the MVS file system by calling getCatalog for the selected ISystemReference.

 ZOSCatalog catalog = getCatalog((ZOSSystemReference)selectedItem);

Once the ZOSCatalog has been obtained, its findMember method is invoked to see if a partitioned data set with the specified name already exists. If the data set exists already, the sample attempts to delete the existing data set, using the delete method. It is important to catch the OperationFailedException in case something goes wrong during the delete.

 ZOSPartitionedDataSet newPDS = null;
	......
	newPDS = (ZOSPartitionedDataSet)
		catalog.findMember(DATASET_NAME);
	if(newPDS != null){
		try {
			......
			newPDS.delete(true, null);
		} catch (OperationFailedException ofe) {
			System.err.println("Allocate PDS Action - PDS (" 
				+ DATASET_NAME + 
				") already exists and could not be deleted.");
			return;
		}
	}

Allocate the Partitioned Data Set

 IPhysicalResourceFactory physicalFactory = 
		PhysicalResourceFactoryFactory.getFactory(
		  ZOSCatalog.class, ZOSDataSet.class);
	......
	ZOSDataSet res = (ZOSDataSet)physicalFactory.getPhysicalResource(catalog,ZOSPartitionedDataSet.class,DATASET_NAME);
	res.setCharacteristics(getCharacteristics());
	try {
		res.allocate(null);
	} catch (OperationFailedException e) {
		System.out.println("Allocate PDS Action - PDS allocation failed" + e.getMessage());
	}

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)