Examples of the allowmissing option with insufficient data for subfield arrays
Examples of the allowmissing option with insufficient data for subfield arrays
The following definitions are used in the examples
D employee DS QUALIFIED
D name 10A VARYING
D type 10A
D empInfo3 DS QUALIFIED
D emp LIKEDS(employee)
D DIM(3)
D empInfo2 DS QUALIFIED
D emp LIKEDS(employee)
D DIM(2)
D empInfo4 DS QUALIFIED
D emp LIKEDS(employee)
D DIM(4)
Assume that file emp.xml contains the following lines:
<employees>
<emp><name>Jack</name><type>Normal</type></emp>
<emp><name>Mary</name><type>Manager</type></emp>
<emp><name>Sally</name><type>Normal</type></emp>
</employees>
-
The empInfo3 data structure has an array emp with three elements. The allowmissing option is not required since the XML document also has three emp XML elements. The default of allowmissing=no can be used, since the XML document exactly matches the data structure.
xml-into empInfo3 %XML('emp.xml' : 'doc=file path=employees'); // empInfo3.emp(1) .name = 'Jack' .type = 'Normal' // empInfo3.emp(2) .name = 'Mary' .type = 'Manager' // empInfo3.emp(3) .name = 'Sally' .type = 'Normal' -
Option allowmissing=no may be specified, however.
xml-into empInfo3 %XML('emp.xml' : 'doc=file ' + 'allowmissing=no path=employees'); // empInfo3.emp(1) .name = 'Jack' .type = 'Normal' // empInfo3.emp(2) .name = 'Mary' .type = 'Manager' // empInfo3.emp(3) .name = 'Sally' .type = 'Normal' -
Option allowmissing=yes must be specified with data structure empInfo4, since the XML document has only three emp XML elements, and the RPG emp array has four elements.
xml-into empInfo4 %XML('emp.xml' : 'doc=file ' + 'allowmissing=yes path=employees'); // empInfo4.emp(1) .name = 'Jack' .type = 'Normal ' // empInfo4.emp(2) .name = 'Mary' .type = 'Manager ' // empInfo4.emp(3) .name = 'Sally' .type = 'Normal ' // empInfo4.emp(4) .name = '' .type = ' ' -
Option allowmissing is not specified for data structure empInfo4. The XML-INTO operation fails with status 00353 because the XML document does not have enough emp XML elements for the RPG array.
xml-into(e) empInfo4 %XML('emp.xml' : 'doc=file path=employees'); // %error = *on // %status = 353