The XMLCHAR built-in function dumps data from a structure as XML into a buffer. It returns a size_t 1 value that indicates the number of bytes written to the buffer. If the buffer is too small, the structure data is truncated and the number of bytes needed for the buffer to contain the structure is returned.
>>-XMLCHAR--(--x--,--p--,--n--)--------------------------------><
The structure-reference x must conform to the following rules:
The buffer length must be nonnegative and must have a computational type. The buffer length is converted to type size_t.
When the XML output is created, it follows these rules:
This example is based on the following code fragment:
dcl buffer char(800);
dcl written fixed bin(31);
dcl next pointer;
dcl left fixed bin(31);
dcl
1 a,
2 a1,
3 b1 char(8),
3 b2 char(8),
2 a2,
3 c1 fixed bin,
3 c2 fixed dec(5,1);
b1 = ' t1';
b2 = 't2';
c1 = 17;
c2 = -29;
next = addr(buffer);
left = stg(buffer);
written = xmlchar( a, next, left );
next += written;
left -= written;
The following bytes would be written to the buffer, and written would be set equal to 72.
<A><A1><B1>t1</B1><B2>t2</B2></A1><A2><C1>17</C1><C2>-29.0</C2></A2></A>