Dataset to XML

Posted by Patrick Tingen on 15-Dec-2015 03:02

I need to create an XML file with a set of tables. The requirement is that one of the tables is surrounded by an extra tag that indicates the plural form of the element below. As an example: for the orders of a customer the XML should look something like this:

  <Name>Lift Line Skiing</Name>

I can achieve this with an extra temp-table in my dataset like this:

DEFINE TEMP-TABLE ttCustomer LIKE customer.
  FIELD custnum AS INTEGER. 

DEFINE DATASET dsCustOrders FOR ttCustomer, ttOrders, ttOrder
  DATA-RELATION drCustOrder FOR ttCustomer, ttOrders RELATION-FIELDS(custnum,custnum)
  DATA-RELATION drOrders FOR ttOrders, ttOrder RELATION-FIELDS(custnum,custnum).

But the table ttOrders is actually only needed to get the <Orders> tag in the XML file. Is there a better way?


All Replies

Posted by Elsworth Burmeister on 15-Dec-2015 03:09

What I do is take the xml and generate an xsd file. (
Then in proenv  run……
xsdto4gl c:\Temp\Temp3\myxsd.xsd -output c:\temp\Temp3
this will create an include file in the out directory that will build your temp-table and dataset and relationships based on the xsd.

Elsworth Burmeister

Developer - Managed Services

Cell: +27 83 777 3072 Email:


ELCB Information Services (Pty) Ltd

Customer Service Email ·

E A S T  L O N D O N

Tel: +27(43)  704 0700

Fax: +27(43) 704 0701


Tel: +27(10) 035 0310

Fax: +27(10) 035 0311

P O R T  E L I Z A B E T H

Tel: +27(41) 373 0529

Fax: +27(86) 650 0135


Posted by Patrick Tingen on 15-Dec-2015 03:46

Thanks for the tip, I did not know one could do this like this. Nice.

It gives me the same structure for my Dataset back as what I came up with myself, so that means I really need those linking temp-tables. Thats sad because I only need them for the XML and not for the program itself.

Posted by Elsworth Burmeister on 15-Dec-2015 03:58

Yes its a great way of doing things and it makes life easy,faster and more efficient... you will run into times where you get errors generating the .i from the xsd but thats because of the structure of the xml... :)

Posted by martinz on 15-Dec-2015 04:45

Wow, I wish I had known about this earlier. We did quite some experimenting to get temp-table definitions right just to solve exactly the same issue as Patrick had.

This is nice!

Posted by Elsworth Burmeister on 15-Dec-2015 06:16

no problem... a guru once shared this with knowledge with me so i thought id return the favor... It works well when doing integration projects (rest services) when receiving xml from a progress works prominently with datasets,  makes startup on these projects much faster....

This thread is closed