B
BobNoobGuy
Guest
This is my desired output
this is my code
the only thing missing from my output from the desired output is the one object in the first line
any suggestions on how to add them?
thank you
Continue reading...
Code:
{ "event_type": "LOAD_AVAILABLE",
"event_data": {
"load": [
{
"Ord": "ORDER12344",
"ShipReqDt": "2021-10-29",
"load_items": [
{
"ItemDesc": "Apple 12oz English Domestic: 10004-000",
"Qty": 320
},
{
"ItemDesc": "Apple CTN 12",
"Qty": 980
}
]
}
]
}}
this is my code
Code:
def temp-table ttOrd serialize-name "load"
field Ord like Ord.Ord
field ShipReqDt like Ord.ShipReqDt.
def temp-table ttItem serialize-name "load_items"
field Ord like OrdDet.Ord serialize-hidden
field ItemDesc as char
field Qty like OrdDet.ActBox.
def dataset dsOrd serialize-name "event_data" for
ttOrd, ttItem
data-relation Rel1 for ttOrd, ttItem nested relation-fields(Ord, Ord).
procedure WriteJSON:
def var dFilename as char no-undo.
dFilename = dSessTmpDir + "/Test1.xml".
find Ord no-lock where
Ord.Ord = "ORDER12344"
no-error.
create ttOrd.
assign
ttOrd.Ord = Ord.Ord
ttOrd.ShipReqDt = Ord.ShipReqDt.
for each OrdDet where OrdDet.Ord = Ord.Ord on error undo, return error on stop undo, return error:
Create ttItem.
assign
ttItem.Ord = OrdDet.Ord
ttItem.ItemDesc = OrdDet.Descr
ttItem.Qty = OrdDet.Qty.
end.
dataset dsOrd:write-json("FILE", dFilename, true).
end procedure. /* WriteJSON */
the only thing missing from my output from the desired output is the one object in the first line
Code:
"event_type": "LOAD_AVAILABLE"
any suggestions on how to add them?
thank you
Continue reading...