Rules for transferring data to RPG variables for XML-INTO and DATA-INTO
Rules for transferring data to RPG variables for XML-INTO and DATA-INTO
-
For integer, unsigned, decimal (packed, zoned, binary) and float fields, the data will be transferred using the same rules as RPG uses for %INT, %UNS, %DEC, %FLOAT. %INTH, %UNSH, and %DECH will be used if the Half-Adjust operation extender is specified on the DATA-INTO or XML-INTO operation code. See Rules for converting character values to numeric values using built-in functions for more information on how options *ALWBLANKNUM and *USEDECEDIT for Control keyword EXPROPTS affect the way the data is processed.
-
For date, time and timestamp fields, the data will be transferred using the same rules as RPG uses for %DATE, %TIME, and %TIMESTAMP. The format defaults to *ISO with separators.
The format may be specified by an attribute fmt in the element. The value of the attribute must be one of the valid formats for the respective built-in function; the leading asterisk is optional. For formats that allow more than one separator in RPG, the separator defaults to the RPG default separator for the format. For example, for a date field, the following XML fragments are valid:
<myDate fmt="DMY/">25/12/04</myDate> <!-- 2004-12-25 --> <myDate fmt="Dmy">25.12.04</myDate> <!-- 2004-12-25 --> <myDate fmt="*cymd0">0971123</myDate> <!-- 1997-11-23 --> -
For indicator, character and UCS-2 fields, data will be transferred with appropriate CCSID conversion if necessary. Fixed-length fields will be assigned left-adjusted by default.
The adjustment can be specified by an attribute adjust in the element, with a value of either “left” or “right”. For example, if the RPG variable data is 10 bytes long, the following XML data will cause the value of DATA to be set to
'␢␢␢␢␢abcde'.<data adjust="right">abcde</data> -
For graphic fields, data will be transferred using the same rules as the %GRAPH built-in function, with appropriate CCSID conversion if necessary. Fixed-length fields will be assigned left-adjusted by default. The adjustment can be specified by an attribute adjust in the element, with a value of either “left” or “right”.
-
Pointer and procedure-pointer subfields are not supported, and are ignored by the DATA-INTO and XML-INTO operations.
-
The special attributes fmt and adjust will be treated as ordinary attributes if they are not relevant to the assignment of the matching variable, or if the value of the attribute is not valid. For example, the following attributes would be treated as ordinary attributes:
‘fmt=“abc”’ : “abc” is not a valid format.
‘adjust=yes’ : “yes” is not a valid value for the adjust attribute.
‘fmt=“mdy/”’, if specified for a numeric field
‘adjust=right’, if specified for a varying-length field.
-
The attributes fmt and adjust and their values must be specified in the case specified by the case option. The following table shows valid examples of the attributes for each value of the case option.
| case option | fmt, example “*MDY/“ | adjust, example “right” |
|---|---|---|
| not specified | rpgle fmt="mdy/" fmt="*mdy/" | adjust=“right“ |
| ‘case=lower’ | rpgle fmt="mdy/" fmt="*mdy/" | adjust=“right“ |
| ‘case=upper’ | rpgle fmt="MDY/" fmt="*MDY/" | ADJUST=“RIGHT“ |
| ‘case=any’ | rpgle Fmt="Mdy/" FMT="*mDY/" ... | rpgle Adjust="Right" adjust="RIGHT" ... |