Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

incorrect return from formula

Status
Not open for further replies.

ajdesigns

Technical User
Jan 26, 2001
154
GB
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
 
When you show the output of each of the individual formulas and then manually do the final calculation for the number of boxes do you get a correct result ? If no, do the other formulas produce expected results for the 8352 record ?

ShortyA
 
I think you need to change the parens to make it: int(Roundup/2) as below:

Local NumberVar RoundUp := {@boxes};
If int (RoundUp/2) = RoundUp/2 then RoundUp else truncate (Roundup)+1 ;

-LB
 
hi lbass
When I change roundup as you suggested I get the following,
qty boxes
940 40
8352 352
6008 253
25773 1085
2616 110
yours AJD
 
Try this

BOXES
Code:
if {@to_number}=0 then
  0
else if remainder({@NEGATE QTY},{@to_number}) = 0 Then
  {@NEGATE QTY} / {@to_number}
Else
  truncate({@NEGATE QTY}/{@to_number})+1

Cheers,
-LW

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top