Banging my head on the wall. Decimal is no longer decimal.

Posted by OctavioOlguin on 29-Jan-2018 21:57

Please help....  6 hours straight making test and stuff, an I've just came to the conclusion I hit into a bug or something.

METHOD PUBLIC VOID RecalcularCFDI(pSerie AS CHARACTER, pFolio AS INTEGER, OUTPUT pTotal AS DECIMAL ):


        FIND Cfdi33_comprobante
            WHERE Cfdi33_comprobante.ciFolio = pFolio
            AND   Cfdi33_comprobante.ccSerie = pSerie NO-LOCK.

        FOR EACH Cfdi33_concepto
            WHERE Cfdi33_concepto.xcFKcomprobante = Cfdi33_comprobante.xcPK:

            ASSIGN
                pTotal = pTotal + Cfdi33_concepto.cdImporte.
        END.

        FIND CURRENT  Cfdi33_comprobante EXCLUSIVE-LOCK.
        ASSIGN
            Cfdi33_comprobante.cdTotal    = DECIMAL(pTotal)
            Cfdi33_comprobante.cdSubTotal = DECIMAL(pTotal).

        MESSAGE "Cfdi33_comprobante.cdTotal decimal: " STRING(Cfdi33_comprobante.cdTotal, ">>>>>>>9.9999<").
        MESSAGE "Cfdi33_comprobante.cdSubTotal decimal: " STRING(Cfdi33_comprobante.cdSubTotal, ">>>>>>>9.9999<").
        MESSAGE "pTotal: " pTotal.

        RELEASE Cfdi33_comprobante.

        RETURN.

    END METHOD.

and this is output

[18/01/29@21:19:23.445-0600] P-006164 T-006168 1 AS -- (Procedure: 'RecalcularCFDI Procs.SAT.v3_3.Comprobante' Line:375) Cfdi33_comprobante.cdTotal decimal: 15150.0000
[18/01/29@21:19:23.445-0600] P-006164 T-006168 1 AS -- (Procedure: 'RecalcularCFDI Procs.SAT.v3_3.Comprobante' Line:376) Cfdi33_comprobante.cdSubTotal decimal: 15150.0000
[18/01/29@21:19:23.445-0600] P-006164 T-006168 1 AS -- (Procedure: 'RecalcularCFDI Procs.SAT.v3_3.Comprobante' Line:377) pTotal: 15149.68

and day 30th is deadline!!!

prowin  11.7.2   code executes on appserver windows:

(appserver's proenv)

Inserting C:\Progress\OpenEdge\bin to beginning of path and
the current directory is
C:\OpenEdge\WRK

OpenEdge Release 11.5 as of Fri Dec 5 19:02:00 EST 2014
proenv>

on code showed up, there are the messages and decimal castings I have tryed,  made shure fields on db are decimai, but writing this I went to revisit the decimals specification I have on database, and found that it is set as '?'  instead the original 6.

This is the temp-table definitions derived from a XSD, wich then was used to load data definition on dictionary.

FIELD cdDescuento AS DECIMAL DECIMALS 6 LABEL "cdDescuento" COLUMN-LABEL "cdDescuento"
FIELD cdSubTotal AS DECIMAL DECIMALS 6 FORMAT "->>,>>9.999999" LABEL "cdSubTotal" COLUMN-LABEL "cdSubTotal"
FIELD cdTipoCambio AS DECIMAL DECIMALS 6 FORMAT "->>,>>9.999999" LABEL "cdTipoCambio" COLUMN-LABEL "cdTipoCambio"
FIELD cdTotal AS DECIMAL DECIMALS 6 FORMAT "->>,>>9.999999" LABEL "cdTotal" COLUMN-LABEL "cdTotal"

 

Another version is this, yet it show exactly the same output on appserver

METHOD PUBLIC VOID RecalcularCFDI(pSerie AS CHARACTER, pFolio AS INTEGER, OUTPUT pTotal AS DECIMAL ):

        DEFINE VARIABLE foo AS DECIMAL DECIMALS 6 NO-UNDO.

        FIND Cfdi33_comprobante
            WHERE Cfdi33_comprobante.ciFolio = pFolio
            AND   Cfdi33_comprobante.ccSerie = pSerie NO-LOCK.


        FOR EACH Cfdi33_concepto
            WHERE Cfdi33_concepto.xcFKcomprobante = Cfdi33_comprobante.xcPK
            GROUP BY Cfdi33_concepto.ccNoIdentificacion:

            ASSIGN
                foo = foo + Cfdi33_concepto.cdImporte.
        END.

        FIND CURRENT  Cfdi33_comprobante EXCLUSIVE-LOCK.
        ASSIGN
            Cfdi33_comprobante.cdTotal    = DECIMAL(foo)
            Cfdi33_comprobante.cdSubTotal = DECIMAL(foo)
            pTotal                        = foo.

        MESSAGE "Cfdi33_comprobante.cdTotal decimal: " STRING(Cfdi33_comprobante.cdTotal, ">>>>>>>9.9999<").
        MESSAGE "Cfdi33_comprobante.cdSubTotal decimal: " STRING(Cfdi33_comprobante.cdSubTotal, ">>>>>>>9.9999<").
        MESSAGE "pTotal: " pTotal.

        RELEASE Cfdi33_comprobante.

        RETURN.

    END METHOD.

I'm really desperate, as  it defies every knowing I had about datatypes..

TIA

Posted by OctavioOlguin on 29-Jan-2018 22:12

I went to datadictionary, set those fields to 6 decimals, recomplied, and re-run.. but no change....

Posted by OctavioOlguin on 29-Jan-2018 22:22

Thanks.. Yes there is no trigger for this (and for no other data anyway).   And I've posted several updates to this thread and the solution... but,,, agin I'm missing those post on the thread..

All Replies

Posted by OctavioOlguin on 29-Jan-2018 22:12

I went to datadictionary, set those fields to 6 decimals, recomplied, and re-run.. but no change....

Posted by Tim Kuehn on 29-Jan-2018 22:18

Have you checked to make sure there's no triggers, etc. running that's changing the data? 

I'd suggest taking the code and running it in a test area - it shouldn't be behaving like that. 

 Virus-free. www.avg.com

Posted by OctavioOlguin on 29-Jan-2018 22:18

removing the DECIMAL() make problem go away...  but decimal function was introduced last hour only......  so previous five hours problem was the decimals definition on datadictiionary?

Posted by OctavioOlguin on 29-Jan-2018 22:22

Thanks.. Yes there is no trigger for this (and for no other data anyway).   And I've posted several updates to this thread and the solution... but,,, agin I'm missing those post on the thread..

Posted by OctavioOlguin on 29-Jan-2018 22:33

Anyway...  removing the DECIMAL() on the fields solved this, after making shure on db that decimals is set to 6, instead a '?' that showed on datadict.  Recompiled and rerun to avail... yes.

The problem is that DECIMAL() was introduced last hour... but previous 5 hours, it behavied different...  Datadictionary was created from XSD with bproxsdto4gl, and data definitions goes as:

   FIELD cdSubTotal  AS DECIMAL  DECIMALS 6 FORMAT "->>,>>9.999999" LABEL "cdSubTotal" COLUMN-LABEL "cdSubTotal"
   FIELD cdTotal     AS DECIMAL  DECIMALS 6 FORMAT "->>,>>9.999999" LABEL "cdTotal" COLUMN-LABEL "cdTotal"

This thread is closed