× 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.



OK - this probably won't format well but ... this code works using the sample XML I created from your spec.

That said - this is more an exercise to show others what can be done because the definition of the document you have is - well - humongous. In the end, even when just handling one order, I had to cut the array sizes down. Do you really need 999 repeats of something 5 levels down? That is an insane document. I thought I'd seen some crazy ones from the insurance industry but this is on another level.

I haven't added counts so that the actual number of repeating elements can be determined. I'll add that if anyone is interested.

Anyway - here's the working program based on the DS definition in your posts.

// Data Structure Template for single occurence of Order
Dcl-Ds ORDERS_T Template Qualified;
BUYERPO CHAR(20);
Dcl-Ds STORER;
Dcl-Ds LOADUNITDETAIL Dim(9);
LOADUNITDETAILID Zoned(4);
Dcl-Ds PACKIDH;
Dcl-Ds PACKIDD Dim(9);
Dcl-Ds PACKIDSUBDETAIL Dim(9);
QTY Zoned(22:5);
Dcl-Ds SKU Dim(9);
OD_SKU Char(25);
Dcl-Ds PICKDETAIL Dim(9);
Dcl-Ds LOTATTRIBUTE Dim(9);
End-Ds;
End-Ds;
End-Ds;
End-Ds;
End-Ds;
End-Ds;
End-Ds;
End-Ds;
End-Ds;

dcl-s xmlfile varchar(100);
dcl-s ordercount int(10);

xmlfile = '/Home/Paris/XMLstuff/Kevins.xml';

XML-INTO %HANDLER(ProcessOrders : OrderCount)
%XML(xmlfile : 'path=root/ORDERS +
case=any +
allowextra=yes allowmissing=yes +
doc=file');


*inlr = *on;
Return;

Dcl-Proc ProcessOrders;
Dcl-Pi *N Int(10);
OrderCount Int(10);
Orders LikeDS(Orders_T) Dim(1) Const;
Elements Int(10) Value;
end-pi;

OrderCount += Elements; // Increment count by qty passed this time
Dsply ('Processing order ' + Orders(1).BUYERPO );
Dsply (%Char(OrderCount) + ' processed so far');

// Actual processing of individual elements goes here

Return 0;

end-proc ProcessOrders;


And here is the XML I used - which may not be exactly the same as yours because there were a contradiction or two in your examples. I also had to add a <root> element because I didn't have the name for yours.

<?xml version="1.0" encoding="UTF-8"?>
<root>
<LOADHDR>Stuff here</LOADHDR>
<LOADSTOP>More stuff</LOADSTOP>
<ORDERS>
<BUYERPO>Buyer PO 1</BUYERPO>
<STORER>
<LOADUNITDETAIL>
<LOADUNITDETAILID>1</LOADUNITDETAILID>
<PACKIDH>
<PACKIDD>
<PACKIDSUBDETAIL>
<QTY>1</QTY>
<SKU>
<OD_SKU>Skunumber 1</OD_SKU>
<ORDERDETAIL>
<PICKDETAIL>
<LOTATTRIBUTE />
</PICKDETAIL>
</ORDERDETAIL>
</SKU>
</PACKIDSUBDETAIL>
</PACKIDD>
</PACKIDH>
</LOADUNITDETAIL>
</STORER>
</ORDERS>
<ORDERS>
<BUYERPO>Buyer PO 2</BUYERPO>
<STORER>
<LOADUNITDETAIL>
<LOADUNITDETAILID>2</LOADUNITDETAILID>
<PACKIDH>
<PACKIDD>
<PACKIDSUBDETAIL>
<QTY>2</QTY>
<SKU>
<OD_SKU>Skunumber 2</OD_SKU>
<ORDERDETAIL>
<PICKDETAIL>
<LOTATTRIBUTE />
</PICKDETAIL>
</ORDERDETAIL>
</SKU>
</PACKIDSUBDETAIL>
</PACKIDD>
</PACKIDH>
</LOADUNITDETAIL>
</STORER>
</ORDERS>
</root>
Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Aug 31, 2018, at 1:10 PM, Kevin Grimes <kevin_grimes@xxxxxxxxx> wrote:

The DS is looking like this. I don't need that many fields from it but everything is nested and this results in more than 16mb.

Dcl-Ds LOADHDR;
Dcl-Ds LOADSTOP;
Dcl-Ds ORDERS Dim(99);
BUYERPO CHAR(20);
Dcl-Ds STORER;
Dcl-Ds LOADUNITDETAIL Dim(99);
LOADUNITDETAILID Zoned(4);
Dcl-Ds PACKIDH;
Dcl-Ds PACKIDD Dim(99);
Dcl-Ds PACKIDSUBDETAIL Dim(999);
QTY Zoned(22:5);
Dcl-Ds SKU Dim(999);
Dcl-Ds OD_SKU Char(25);
Dcl-Ds PICKDETAIL Dim(99);
Dcl-LOTATTRIBUTE Dim(99);
End-Ds;
End-Ds;
etc.

Kevin

From: Jon Paris <jon.paris@xxxxxxxxxxxxxx<mailto:jon.paris@xxxxxxxxxxxxxx>>
Subject: Re: XML with 8 levels of multi-occurring segments
Date: August 31, 2018 at 12:20:36 PM EDT
To: Rpg400 Rpg400-L <rpg400-l@xxxxxxxxxxxx<mailto:rpg400-l@xxxxxxxxxxxx>>
Reply-To: "RPG programming on the IBM i \(AS/400 and iSeries\)" <rpg400-l@xxxxxxxxxxxx<mailto:rpg400-l@xxxxxxxxxxxx>>

I meant that there is an awful lot of this stuff.

If it is this element/attribute name then
else if it is this name and I'm in this structure ... type of stuff.

Not to mention having to handle multiple data events for each element/attribute handle white spec characters etc. etc.

I find XML-INTO just so much less work. Just code a DS and bingo! (Well "Just" can sometimes be a pain but ...).


Jon Paris

www.partner400.com<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.partner400.com&data=02%7C01%7CKevin_Grimes%40genpt.com%7Cd5f257ddece54cf2cc7308d60f6418c3%7Cb439d764f2cb43eaac052e373c83043e%7C0%7C0%7C636713319921556468&sdata=mPX5h3UbAim%2F1ppcwVUJDw55pYpUQXRztgCGCckcfT4%3D&reserved=0>
www.SystemiDeveloper.com<http://www.SystemiDeveloper.com>


On Aug 31, 2018, at 12:06 PM, Alan Campin <alan0307d@xxxxxxxxx<mailto:alan0307d@xxxxxxxxx>> wrote:

It was said earlier that XML-SAX is a lot of work. I don't get that.
XML-SAX is easy, to me at lot easier than trying to use XML-INTO and you
don't have to sweat memory. You only need enough to store one record (I
don't know what you are doing with records. Processing everything for an
order and then writing to disk?).

