Search code examples
sqlopenedgeprogress-4glprogress-db

Progress Database 4GL - Math calculate for export file


The statements below will execute. However, I want the wShipment.Volume divided by 1728 and export that result.

For example, if wShipment.Volume is 3456, then it should export the result 2 to the report.

OUTPUT TO \\tsclient\U\All_Orders_item.csv.

FOR EACH r4_wms.wShipmentDet NO-LOCK,

FIRST r4_wms.wShipment OF r4_wms.wShipmentDet NO-LOCK where wShipment.shipmentNO>6500 and wShipmentDet.Owner="MIDEAUS",

FIRST r4_wms.wOrder OF r4_wms.wShipmentDet NO-LOCK,

FIRST r4_wms.wOrderline OF r4_wms.wShipmentDet NO-LOCK
 BY wShipment.ShipmentNo DESC:

EXPORT DELIMITER ","

           wOrder.OrderNo

           wShipment.Volume

           wShipment.Weight SKIP.   

 END.

 OUTPUT CLOSE. 

Solution

  • If you just want to divide by 1728, you can do that right in the EXPORT statement:

    wShipment.Volume / 1728
    

    But that "1728" sounds like you're looking for cubic feet (12 x 12 x 12). If you need the minimum whole-number of cubic feet for the volume, you can calculate that like this:

    DEFINE VARIABLE RoundedVol AS INTEGER NO-UNDO.
    
    RoundedVol = TRUNCATE(wShipment.Volume / 1728, 0).
    IF wShipment.Volume MOD 1728 > 0 THEN 
        RoundedVol = RoundedVol + 1.
    

    Then add RoundedVol to the EXPORT statement. It will give you the cubic feet rounded up on any fraction. So for a volume of 1729, you'll get 2.