2

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. 
Tom Bascom
  • 13,405
  • 2
  • 27
  • 33
Joe
  • 31
  • 4
  • You really shouldn't use unquoted file names -- yes, it "works" but it is a bug waiting to happen. You're also playing with fire with those FIRST and OF clauses in the FOR EACH. – Tom Bascom Jan 01 '18 at 18:37

1 Answers1

4

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.

TheDrooper
  • 1,182
  • 1
  • 7
  • 14