I have a report where I have to show the total no of an item being shipped by lot no used,then specify how many boxes make up the total . If I ship 240 of an item and the the item ships in packs or 24 then = 10 boxes, but if I ship 245 this will equate to 11 boxes ( 10 +1 part box).
These are the formulars I am using to acieve this.
SPLIT UNITS
split({stockm.despatch_units},"PK")[1]
//the despatch units are in the format 5PK, 24 PK etc so I have to split the field to get 5, 24 etc.
TO NUMBER
if isnumeric({@split units}) then
tonumber({@split units})
Else 0
// then change this field to a number in order to use it in a calculation
NEGATE QTY
-({stkhstm.movement_quantity})
// I have to negate this qty to make it a positive no
BOXES
if {@to_number}<>0
Then {@NEGATE QTY} / {@to_number}
Else
0
ROUNDUP BOXES
Local NumberVar RoundUp := {@boxes};
If int (RoundUp)/2 = RoundUp/2 then RoundUp else truncate (Roundup)+1 ;
This works fine but occasionally I get an incorrect ammount as you can see below:
Ps All are shipped in packs of 24.
TOTAL SHIPPED BOXES lot NO
940 40 5a08d
8352 349 5a15c
6008 251 5a09d
25773 1074 5a16c
2616 109 5a17c
All are correct except the 8352 (lot No 5a15c, this should show 348 boxes not 349 as 8352/24 = 348 exactly yet it seems to be adding 1 to this ammount.
Could anyone shed some light on this.
Ps I have to sum the total and the boxes fields otherwise they only return the 1st instance of the movement Qty(Negate Qty).
I am using CR 8.5
thanks in advance for any help you can give me AJD
These are the formulars I am using to acieve this.
SPLIT UNITS
split({stockm.despatch_units},"PK")[1]
//the despatch units are in the format 5PK, 24 PK etc so I have to split the field to get 5, 24 etc.
TO NUMBER
if isnumeric({@split units}) then
tonumber({@split units})
Else 0
// then change this field to a number in order to use it in a calculation
NEGATE QTY
-({stkhstm.movement_quantity})
// I have to negate this qty to make it a positive no
BOXES
if {@to_number}<>0
Then {@NEGATE QTY} / {@to_number}
Else
0
ROUNDUP BOXES
Local NumberVar RoundUp := {@boxes};
If int (RoundUp)/2 = RoundUp/2 then RoundUp else truncate (Roundup)+1 ;
This works fine but occasionally I get an incorrect ammount as you can see below:
Ps All are shipped in packs of 24.
TOTAL SHIPPED BOXES lot NO
940 40 5a08d
8352 349 5a15c
6008 251 5a09d
25773 1074 5a16c
2616 109 5a17c
All are correct except the 8352 (lot No 5a15c, this should show 348 boxes not 349 as 8352/24 = 348 exactly yet it seems to be adding 1 to this ammount.
Could anyone shed some light on this.
Ps I have to sum the total and the boxes fields otherwise they only return the 1st instance of the movement Qty(Negate Qty).
I am using CR 8.5
thanks in advance for any help you can give me AJD