I have several input fields with xml format. Each field is having format like <Delimiter>Field value</Delimiter>. So I have fields namely, msgid,sysid,src,and msgtyp for which I have devloped below SORT card for it. <<Please dont go in detail for FINDREP part as I have shown to understand skip of the general header part of XML>>
OPTION COPY
INREC FINDREP=(INOUT=(C'<?xml version="1.0msg>',C'', -
C'</message>',C''))
OUTREC PARSE=(%01=(STARTAFT=C'<msgid>',ENDBEFR=C'</msgid>',FIXLEN=10),
%02=(STARTAFT=C'<sysid>',ENDBEFR=C'</sysid>',FIXLEN=10),
%03=(STARTAFT=C'<src>',ENDBEFR=C'</src>',FIXLEN=10),
%04=(STARTAFT=C'<msgtyp>',ENDBEFR=C'</msgtyp>',FIXLEN=10)),
BUILD=(%01,21:%02,31:%03,41:%04)
INREC FINDREP=(INOUT=(C'<?xml version="1.0msg>',C'', -
C'</message>',C''))
OUTREC PARSE=(%01=(STARTAFT=C'<msgid>',ENDBEFR=C'</msgid>',FIXLEN=10),
%02=(STARTAFT=C'<sysid>',ENDBEFR=C'</sysid>',FIXLEN=10),
%03=(STARTAFT=C'<src>',ENDBEFR=C'</src>',FIXLEN=10),
%04=(STARTAFT=C'<msgtyp>',ENDBEFR=C'</msgtyp>',FIXLEN=10)),
BUILD=(%01,21:%02,31:%03,41:%04)
and this will work perfectly fine for the order sequence of xml delimiters as, msgid ==> sysid ==> src ==> msgtyp then only.
If the delimiter order sequence is changed then it yields with wrong output. e.g. msgid ==> sysid ==> msgtyp ==>src
or
src ==> sysid ==> msgid ==> msgtyp
or any combination other than "msgid ==> sysid ==> src ==> msgtyp" this order sequence.
Can any one suggest me for this SORT card working for all the order sequences that will be a great help. Cause in XML format input its not mandate all the fields will be there in the input records, say some input records might have all the 4 fields with delimiters and some records may have only field with delimiter or two field with 2 delimiters likewise.