Anyway, I would be happy to send you an example program I wrote that uses
XML-SAX.

On Fri, Aug 31, 2018 at 8:57 AM Jon Paris <jon.paris@xxxxxxxxxxxxxx<mailto:jon.paris@xxxxxxxxxxxxxx>> wrote:


Even a single instance of an Order won't fit? Surely it can't be that
huge?


Jon Paris

www.partner400.com<http://www.partner400.com>
www.SystemiDeveloper.com<http://www.SystemiDeveloper.com>


On Aug 31, 2018, at 10:54 AM, Kevin Grimes <kevin_grimes@xxxxxxxxx<mailto:kevin_grimes@xxxxxxxxx>>
wrote:


<ORDERS> will not fit into 16mb and that's my main issue right now. How
can I define the data structure to be less than 16mb or do I need to use
some other technique?



-----Original Message-----
From: Jon Paris [mailto:jon.paris@xxxxxxxxxxxxxx]
Sent: Friday, August 31, 2018 9:44 AM
To: Rpg400 Rpg400-L <rpg400-l@xxxxxxxxxxxx<mailto:rpg400-l@xxxxxxxxxxxx>>
Subject: Re: XML with 8 levels of multi-occurring segments

You could use XML-SAX - but that's a lot of work unless you only want a
few fields.


In this case you should be able to do it with XML-INTO and the %Handler
option. As long as the size of one <ORDERS> will fit into 16Mb it should
work just fine.


If you need more help in understanding how that would work just holler.


Jon Paris

www.partner400.com<http://www.partner400.com>
www.SystemiDeveloper.com<http://www.SystemiDeveloper.com>


On Aug 31, 2018, at 9:32 AM, Kevin Grimes <kevin_grimes@xxxxxxxxx<mailto:kevin_grimes@xxxxxxxxx>>
wrote:


I have the following XML file to process -

<LOADHDR> single
<LOADSTOP> single
<ORDERS> multiple
<Field 1>
<STORER> single
<LOADUNITDETAIL> multiple
<PACKIDH> single
<PACKIDD> multiple
<PACKIDSUBDETAIL> multiple
<Field 2>
<SKU> multiple
<Field 3>
<ORDERDETAIL> multiple
<PICKDETAIL> multiple
<LOTATTRIBUTE> multiple

I'm trying to read this into a data structure and with the nested
multiple occurring segments it is too big to compile. I'm relatively new
to XML processing and I'm hoping there's another method to consuming the
XML file besides just reading it into a DS with nested arrays.


Thanks,

Kevin G
"This email and any attachments, contain Genuine Parts Company
confidential information that is proprietary, privileged, and protected by
applicable laws. If you have received this message in error and are not the
intended recipient, you should not retain, distribute, disclose or use any
of this information and you should destroy this email, any attachments or
copies therein forthwith. Please notify the sender immediately by email if
you have received this email in error."

--
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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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 email and any attachments, contain Genuine Parts Company confidential information that is proprietary, privileged, and protected by applicable laws. If you have received this message in error and are not the intended recipient, you should not retain, distribute, disclose or use any of this information and you should destroy this email, any attachments or copies therein forthwith. Please notify the sender immediately by email if you have received this email in error."
--
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 ...

Follow-Ups:
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.