Exporting data through a VI job where a numeric field may be zero (0) but need it to show as 0.00.

SOLVED

Client is running Sage 100 v2018.  Tried PRC(AP_InvoiceHeader04.DiscountAmt,2) in the numeric field - Calculation but that doesn't seem to change anything. The numeric mask is ###,###,###.00- but if the DiscountAmt being exported is 0, it's not showing on the export file as 0.00.

Thank you

Parents Reply
  • +1 in reply to Paul Smith - Bretthauer
    verified answer

    Well, apparently, this is just how the STR function works, if the numeric value is exactly zero, then regardless of extra zeros on the left or right of the decimal point in the mask, it will only return "0".  

    Two ways to do this depending on where you want the - sign.  Both require using a temp field with the data type set to string because you can't manipulate the string output if you return it as a number which is required when building a calculation against numeric fields.

    Use the following if you want the - sign on the right.

    STP(STR(PRC(AP_InvoiceHeader04.DiscountAmt,2),"###,###,##0.00"),"A","-")+TBL(PRC(AP_InvoiceHeader04.DiscountAmt,2)=PRC(AP_InvoiceHeader04.DiscountAmt,0),"",".00")+TBL(PRC(AP_InvoiceHeader04.DiscountAmt,2)<>ABS(PRC(AP_InvoiceHeader04.DiscountAmt,2)),"","-")

    Use the following if you want the - sign on the left.

    STR(PRC(AP_InvoiceHeader04.DiscountAmt,2),"-###,###,##0.00")+TBL(PRC(AP_InvoiceHeader04.DiscountAmt,2)=PRC(AP_InvoiceHeader04.DiscountAmt,0),"",".00")

    EDIT: If you don't want the temp field to be wrapped in double quotes when you have the option enabled, added the following to the calculation.

    ; DATATYPE$="N"

Children