Conditionally export Fields - Part 2 - Forum - OpenEdge Development - Progress Community

Conditionally export Fields - Part 2

 Forum

Conditionally export Fields - Part 2

This question is answered

Continuing with https://community.progress.com/community_groups/openedge_development/f/19/t/36047 , where I have a dataset to acomodate: ( http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd )  (obtained with bproxsdto4gl tool).

I have following situation.

applying XML-WRITE to dataset with option OMIT-INITAL-VALUES, keeps the xml free of empty nodes, which is desirable on most cases.

The problem came with certain nodes, which initial value is 0, and a value that in certains cases makes sense of 0.00, are removed from layout, but in those cases, the node must be present to assert a value of 0.00.

The first case is a run with omit-initial-values eq False, the second has omited values.  The problem is in first case, I don't want the Sello = "" and Folio = "" fields and as this, I can get the TasaOCuota field present in the CONCEPTO-IMPUESTOS-TRASLADOS-TRASLADO node.  With omit-initial-values, I get id of the Sello and friends fields, but also lost Tasa OCuota, which is a field to be present to indicate a tax rate of 0.00.

I'm thinking that, unless I could modify the schema of XML at runtime to specify some inexistent value as initial so the omit-iniital option considers 0.00 not to be initial value and keeps the field on XML output, I should write my own XML-WRITE method, something I really would like not to have to do, for simplicity of system sake...

Is there something I can do?

Thanks.

Examples:

first, with OMIT-INITIAL-VALUES equals false

<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="3.3" Serie="A" Folio="" Fecha="2017-11-11T16:59:31" Sello="" FormaPago="03" NoCertificado="" Certificado="certificado" CondicionesDePago="Contado" SubTotal="0.0" Descuento="0.0" Moneda="MXN" TipoCambio="1.0" Total="0.0" TipoDeComprobante="Ingreso" MetodoPago="PUE" LugarExpedicion="36760" Confirmacion="">
  <cfdi:Emisor Rfc="AECE911208KK4" Nombre="Edgar O." RegimenFiscal="Persona Fisica"/>
  <cfdi:Receptor Rfc="SCH000314GV5" Nombre="SUPER S.A. DE C.V." ResidenciaFiscal="Street #100, Col. San Pedro" NumRegIdTrib="" UsoCFDI="G03"/>
  <cfdi:Conceptos>
    <cfdi:Concepto ClaveProdServ="50111514" NoIdentificacion="065" Cantidad="122.1" ClaveUnidad="KGM" Unidad="KGS" Descripcion="Pernil" ValorUnitario="32.5" Importe="3968.25" Descuento="0.0">
      <cfdi:Impuestos>
        <cfdi:Traslados>
          <cfdi:Traslado Base="3968.25" Impuesto="" TipoFactor="TASA" TasaOCuota="0.0" Importe="0.0"/>
        </cfdi:Traslados>
      </cfdi:Impuestos>
    </cfdi:Concepto>
    <cfdi:Concepto ClaveProdServ="50111514" NoIdentificacion="065" Cantidad="222.1" ClaveUnidad="KGM" Unidad="KGS" Descripcion="Pernil" ValorUnitario="32.5" Importe="7218.25" Descuento="0.0">
      <cfdi:Impuestos>
        <cfdi:Traslados>
          <cfdi:Traslado Base="7218.25" Impuesto="" TipoFactor="TASA" TasaOCuota="0.0" Importe="0.0"/>
        </cfdi:Traslados>
      </cfdi:Impuestos>
    </cfdi:Concepto>
  </cfdi:Conceptos>
</cfdi:Comprobante>

second with OMIT-INITIAL-VALUES eq TRUE

<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="3.3" Serie="A" Fecha="2017-11-11T16:54:34" FormaPago="03" Certificado="certificado" CondicionesDePago="Contado" Moneda="MXN" TipoCambio="1.0" TipoDeComprobante="Ingreso" MetodoPago="PUE" LugarExpedicion="36760">
  <cfdi:Emisor Rfc="AECE911208KK4" Nombre="Edgar O." RegimenFiscal="Persona Fisica"/>
  <cfdi:Receptor Rfc="XXX000314XX5" Nombre="SUPER S.A. DE C.V." ResidenciaFiscal="Street #100, Col. San Pedro" UsoCFDI="G03"/>
  <cfdi:Conceptos>
    <cfdi:Concepto ClaveProdServ="50111514" NoIdentificacion="065" Cantidad="122.1" ClaveUnidad="KGM" Unidad="KGS" Descripcion="Pernil" ValorUnitario="32.5" Importe="3968.25">
      <cfdi:Impuestos>
        <cfdi:Traslados>
          <cfdi:Traslado Base="3968.25" TipoFactor="TASA"/>
        </cfdi:Traslados>
      </cfdi:Impuestos>
    </cfdi:Concepto>
    <cfdi:Concepto ClaveProdServ="50111514" NoIdentificacion="065" Cantidad="222.1" ClaveUnidad="KGM" Unidad="KGS" Descripcion="Pernil" ValorUnitario="32.5" Importe="7218.25">
      <cfdi:Impuestos>
        <cfdi:Traslados>
          <cfdi:Traslado Base="7218.25" TipoFactor="TASA"/>
        </cfdi:Traslados>
      </cfdi:Impuestos>
    </cfdi:Concepto>
  </cfdi:Conceptos>
</cfdi:Comprobante>
Verified Answer
  • Hi Octavio,

    What is you set the initial value of the integer field to ?

    Than fields that are 0.00 are not the same as the default and will get serialized

  • Why not make the initial value of the numeric fields ?

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

All Replies
  • Hi Octavio,

    What is you set the initial value of the integer field to ?

    Than fields that are 0.00 are not the same as the default and will get serialized

  • Why not make the initial value of the numeric fields ?

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • Set initial values in temp-tables ?  let me see...

  • YOU ROCK men!!!!!!

    I tough that initial values was something attached to XML schema!!!!

    I set initial value to 0.000001  and that was it

  • Octavio, do yourself a favour and do the serialisation yourself instead of fooling around with temp-table/dataset/field properties… not only that might have strange side-effects if you get the objects by reference (others might not expect you to change those on the reference they pass through) but eventually you will find it’s hard if not impossible to define a dataset structure to exactly match the xml format you need to produce.


    Marian Edu

    Acorn IT 
    +40 740 036 212

  • What objection do you have to using unknown value as the initial value?

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • No objection if that really has to be set, that can’t be changed once the table was prepared… however, my comment was because this is a followup (part two) of another thread where buffer field attributes were changed (serialize hidden, xml node type, etc).

    When dealing with external systems integration where you can’t control the serialization structure it’s probably better not to go the write-xml/read-xml route but that might be just my experience :(

    Marian Edu

    Acorn IT 
    +40 740 036 212

  • My question was addressed to Octavio, not you, Marian.  :)

    I am not disagreeing with you at all, but just suggesting that *if* he sticks with the current approach, that ? is the better choice ... for anything that is not mandatory.

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • Thanks...

    Indeed... I stumbled in this document specification at a design error,,,  (from our "smart" developers on IRS equivalent, for whom is addressed ).

    They named the same for a deep inside node and a document level node...so the write-xml can't cope with that...

    Reverting to ol'good create hNodeRef stuff (hand writing of xml).