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



I recommend to work whenever possible with templates.

Example with your data:
dcl-ds xmldata;
file_in like t_file-in dim(100);
cnt_file-in int(5);
end-ds;

dcl-ds t_file_in template;
dcl-ds header;
dcl-subf file_number int(5);
end-ds;
service like tsf_service;
end-ds;

dcl-ds tsf_ service template;
dcl-subf label varchar(20);
dcl-ds data;
dcl-ds contract dim(10);
dcl-subf num_contract int(5);
end-ds;
cnt_contract int(5);
end-ds;
end-ds;

xml-into xmldata %xml(%trim(InpFile):options);

dcl-c options 'doc=file +
ccsid=best +
ns=remove +
case=any +
allowmissing=yes +
allowextra=yes +
datasubf=data +
countprefix=cnt_ +
path=xmldata';

With the cnt_ fields you'll informed how much entries are in.

Not tested, only a proposal. I use this method in huge XML structures like
the UBL invoices or orders.

Just my 2 cts.
kf


-----Ursprüngliche Nachricht-----
Von: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] Im Auftrag von
Dave
Gesendet: Freitag, 2. August 2024 20:08
An: rpg400-l@xxxxxxxxxxxxxxxxxx
Betreff: xml-into

Hi,

Not having much fun using XML-INTO and nested DS arrays :-(

I need an array at the end something like this
fileIn(1).header.file_number = 31
fileIn (1).contract(1).num_contract = 741
fileIn (1).contract(2).num_contract = 750
fileIn (2). header.file_number = 42
fileIn (2).contract(1).num_contract = 850
fileIn (2).contract(2).num_contract = 950

I've tried pulling the whole of my xml file into 1 DS (this came out
empty, I'm not sure if XML-INTO knows how to do this).
I can get the "header" elements into one DS array and the "contract"
elements into another :

Header(1). file_number = 31
Header(2). file_number = 42

contract(1).num_contract = 741
contract(2).num_contract = 750
contract(3).num_contract = 850
contract(4).num_contract = 950

Obviously that's not good as I've lost the relation
file_number/num_contract.

Thanks for any help.

My Xml

<xmldata>
<file_in>
<header>
<file_number>31</file_number>
</header>
<service>
<label>label1</label>
<data>
<contract>
<NUM_contract>741</NUM_contract>
</contract>
<contract>
<NUM_contract>750</NUM_contract>
</contract>
</data>
</service>
</file_in>
<file_in>
<header>
<file_number>42</file_number>
</header>
<service>
<label>label2</label>
<data>
<contract>
<NUM_contract>850</NUM_contract>
</contract>
<contract>
<NUM_contract>950</NUM_contract>
</contract>
</data>
</service>
</file_in>
</xmldata>

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.