%DATA (document {:options})
%DATA is used as the second operand of the DATA-INTO operation code to specify the document to be parsed, and the options to control how the information from the document is placed in the target RPG variable. %DATA does not return a value, and it cannot be specified anywhere other than for the DATA-INTO operation code.
The first operand of %DATA specifies the document to be parsed. It can be a constant or variable character or UCS-2 expression containing either an document or the name of a file containing a document.
optionname1=value1 optionname2=value2
'doc=file allowextra=yes'
' doc=file allowextra=yes '
'ALLOWEXTRA=YES DOC=FILE '
'AllowExtra=Yes Doc=File '
Option string | The problem with the option string |
---|---|
'doc = file' | Spaces around the equal sign are not allowed |
'allowextra' | Each option must have an equal sign and a value |
'badopt=yes' | Only valid options are allowed |
'allowextra=ok' | The 'allowextra' value can only be 'yes' or 'no' |
See %DATA options for the DATA-INTO operation code for a complete list of valid options and values.
'doc=file doc=string'
then the parser will
use the value "string" for the "doc" option.If the parser discovers an invalid option or invalid value, the operation will fail with status code 00352.
Examples of %DATA
document = 'city=Toronto';
DATA-INTO city %DATA(document) %PARSER(p);
DATA-INTO myds %DATA(document : 'allowmissing=yes allowextra=yes')
%PARSER(p);
ccsidOpt = 'ccsid=ucs2';
DATA-INTO %HANDLER(mySaxHandler : myCommArea)
%DATA('mydoc.txt' : 'doc=file ' + ccsidOpt)
%PARSER(p);
For more examples of %DATA, and more information about the DATA-INTO operation, see DATA-INTO (Parse a Document into a Variable).