Specifying data types for application programs

You can specify the data type that an application program expects in a given field by specifying the DATATYPE parameter in the FIELD statement that defines the field to the DBD Generation utility.

When the DATATYPE keyword is specified, a data type converter transforms the field data returned by IMS from the binary data type that IMS stores the physical data in to the data type specified on the DATATYPE parameter.

For each DATATYPE specification, IMS automatically selects a compatible IMS-provided data-type converter. If the data-type converter selected by IMS does not fit your needs exactly, you can select the data-type converter yourself, or you can provide your own custom data-type converter. Specify the IMS-provided data-type converters on the INTERNALTYPECONVERTER parameter or a custom data-type converter on the USERTYPECONVERTER parameter. Both parameters are specified in the DFSMARSH statement.

When specifying a data type, you must ensure that the byte length of the field supports the data type. Some data types require a specific field length. For example, if you specify DATATYPE=LONG, you must define the length of the field as eight bytes by specifying BYTES=8.

If no data type is specified, the default data type returned to an application program is determined by the value of the TYPE parameter. If TYPE=C is specified or defaulted to, the default application data type is CHAR. For all other specifications of the TYPE parameter, the default application data type is BINARY.

You can define additional characteristics of your data type selections, such as the character encoding, date and time formats, and decimal types, by specifying additional parameters on the DFSMARSH statement.

Examples of the DFSMARSH statement

The following series of examples show some possible uses of the DFSMARSH statement for various DATATYPE and type converter specifications.

DATATYPE=DATE:
FIELD    EXTERNALNAME=XDATE,         
         BYTES=8,                    
         START=84,                   
         DATATYPE=DATE               
DFSMARSH ENCODING=Cp1047,            
         INTERNALTYPECONVERTER=CHAR, 
         PATTERN='MMddyyyy'
DATATYPE=TIME:
FIELD    EXTERNALNAME=XTIME,        
         BYTES=6,                   
         START=92,                  
         DATATYPE=TIME              
DFSMARSH ENCODING=Cp1047,           
         INTERNALTYPECONVERTER=CHAR,
         PATTERN='HHmmss'      
DATATYPE=TIMESTAMP:
FIELD    EXTERNALNAME=XTIMESTAMP,   
         BYTES=16,                  
         START=84,                  
         DATATYPE=TIMESTAMP         
DFSMARSH ENCODING=Cp1047,           
         INTERNALTYPECONVERTER=CHAR,
         PATTERN='MMddyyyyHHmmssff'  
DATATYPE=ZONEDDECIMAL:
FIELD NAME=ORDPRICE,                        
         BYTES=10,                          
         START=21,                          
         DATATYPE=DECIMAL(10,2)             
DFSMARSH INTERNALTYPECONVERTER=ZONEDDECIMAL,
         ISSIGNED=Y                         
DATATYPE=PACKEDDECIMAL:
FIELD    EXTERNALNAME=XPACKEDDEC1,           
         BYTES=4,                            
         START=60,                           
         DATATYPE=DECIMAL(7,2)               
DFSMARSH INTERNALTYPECONVERTER=PACKEDDECIMAL,
         ISSIGNED=Y                          
USERTYPECONVERTER=:
FIELD    EXTERNALNAME=PACKEDDATEFIELD, 
         BYTES=5,
         START=40,
         DATATYPE=DATE                                             
DFSMARSH USERTYPECONVERTER=class://com.ibm.ims.dli.types.PackedDateConverter, 
         PROPERTIES=(pattern=MMddyyyy,isSigned=false)