× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Sean,

To provide a balance to my slightly flippant remark re COBOL long names ....

I can see how it would be unwieldy to try to use that long qualified name a
lot in your subsequent code.

If that is what concerns you, here are two alternatives - both illustrated
below:


1. Create two separate variables based on pointers, initialise their
address to the DS subfields and use those names going forwards
2. Overlay the DS with some more fields using the POS keyword to put
them in the right place and use those names going forwards

Essentially this amounts to the same thing - two variable pointing to the
same memory address:

e.g: From my second example:

Dcl-S XMLDoc VarChar( 512 );

Dcl-DS docID Qualified Template;
ProprietaryDocumentIdentifier Char( 26 );
End-Ds;

Dcl-DS genDate Qualified Template;
datetimestamp Char( 26 );
End-Ds;

Dcl-DS ASN Qualified;
thisDocumentGenerationDateTime LikeDS( genDate );
thisDocumentIdentifier LikeDS( docID );
doc Char( 26 ) Pos( 1 );
date Char( 26 ) Pos( 27 );
End-Ds;

Dcl-S ID Char( 26 ) Based( pID );
Dcl-S GDate Char( 26 ) Based( pGDate );

pID = %Addr( ASN.thisDocumentIdentifier.ProprietaryDocumentIdentifier );
pGDate = %Addr( ASN.thisDocumentGenerationDateTime.datetimestamp );

XMLDoc = '<ASN>'
+ '<thisDocumentGenerationDateTime>'
+ '<DateTimeStamp>19.03.2018 08:50:55</DateTimeStamp>'
+ '</thisDocumentGenerationDateTime>'
+ '<thisDocumentIdentifier>'
+ '<ProprietaryDocumentIdentifier>87323619.03.2018
08:50:55</ProprietaryDocumentIdentifier>'
+ '</thisDocumentIdentifier>'
+ '</ASN>';

Xml-Into ASN
%Xml( XMLDoc : 'path=ASN case=any allowmissing=yes' );

So you could do either approach ( don't do both! I was just showing you an
example )

But now you can either use ASN.doc and ASN.date

or plain old ID and GDate

To refer to those long fields.

regards,
Craig





On 23 March 2018 at 15:51, <SCOURTNEY@xxxxxxxxxxx> wrote:

Thanks a million Craig and Barbara ...

I read a load of documentation but nothing stated that I needed to use the
original element tags ..

Just tried it out and eureka ...

Thanks ...




-----Ursprüngliche Nachricht-----
Von: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im Auftrag von Craig
Richards
Gesendet: Friday, 23 March 2018 16:48
An: RPG programming on the IBM i (AS/400 and iSeries)
Betreff: Re: RPGLE XML-INTO

Well ok, since I did most of it already - here is how you could do it in
one xml-into:

Dcl-S XMLDoc VarChar( 512 );

Dcl-DS docID Qualified Template;
ProprietaryDocumentIdentifier Char( 26 );
End-Ds;

Dcl-DS genDate Qualified Template;
datetimestamp Char( 26 );
End-Ds;

Dcl-DS ASN Qualified;
thisDocumentGenerationDateTime LikeDS( genDate );
thisDocumentIdentifier LikeDS( docID );
End-Ds;

XMLDoc = '<ASN>'
+ '<thisDocumentGenerationDateTime>'
+ '<DateTimeStamp>19.03.2018 08:50:55</DateTimeStamp>'
+ '</thisDocumentGenerationDateTime>'
+ '<thisDocumentIdentifier>'
+ '<ProprietaryDocumentIdentifier>87323619.03.2018
08:50:55</ProprietaryDocumentIdentifier>'
+ '</thisDocumentIdentifier>'
+ '</ASN>';

Xml-Into ASN
%Xml( XMLDoc : 'path=ASN case=any allowmissing=yes' );

regards,

Craig

On 23 March 2018 at 15:32, Craig Richards <craig@xxxxxxxxxxxxxxxx> wrote:

Sean,

You need to make sure at the level you path to that your xml elements
match the data structure subfield names.

here is an example using 2 separate xml-into with your data.

You could do it with one xml-into if you build a more nest
datastructure but you'd need to match more subfield names to the xml
elements:

I'm not staying this is the best way to parse that document, I'm a bit
pressed for time but this example will show you something that works


Dcl-S XMLDoc VarChar( 512 );

Dcl-DS thisDocId_T;
ProprietaryDocumentIdentifier Char( 26 );
End-Ds;

Dcl-DS docGenDate_T;
datetimestamp Char( 26 );
End-Ds;

Dcl-DS ASN Qualified;
docGenDate LikeDS( docGenDate_T );
thisDocid LikeDS( thisDocId_T );
End-Ds;

XMLDoc = '<ASN>'
+ '<thisDocumentGenerationDateTime>'
+ '<DateTimeStamp>19.03.2018 08:50:55</DateTimeStamp>'
+ '</thisDocumentGenerationDateTime>'
+ '<thisDocumentIdentifier>'
+ '<ProprietaryDocumentIdentifier>87323619.03.2018
08:50:55</
ProprietaryDocumentIdentifier>'
+ '</thisDocumentIdentifier>'
+ '</ASN>';

Xml-Into ASN.docGenDate
%Xml( XMLDoc : 'path=ASN/thisDocumentGenerationDateTime
case=any allowmissing=yes' );

Xml-Into ASN.thisDocid
%Xml( XMLDoc : 'path=ASN/thisDocumentIdentifier case=any
allowmissing=yes' );

regards,
Craig


On 23 March 2018 at 14:36, <SCOURTNEY@xxxxxxxxxxx> wrote:

Hello all,



I am playing around with XML-INTO and for some reason cannot get this
example to work :

I keep getting : RNX0353 The XML document does not match the RPG
variable;



Example XML



<ASN>

<thisDocumentGenerationDateTime>

<DateTimeStamp>19.03.2018
08:50:55</DateTimeStamp>

</thisDocumentGenerationDateTime>

<thisDocumentIdentifier>

<ProprietaryDocumentIdentifier>87323619.03.2018
08:50:55</ProprietaryDocumentIdentifier>

</thisDocumentIdentifier>

</ASN>



RPG CODE





d ASN ds qualified

d docGenDate LikeDS(docGenDate_T)

d thisDocid LikeDS(thisDocId_T )



*-----------------------------------------

* thisdocumentgenerationdatetime

*-----------------------------------------

d docGenDate_T ds

d datetimestamp 26

*-----------------------------------------

* thisdocumentidentifier

*-----------------------------------------

d thisDocId_T ds

* proprietarydocumentidentifier

d docId 26



XML-INTO ASN %XML(XML_Source: 'doc=file +

case=any +

allowmissing=yes');



Any help would be greatly appreciated.





Mit freundlichen Grüßen / Kind regards / Bien à vous,



Sean





--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email:
RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list
options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our
affiliate
link: http://amzn.to/2dEadiD



--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD

--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.