Table of Contents
This appendix describes the DCB Handling API methods used to output or modify attributes of DDs allocated in JCL.
You can use the DCB Handling API provided with OpenFrame to search for or modify attribute information about allocated DDs in JCL and execute dynamic allocation in applications.
To write a program using the DCB Handling API, you must include the tdch.h header file, which is distributed with the OpenFrame binary, in the user program, and link the libtdcb.so library during compilation.
The Tmax DCB Handling API can be classified as follows:
Allocation Handle
API | Description |
---|---|
Retrieves the DCB information allocated by a JCL DD statement by giving the DD name. | |
Discards the allocation information returned by the tdcb_get_handle() API. | |
Outputs the allocation information returned by the tdcb_get_handle() API. |
DCB Information
API | Description |
---|---|
Retrieves the DCB type and the number of sequential concatenations. | |
Retrieves the maximum and average lengths of logical records. | |
Retrieves the DSORG and RECFM attributes of a non-VSAM data set. |
Get Attributes
API | Description |
---|---|
Retrieves the data set name and member name. | |
Retrieves the volume serial information of a data set. | |
Retrieves other miscellaneous attributes of a data set. | |
Retrieves the block size and record length of a data set. | |
Retrieves the key location and key length of a data set. | |
Retrieves the type and AIX attribute of a VSAM data set. |
Set Attributes
API | Description |
---|---|
Sets the logical record length of a data set. | |
Sets the RECFM attribute of a data set. | |
Sets the block size of a data set. | |
Sets the key location and key length of a data set. |
Dynamic Allocation
API | Description |
---|---|
Executes dynamic allocation for a data set. | |
Concatenates multiple data sets using a handle returned by tdcb_allocate(). | |
Executes deallocation for the data set on which tdcb_allocate() was executed for dynamic allocation. |
Retrieves or finds the DCB information allocated by a JCL DD statement by giving the DD name. If the tdcb_get_handle() API is executed, some DCB information, which is organized in the shared memory by JCL, is reorganized in the local memory area to allow for later access.
If allocation information is successfully retrieved, the allocation handle is returned, not a negative number. The returned allocation handle is subsequently used for DCB information querying or attribute modifying functions.
Prototype
int tdcb_get_handle(char *ddname);
Parameter
Parameter | Description |
---|---|
ddname (IN) | DD name of the allocation information to retrieve. |
Return Value
If allocation information is retrieved successfully, the allocation handle is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Discards the allocation information retrieved through the tdcb_get_handle() API. In other words, the DCB information built in the local memory area is discarded. Therefore, the tdcb_get_handle() API must be called again to get back the DCB information of the same DD.
It is not necessary to discard the allocation information obtained through the tdcb_get_handle() API, but if this API is repeatedly called for the same DD, an error message is displayed warning that the DD information is already organized in the local memory area.
If a DD, whose allocation information is not released by the tdcb_discard_handle() API in a C module, is opened in a COBOL module, the same warning message appears because an API similar to the tdcb_get_handle() API is called internally.
Prototype
int tdcb_discard_handle(int handle);
Parameter
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Prints the allocation information returned by the tdcb_get_handle() API.
The printed allocation information includes the following details:
DD_Name, JOB_Name, Allocation_Date, Allocation_Time, Concatenation_Count + [Sequence_Number] Slot_Number, DCB_Type, DCB_Name, DISPOSITION
Prototype
int tdcb_print_info(int handle);
Parameter
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Retrieves the DCB type and the number of sequential concatenations from the allocation information, which was returned by the tdcb_get_handle() API.
The following macros for the DCB types are defined in the tdcb.h header file:
#define TDCB_DCB_TYPE_NONE 0x00 /* Unknown */ #define TDCB_DCB_TYPE_NVSM 0x01 /* Non-VSAM */ #define TDCB_DCB_TYPE_TSAM 0x02 /* VSAM */ #define TDCB_DCB_TYPE_ISAM 0x03 /* ISAM */
The OpenFrame system provides a method to combine two or more non-VSAM data sets, which can be searched contiguously like a single data set. This is called sequential concatenation. The number of sequential concatenations represents the number of connected data sets.
The OpenFrame system does not support sequential concatenation of VSAM data sets. If the DCB type is TSAM, the 'count' parameter is not the number of sequential concatenations, but the total number of base clusters and alternate indexes that are connected to them.
Prototype
int tdcb_get_type(int handle, int *dcb_type, int *count);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
dcb_type (OUT) | Buffer to store the DCB type of the given allocation information. |
count (OUT) | Buffer to store the number of sequential concatenations or the number of base clusters and alternate indexes. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Retrieves the maximum and average lengths of logical records from the allocation information returned by the tdcb_get_handle() API.
For non-VSAM data sets that are not sequentially concatenated or are of fixed length, the maximum and average record lengths are identical. However, in the case of sequentially concatenated non-VSAM data sets or variable length VSAM data sets, the lengths can be different.
For variable length non-VSAM data sets, the record length is the LRECL value that is set when allocating the data set in JCL. This is the logical record length including the length of the RDW.
Prototype
int tdcb_maxlrecl(int handle, int *maxlrecl, int *avglrecl);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
maxlrecl (OUT) | Buffer to store the maximum logical record length of the given allocation information. |
avglrecl (OUT) | Buffer to store the average logical record length of the given allocation information. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Retrieves the DSORG and RECFM attributes of the non-VSAM data set from the allocation information, which was returned by the tdcb_get_handle() API.
The DSORG attribute of non-VSAM data sets specifies the organization of the data set. Available values for DSORG are as follows:
DSORG | Description |
---|---|
PS(Physical Sequential) | SAM data set. |
IS(Indexed Sequential) | ISAM data set. |
PO(Partitioned) | PDS or PDSE. |
DA(Direct) | DAM data set. |
The RECFM attribute of non-VSAM data sets specifies the format or characteristic of the record. Available values for RECFM are as follows:
RECFM | Description |
---|---|
F | Fixed-length record |
V | Variable-length record |
L | Line sequential record |
U | Undefined record |
B | Block unit I/O |
A | ANSI control character included |
For example, if a data set supports fixed-length records and I/O in units of blocks, its RECFM attribute is specified as RECFM=FB. And if a data set is made of variable length records and includes ANSI control characters, its RECFM attribute is specified as RECFM=VA.
For sequentially concatenated non-VSAM data sets, the first data set's DSORG and RECFM attributes are returned. (In principle, mainframe does not allow sequential concatenation between non-VSAM data sets that have different basic attributes.)
For VSAM data sets, depending on the length type, DSORG=PS and RECFM=FB are returned for fixed length records and DSORG=PS and RECFM=VB for variable length records.
To retrieve the DSORG attribute from the allocation information, a string buffer pointer of 8 bytes or more in size must be specified as the 'dsorg' parameter. To retrieve the RECFM attribute, a string buffer pointer of eight bytes or more in size must be specified in the 'recfm' parameter. If a user string buffer is specified, the DSORG and RECFM attributes are copied to the user buffer with a NULL terminating character.
Prototype
int tdcb_nvsm_info(int handle, char *dsorg, char *recfm);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
dsorg (OUT) | Buffer to store the DSORG attribute of the given allocation information. |
recfm (OUT) | Buffer to store the RECFM attribute of the given allocation information. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Retrieves the data set name and member name of a DCB component from the allocation information which was returned by the tdcb_get_handle() API. The DCB component represents a data set in the allocation information of sequentially concatenated non-VSAM data sets, or a base cluster or an alternate index in the VSAM allocation information.
To retrieve the allocated data set name, specify a string buffer pointer of at least 45 bytes in the 'dsname' parameter. This string buffer pointer is then copied to the user buffer with a NULL terminating character added.
You can retrieve the name of a PDS or PDSE data set member only. To retrieve the name, specify a string buffer pointer of at least 9 bytes in the 'member' parameter. The string buffer pointer is then copied to the user buffer with a NULL terminating character added.
Prototype
int tdcb_get_dsname(int handle, int index, char *dsname, char *member);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
index (IN) | Sequence number of a sequential concatenation or the specified number of a base cluster or alternate index. |
dsname (OUT) | Buffer to store the data set name of the DCB component. |
member (OUT) | Buffer to store the member name of the DCB component. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Retrieves the volume serial information of a DCB component from the allocation information that was returned by the tdcb_get_handle() API. The DCB component represents a data set in the allocation information of sequentially concatenated non-VSAM data sets, or a base cluster or an alternate index in the VSAM allocation information.
To retrieve the volume serial information of the allocated DCB component, specify a string buffer pointer of at least 9 bytes in the 'volser' parameter. The string buffer pointer is then copied to the user buffer with a NULL terminating character added.
Prototype
int tdcb_get_volser(int handle, int index, char *volser);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
index (IN) | Sequence number of a sequential concatenation or the specified number of a base cluster or alternate index. |
volser (OUT) | Buffer to store the volume serial information of the DCB component. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Retrieves various miscellaneous attributes or flags of a DCB component from the allocation information returned by the tdcb_get_handle() API. The DCB component represents a data set in the allocation information of sequentially concatenated non-VSAM data sets, or a base cluster or an alternate index in the VSAM allocation information.
The DCB component's various miscellaneous attributes represent the following macros defined in the tdcb.h header file:
#define TDCB_LRECL_NOT_SET 0x01 #define TDCB_RECFM_NOT_SET 0x04 #define TDCB_BLKSIZE_NOT_SET 0x08 #define TDCB_KEYLEN_NOT_SET 0x40 #define TDCB_IS_TAPE_DATASET 0x10 #define TDCB_IS_OPEN_INDICATOR 0x20
Descriptions for each macro are as follows:
Macro | Description |
---|---|
TDCB_LRECL_NOT_SET | Logical record length of a data set is not set in a catalog or JCL. |
TDCB_RECFM_NOT_SET | RECFM attribute of a data set is not set in a catalog or JCL. |
TDCB_BLKSIZE_NOT_SET | Block size of a data set is not set in a catalog or JCL. |
TDCB_KEYLEN_NOT_SET | Key length of a data set is not set in a catalog or JCL. |
TDCB_IS_TAPE_DATASET | A data set that is allocated to the tape volume device. |
TDCB_IS_OPEN_INDICATOR | The OPEN API has not yet been called in an application program. |
Prototype
tdcb_get_flags(int handle, int index, int *flags);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
index (IN) | Sequence number of a sequential concatenation or the specified number of a base cluster or alternate index. |
flags (OUT) | Buffer to store the miscellaneous attributes of the DCB component. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Retrieves the block size and record length of a DCB component from the allocation information returned by the tdcb_get_handle() API. The DCB component represents a data set in the allocation information of sequentially concatenated non-VSAM data sets, or a base cluster or an alternate index in the VSAM allocation information.
For variable length non-VSAM data sets, the record length is the LRECL value that is set when allocating the data set in JCL. This is the logical record length including the length of the RDW is used.
If the record length information of the allocated DCB component is not necessary, set the 'reclen' parameter to NULL.
Prototype
int tdcb_get_blksize(int handle, int index, int *blksize, int *reclen);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
index (IN) | Sequence number of a sequential concatenation or the specified number of a base cluster or alternate index. |
blksize (OUT) | Buffer to store the block size of the DCB component. |
reclen (OUT) | Buffer to store the record length of the DCB component. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Retrieves the key location and key length from the allocation information returned by the tdcb_get_handle() API. The DCB component represents a data set in the allocation information of sequentially concatenated non-VSAM data sets, or a base cluster or alternate index in the VSAM allocation information.
If the key information of the allocated DCB component does not exist (for example, when the allocated data set is a non-VSAM data set and its DSORG is PS or PO), 0 is returned for the key location and key length.
Prototype
int tdcb_get_key_info(int handle, int index, int *keypos, int *keylen);
Parameter
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
index (IN) | Sequence number of a sequential concatenation or the specified number of a base cluster or alternate index. |
keypos (OUT) | Buffer to store the key location of the DCB component. |
keylen (OUT) | Buffer to store the key length of the DCB component. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Retrieves the VSAM data set type and AIX attribute of a VSAM DCB component from the allocation information returned by the tdcb_get_handle() API. The DCB component represents a data set in the allocation information of sequentially concatenated non-VSAM data sets, or a base cluster or an alternate index in the VSAM allocation information.
The following macros are defined for VSAM data set types in the tdcb.h header file:
#define TDCB_VSAM_TYPE_ESDS 0x01 /* ESDS */ #define TDCB_VSAM_TYPE_KSDS 0x02 /* KSDS */ #define TDCB_VSAM_TYPE_RRDS 0x04 /* RRDS */ #define TDCB_VSAM_TYPE_VRDS 0x05 /* VRDS */
The following macros are defined for the AIX attribute in the tdcb.h header file.
#define TDCB_RGATTR_EAIX 0x01 #define TDCB_RGATTR_KAIX 0x02 #define TDCB_RGATTR_UPGRADE 0x04
Descriptions for each macro are as follows:
Macro | Description |
---|---|
TDCB_RGATTR_EAIX | The VSAM DCB component is an alternate index of ESDS. |
TDCB_RGATTR_KAIX | The VSAM DCB component is an alternate index of KSDS. |
TDCB_RGATTR_UPGRADE | The alternate index component has the UPGRADE attribute. |
Prototype
int tdcb_get_vsamtype(int handle, int index, int *vsamtype, int *rgattr);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
index (IN) | Sequence number of a sequential concatenation or the specified number of base cluster or alternate index. |
vsamtype (OUT) | Buffer to store the VSAM data set type of the VSAM DCB component. |
rgattr (OUT) | Buffer to store the AIX attribute of the VSAM DCB component. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Sets the logical record length of a DCB component in the allocation information returned by the tdcb_get_handle() API. The DCB component here represents a data set in the allocation information of sequentially concatenated non-VSAM data sets.
Before setting the logical record length by using the tdcb_set_lrecl() API, it is recommended to check that the DCB component's logical record length is already set in a catalog or JCL by using the tdcb_get_flags() API .
For variable length non-VSAM data sets, the record length is set when allocating the data set in JCL. This is the logical record length including the length of the RDW.
Prototype
int tdcb_set_lrecl(int handle, int index, int lrecl);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
index (IN) | Sequence number of a sequential concatenation of non-VSAM data sets or 0. |
lrecl (IN) | Logical record length to specify in the DCB component. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Sets the RECFM attribute of a specified DCB component in the allocation information returned by the tdcb_get_handle() API. The DCB component here represents a specified data set in the allocation information of sequentially concatenated non-VSAM data sets.
Before setting the RECFM attribute by using the tdcb_set_recfm() API, it is recommended to check that the DCB component's RECFM attribute is already specified in a catalog or JCL by using the tdcb_get_flags() API.
Prototype
int tdcb_set_recfm(int handle, int index, char *recfm);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
index (IN) | Sequence number of a sequential concatenation of non-VSAM data sets or 0. |
recfm (IN) | RECFM attribute to specify in the DCB component. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Sets the block size of a DCB component in the allocation information returned by the tdcb_get_handle() API. The DCB component here represents a data set in the allocation information of sequentially concatenated non-VSAM data sets.
Before setting the block size by using the tdcb_set_blksize() API, it is recommended to check that the DCB component's block size is already specified in a catalog or JCL by using the tdcb_get_flags() API.
Prototype
int tdcb_set_blksize(int handle, int index, int blksize);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
index (IN) | Sequence number of a sequential concatenation of non-VSAM data sets or 0. |
blksize (IN) | Block size to specify in the DCB component. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Sets the key length and key location of a DCB component in the allocation information returned by the tdcb_get_handle() API. The DCB component here represents a data set in the allocation information of sequentially concatenated non-VSAM data sets.
Before setting the key length and key location by using the tdcb_set_keylen() API, it is recommended to check that the DCB component's key length is already specified in a catalog or JCL by using the tdcb_get_flags() API.
Prototype
int tdcb_set_keylen(int handle, int index, int keylen, int keyoff);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by the tdcb_get_handle() API. |
index (IN) | Sequence number of a sequential concatenation of non-VSAM data sets or 0. |
keylen (IN) | Key length to specify in the DCB component. |
keyoff (IN) | Key location to specify in the DCB component. |
Return Value
If successful, 0 is returned. If an error occurs, -1 is returned with an error message. An error code is displayed in the message as needed.
Allows an application to execute dynamic allocation on a data set, which is not defined through JCL, to access the data set.
Once dynamic allocation is executed on a data set using tdcb_allocate(), OPEN and I/O can be performed on the data set.
Prototype
int tdcb_allocate(char *ddname, char *ddparam, int flags);
Parameters
Parameter | Description |
---|---|
ddname (IN) | DD name. |
ddparam (IN) | DD attributes specified as a string. Each attribute is delimited by a comma (,).
|
flags (IN) | Option for allocation.
|
Return Value
If allocation is successful, the allocation handle is returned. If an error occurs, the function that caused the error is output as a message, and a negative OpenFrame error code is returned. To check the error code, use the oferror command.
Concatenates a data set to the DD statement using a handle returned by tdcb_allocate().
Prototype
int tdcb_concatenate(int handle, char *ddparam, int flags);
Parameters
Parameter | Description |
---|---|
handle (IN) | Handle returned by tdcb_allocate(). |
ddparam (IN) | DD attributes specified as a string. Each attribute is delimited by a comma (,).
|
flags(IN) | Option for concatenation.
|
Return Value
If successful, 0 is returned. If an error occurs, the function that caused the error is output as a message, and a negative OpenFrame error code is returned. To check the error code, use the oferror command.
Closes a data set on which dynamic allocation was executed using tdcb_allocate(), and then executes deallocation on the data set. The oferror command shows an error code.
Prototype
int tdcb_unallocate(int handle, int disp, int flags);
Parameters
Parameter | Description |
---|---|
handle (IN) | Allocation handle returned by tdcb_allocate(). |
disp (IN) | Specifies whether normal or abnormal termination.
|
flags (IN) | Option for deallocation.
|
Return Value
If successful, 0 is returned. If an error occurs, the function that caused the error is output as a message, and a negative OpenFrame error code is returned. To check the error code, use the oferror command.