For completeness here is my code. I hope i can help others with this.
reportextension 50999 "Standard Sales - Shipment Ext" extends "Standard Sales - Shipment"
{
// in this extension we
// add weights to the delivery note
// add package sizes to the delivery note
dataset
{
add(Header)
{
column(Header_TotalNetWeight; TotalNetWeight) { }
column(Header_TotalGrossWeight; TotalGrossWeight) { }
}
add(Line)
{
column(Net_Weight; "Net Weight") { }
column(Gross_Weight; "Gross Weight") { }
column(LineNetWeight; LineNetWeight)
{
DecimalPlaces = 0 : 1;
}
column(LineGrossWeight; LineGrossWeight)
{
DecimalPlaces = 0 : 1;
}
column(Unit_of_Measure_Code; "Unit of Measure Code") { }
column(LineUnitSize; LineUnitSize) { }
}
modify(Header)
{
trigger OnAfterAfterGetRecord()
begin
TotalGrossWeight := TotalGrossWeight;
TotalNetWeight := TotalNetWeight;
end;
}
modify(Line)
{
trigger OnAfterAfterGetRecord()
begin
//get (width x length x height) as Text
LineUnitSize := GetItemUnitSize("No.", "Unit of Measure Code");
// if we have a gross weight from th eitem unit of measure,
// use this to calculate the line gross weight and the gross total
if ItemUnitOfMeasure.Get("No.", "Unit of Measure Code") then begin
if ItemUnitOfMeasure.Weight > 0 then begin
"Gross Weight" := ItemUnitOfMeasure.Weight;
LineGrossWeight := AddToGrossTotal("Gross Weight" * Quantity);
end;
end;
// use modify to calculate th eline net weight, from the item card
LineNetWeight := AddToNetTotal("Net Weight" * Quantity);
end;
}
} //end of Dataset
requestpage
{
//placeholder: later being able to chose including a commercial invoice
}
local procedure AddToNetTotal(LineWeight: Decimal) LineWeightReturn: Decimal
begin
TotalNetWeight += LineWeight;
LineWeightReturn := LineWeight;
end;
local procedure AddToGrossTotal(LineWeight: Decimal) LineWeightReturn: Decimal
//var
// ItemUnitsOfMeasure: Record "Item Unit of Measure";
begin
TotalGrossWeight += LineWeight;
LineWeightReturn := LineWeight;
end;
local procedure GetItemUnitSize(ItemNo: Code[20]; ItemUnit: Code[20]) Size: Text
begin
if ItemUnitOfMeasure.Get(ItemNo, ItemUnit)
then begin
Size :=
Format(ItemUnitOfMeasure.Height) + ' x '
+ Format(ItemUnitOfMeasure.Width) + ' x '
+ Format(ItemUnitOfMeasure.Length);
end;
end;
var
TotalNetWeight: Decimal;
TotalGrossWeight: Decimal;
LineNetWeight: Decimal;
LineGrossWeight: Decimal;
ItemUnitOfMeasure: Record "Item Unit of Measure";
LineUnitSize: Text;
}