The information in this article applies to:
Product: MIM and PM4Data
Version: 8.x
Platform: z/OS
Discussion
This article discusses the interfaces for dynamic allocation when using XMScript. There are 2 ways to invoke the internal dynamic allocation routines: the XMDynamicAllocation class and the XMFile class.
- The XMScript Programming Guide describes XMFile as follows:
XMFile provides a cross-platform, multi-language, high-performance interface to file systems, databases, and WebSphere MQ resources, among others. Using a simple and easy to use programming interface, XMFile allows seamless integration and access to any supported data source, regardless of underlying platform dependencies, data source vendor dependencies, or application needs. XMFile provides both stream and record based interfaces, allowing applications to interact with a data source using a stream-oriented or record-oriented approach. This means regardless of the underlying data source or format (i.e. database records, WebSphere MQ messages, Open Systems stream files), the application determines how the data is accessed and read or written. With all of these benefits, XMFile is ideal for all cross-platform, multi-data source integration needs.
- XMDynamicAllocation is an XMCOM-enabled class that provides the ability to dynamically allocate datasets on z/OS.
When do you use the XMDynamicAllocation class?
If you are using XMFile to allocate a new dataset, then you should use XMFile exclusively. There is no need to explicitly use XMDynamicAllocation class. (example 1)
If you want to allocate a new dataset and you are not using XMFile, then you can use the Dynamic Allocation class to allocate the dataset. (example 2)
Example 1 allocates the file, opens it in write mode, and then closes it.
Example 1: XMFile main() \{ // Test the XMFile dynamic allocation attributes var xmoPolicy = XMObject::create("Policy"); // File xmoPolicy.setMetadata("type", "file"); xmoPolicy.name = "SYSMAG.TST.RLSE2"; xmoPolicy.File.convert = "yes"; // Dynamic Allocation var xmoDynamicAllocation = XMObject::create("Dataset"); xmoDynamicAllocation.SUNIT = "TRK"; xmoDynamicAllocation.PRIMARY = "10"; xmoDynamicAllocation.SECONDARY = "1"; xmoDynamicAllocation.DISP = "NEW"; xmoDynamicAllocation.DSNAME = "SYSMAG.TST.RLSE2"; xmoDynamicAllocation.BLKSIZE = "0"; xmoDynamicAllocation.DSORG = "PS"; xmoDynamicAllocation.LRECL = "80"; xmoDynamicAllocation.RECFM = "FB"; xmoDynamicAllocation.UCBTYPE = "D"; xmoDynamicAllocation.DEVICE = "SYSDA"; xmoPolicy.File.insert(xmoDynamicAllocation); cout << "Policy: " << xmoPolicy << endl; cout << "Creating XMFile instance..." << endl; var writeFile = new XMFile(xmoPolicy, XMFile::writeMode, XMFile::record); cout << "Opening file..." << endl; writeFile.open(); cout << "Closing file..." << endl; writeFile.close(); return(0); \}
Example 2 uses the XMDynamicAllocation class outside of the XMFile class.
Example 2: XMDynamicAllocation main() \{ // Test the XMDynamicAllocation attributes var xmoDynamicAllocation = XMObject::create("Dataset"); xmoDynamicAllocation.SUNIT = "TRK"; xmoDynamicAllocation.PRIMARY = "10"; xmoDynamicAllocation.SECONDARY = "1"; xmoDynamicAllocation.DISP = "NEW"; xmoDynamicAllocation.DSNAME = "SYSMAG.TST.RLSE3"; xmoDynamicAllocation.BLKSIZE = "0"; xmoDynamicAllocation.DSORG = "PS"; xmoDynamicAllocation.LRECL = "80"; xmoDynamicAllocation.RECFM = "FB"; xmoDynamicAllocation.UCBTYPE = "D"; xmoDynamicAllocation.DEVICE = "SYSDA"; cout << "Policy: " << xmoDynamicAllocation << endl; cout << "Creating XMDynamicAllocation instance..." << endl; var xmda = new XMDynamicAllocation(); var rc = xmda.allocate(xmoDynamicAllocation); if (rc != 0) \{ cout << "Failed to execute allocate, rc = " << rc << endl; \} else \{ cout << "Successfully executed allocate." << endl; \} return(0); \}