How to write a xml file using break by

Pavithra

New Member
Here is my query .. I am trying break the file with site while writing it.
Code:
FOR EACH tt_Woorder NO-LOCK BREAK BY tt_Woorder.tt_site:
IF LAST-OF (tt_Woorder.tt_site) THEN DO:
    DATASET dsproductionPlan:write-xml("file", lXmlPathName ,true, ?,?, false, false).
END.
end.
 
Last edited by a moderator:

peterjudge

Member
I'm not sure what you're asking for. Do you want to only write a subset of the data in the dataset? ANd is tt_Woorder in the dsproductionPlan dataset?
 

Cecil

19+ years progress programming and still learning.
I'm not quite sure what you are trying to do, but at a guess you want to have a separate XML output per site.

Try this:
Code:
FOR EACH tt_Woorder NO-LOCK BREAK BY tt_Woorder.tt_site:
IF LAST-OF (tt_Woorder.tt_site) THEN DO:

   // DATASET dsproductionPlan:write-xml("file", lXmlPathName ,true, ?,?, false, false).
  
    tt_Woorder:SERIALIZE-ROW("XML","file", lXmlPathName + tt_Woorder.tt_site + '.xml'  ,true, ?,?, false).
END.
end.
 

Pavithra

New Member
I'm not quite sure what you are trying to do, but at a guess you want to have a separate XML output per site.

Try this:
Code:
FOR EACH tt_Woorder NO-LOCK BREAK BY tt_Woorder.tt_site:
IF LAST-OF (tt_Woorder.tt_site) THEN DO:

   // DATASET dsproductionPlan:write-xml("file", lXmlPathName ,true, ?,?, false, false).
 
    tt_Woorder:SERIALIZE-ROW("XML","file", lXmlPathName + tt_Woorder.tt_site + '.xml'  ,true, ?,?, false).
END.
end.
Hi,
Thanks for your query.
yes I am trying to separate xml per site, I have tried your query but it throws the following error

**SERIALIZE-ROW is not a queryable attribute for TEMP-TABLE widget. (4052).

my temp table is having below values

┌────────────────────────────────────────
│Item Number Site Qty Ordered Line tt_ddate Domain tt_refid
│────────────────────────────────────────
│1234 6030 1,968.0 O9 10/02/20 US01 f688bd73-0234-d399-bc14-2eb06881cde9
│1234 6033 41,608.0 O9 10/02/20 US01 f688bd73-0234-d399-bc14-2eb020a6cde9
 

Pavithra

New Member
I'm not sure what you're asking for. Do you want to only write a subset of the data in the dataset? ANd is tt_Woorder in the dsproductionPlan dataset?
Hi ,
Thanks for the reply.
yes, tt_woorder is my dataset and I want that temp table data to be export in xml output per site.
 

peterjudge

Member
Hi ,
Thanks for the reply.
yes, tt_woorder is my dataset and I want that temp table data to be export in xml output per site.

The temp-table and dataset WRITE-XML (and WRITE-JSON) methods write out the entire contents of the dataset/temp-table.

You would call SERIALIZE-ROW on the buffer, so the syntax would be BUFFER tt_woorder:SERIALIZE-ROW(...) . YOu will overwrite the file each time you call it, so I would write the XML to a longchar (without any outer objects, see the doc) and use the OUTPUT APPEND to write to file. That will probably require a restructuring of your FOR EACH too.

It might be simpler to just fill the temp-table with 1 site's data and use WRITE-XML .
 
Top