|
On Apr 25, 2017, at 7:33 PM, Jon Paris <jon.f.paris@xxxxxxxxx> wrote:
You are right of course Barbara - I was rushing and did not test it.
Now that I know it has to run on V7.1 I have reworked it and a
"working" version can be found here:
https://code.midrange.com/59b2271b6f.html
By "tested" I mean that it processes the XML without errors - but has not been tested beyond the scope of the date in the program.
As soon as I get my V7.3 system updated to the latest PTFs I'll add a version using the directly nested ds.
Jon Paris
jon.f.paris@xxxxxxxxx
On Apr 25, 2017, at 5:45 PM, Barbara Morris <bmorris@xxxxxxxxxx> wrote:
On 2017-04-25 3:53 PM, Jon Paris wrote:
I _think_ my version is right - but not tested - if I have time I'll
do that because it needs a couple of count fields by the look of it
(for OptionalChannelData for example).
Jon, I think your version needs a few corrections
- The DIM should be on Channel, not Channels
- ChannelID, Readings, OptionalChannelDatas should be subfields of
Channel, not of Channels
- the DIM should be on OptionalChannelData, not OptionalChannelDatas
I think this is closer, but it's also untested ... sorry ...
I added a few "count" subfields for the repeated elements. I also added a few names on the END-DS's. It seems useful when the end of the data structure is a long way from the beginning.
dcl-ds MeterReadingDocument Qualified; dcl-ds ImportExportParameters;
CreateResubmitFile char(n);
dcl-ds DataFormat;
DSTTransitionType char(n);
ReadingTimestamp char(n);
end-ds;
end-ds;
dcl-ds Channels;
countChannel int(10);
dcl-ds Channel dim(nn);
ReadingsInPulse char(n);
IsRegister char(n);
IsReadingDecoded char(n);
MarketType char(n);
dcl-ds ChannelID;
EndPointChannelID char(n);
end-ds;
dcl-ds Readings;
countReading int(10);
dcl-ds Reading dim(nn);
Value char(n);
ReadingTime char(n);
end-ds;
end-ds;
dcl-ds OptionalChannelDatas;
countOptionalChannelData int(10);
dcl-ds OptionalChannelData dim(nn);
Name char(n);
Value char(n);
end-ds;
end-ds;
end-ds Channel;
end-ds Channels;
end-ds MeterReadingDocument;
To get the Channel data the XML-INTO would look like this:
XML-INTO MeterReadingDocument.Channels
%XML(XMLFile: 'doc=file +
datasubf=data +
countprefix=count +
path=MeterReadingDocument/Channels +
case=any');
Then use MeterReadingDocument.Channels.countChannel to find out how many Channel elements there were.
Mike, if you only want the Channel info, it might be better just to code the Channels DS at the top level, and not bother about the other stuff before the Channels info.
dcl-ds Channels qualified;
countChannel int(10);
dcl-ds Channel dim(nn);
ReadingsInPulse char(n);
IsRegister char(n);
IsReadingDecoded char(n);
MarketType char(n);
dcl-ds ChannelID;
EndPointChannelID char(n);
end-ds;
dcl-ds Readings;
countReading int(10);
dcl-ds Reading dim(nn);
Value char(n);
ReadingTime char(n);
end-ds;
end-ds;
dcl-ds OptionalChannelDatas;
countOptionalChannelData int(10);
dcl-ds OptionalChannelData dim(nn);
Name char(n);
Value char(n);
end-ds;
end-ds;
end-ds Channel;
end-ds Channels;
Then the XML-INTO would look like this:
XML-INTO Channels
%XML(XMLFile: 'doc=file +
datasubf=data +
countprefix=count +
path=MeterReadingDocument/Channels +
case=any');
Then use Channels.countChannel to find out how many Channel elements there were.
--
Barbara
--
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: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at
http://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 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.