This sample demonstrates how to programmatically allocate a partitioned data set with a particular set of data set characteristics.
Right-click the MVS™ Files subsystem for the appropriate connection and then select the API Sample Actions > Allocate PDS action.

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

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

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;
}
}
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());
}