write-xml decimal formatting - Forum - OpenEdge Development - Progress Community
 Forum

write-xml decimal formatting

  • Is it possible to enforce the number of decimal places when using write-xml?

    e.g. Temp table has a decimal field:

    define temp-table ttTab no-undo
        field partQty as decimal format "zzz,zz9.99-".

    create ttTab.
    assign ttTab.partQty = 200.1.

    temp-table ttTab:write-xml("FILE","myfile.xml").

    Resulting in XML like this:

    <?xml version="1.0"?>

    <ttTab xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

         <ttTabRow>

              <partQty>200.1</partQty>

         </ttTabRow>

    </ttTab>

    Is there a method of ensuring partQty has 2 decimal places at all times e.g.?

    <partQty>200.10</partQty>

    Chris

    Openedge 10.2B05, Solaris 64bit

  • Use a character column.

  • WRITE-XML recognizes the DECIMALS option on the temp-table field definition.  Adding DECIMALS 2 to the partQty definition will enforce 2 decimal places in the output.

    Regards,

    Robin

  • Bingo thanks very much!

    Chris