WRITE-XML() From Datasets ...

Hauschild

New Member
Guys,

With an xml document that goes several levels deep, how does OpenEdge expect the data relations to be defined when then using the write-xml() method?

For example, I am coding to a particular xml spec that begins as an Order node and has underneath it: Order Item(s) and a Shipments node and the Shipments node contains another node for Shipment Item(s):
->Order
--->OrderItems
--->Shipments
------>ShipmentItems

Is there anything different I need to do when defining the relations when you go an extra level deep, as opposed to the standard parent-child relationship? Does ShipmentItems have to know about the Order (order # key) node? Or, is it only concerned with its direct parent Shipments (Ship # key)? I would assume the latter, but I can't get ShipmentItems to nest underneath Shipments.

I can post the code, but wanted to find out first whether there is something easy I might be missing.

Thanks.
 

Marian EDU

Member
if you have the data relation defined between Shipment and ShipmentItem and it's using nested then you should be just fine...

Code:
...
data-relation for Shipment, ShipmentItem relation-fields (shipKey, shipKey) nested
...
 

Hauschild

New Member
I figured out how to reproduce the xml document I was coding to. Not sure why I had to create a bunch of extra temp tables (the ones with 'link' as part of the name), but this was the ONLY method I found to reproduce the xml exactly. It would really help if Progress provided more complex examples in their documentation. I'm not sure what is redundant and what is needed in the following code, but it gave me what I needed and hopefully somebody in the same situation as me will find this helpful:

Code:
def temp-table SupplierOrdersLink
  XML-NODE-NAME "SupplierOrders"
  field supplierOrderId as char xml-node-type "hidden"
    index idx is primary unique supplierOrderId.
  
def temp-table ItemLink
  XML-NODE-NAME "Items"
  field supplierOrderId as char xml-node-type "hidden"
    index idx is primary unique supplierOrderId.
 
def temp-table ShipmentLink
  XML-NODE-NAME "Shipments"
  field supplierOrderId as char xml-node-type "hidden"
    index idx is primary unique SupplierOrderId.
 
def temp-table SupplierOrders no-undo
  XML-NODE-NAME "SupplierOrder"
  field dealerPONumber  as char
  field supplierOrderId as char
  field supplierCustom1 as char
  field orderStatusCode as char
  field orderMessage    as char
  field discounts       as deci
  field OtherCharges    as deci
  field Total           as deci
    index idx is primary unique supplierOrderId.    
  
def temp-table OrderItems no-undo
  XML-NODE-NAME "Item"
  field supplierOrderId   as char xml-node-type "hidden"
  field supplierSKU       as char
  field productName       as char
  field quantity          as inte
  field cost              as deci
  field ItemStatusCode    as char
  field ItemStatusMessage as char
    index idx is primary unique supplierOrderId supplierSKU. 
 
def temp-table ShipItems no-undo
  XML-NODE-NAME "Items"
  field shipId            as char xml-node-type "hidden"
  field supplierOrderId   as char xml-node-type "hidden"
  field supplierSKU       as char
  field productName       as char
  field quantity          as inte
  field cost              as deci
  field ItemStatusCode    as char
    index idx is primary unique ShipId supplierSKU. 
 
def temp-table Shipments no-undo
  XML-NODE-NAME "Shipment"    
  field supplierOrderId as char xml-node-type "hidden"
  field shipId          as char
  field shipper         as char
  field trackingNum     as char
  field shipDate        as date
  field shippingCost    as deci
  field shippingTotal   as deci
    index idx is primary unique SupplierOrderId ShipId.
  
  
def DATASET OrderUpdate
  for orderId
      ,SupplierOrdersLink  
      ,SupplierOrders
      ,ItemLink
      ,OrderItems
      ,Shipments
      ,ShipItems
      ,ShipmentLink
      
      DATA-RELATION drSuppLink FOR SupplierOrdersLink, SupplierOrders
      RELATION-FIELDS(SupplierOrderId, SupplierOrderId) NESTED
 
      DATA-RELATION drItemLink FOR ItemLink, OrderItems
      RELATION-FIELDS(supplierOrderId, supplierOrderId) NESTED
 
      DATA-RELATION drSuppItem FOR SupplierOrders, ItemLink
      RELATION-FIELDS(SupplierOrderId, SupplierOrderId) NESTED
      
      DATA-RELATION drShipLink FOR ShipmentLink, Shipments
      RELATION-FIELDS(supplierOrderId, supplierOrderId) NESTED
      
      DATA-RELATION drSuppShip FOR SupplierOrders, ShipmentLink
      RELATION-FIELDS(SupplierOrderId, SupplierOrderId) NESTED
      
      DATA-RELATION drShipItems FOR Shipments, ShipItems
      RELATION-FIELDS(ShipId, ShipId) NESTED
 
Top