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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suggestions for base logic to build from 1

Status
Not open for further replies.

markajem

Programmer
Dec 20, 2001
564
US
I am working on a project for measurements for the warehouse. I am just trying to get the basic logic down for figuring the longest end of the carton and then from there I can take it.

Here is what I mean. I have to determine if the length, width or height is the longest of all 3 dimensions and then from there do my calculations. There is also a chance that the length may be the same as the width but still be the longest measurement or that all three measurements are the same so the formula has to have not only a > but also = in it. I have created something already but unfortunately as example what happens is that when I run it and the width is greater than the height it catches it in the logic but it is possible that the length could be longer than the height but that is further in the logic and does not catch it so the formula has to be able to allow all possibilities.

Is this a big thing or is there some type of standard logic to this?

Thanks
 
You could try with a forumula like this:
[tt]
numbervar array LWH:= [{Table.Length},{Table.Width},{Table.Height}];

if LWH[1] = Maximum(LWH) Then
"Length"
else if LWH[2] = Maximum(LWH) Then
"Width"
else
"Height"
[/tt]

Here's a look at what the results would be, based on some fake data:

[tt]Length Width Height LWH
30 25 10 Length
15 50 25 Width
20 14 50 Height
55 60 60 Width
[/tt]
Note that the last line would pick up Width as the maximum, even though Height is equal to it. You'd have to build on this to determine what to do in those cases.

-dave
 
I was looking at the formula

And thought you could expand it as follows

if LWH[1] = Maximum(LWH) Then
"Length"
else if LWH[2] = Maximum(LWH) Then
"Width"
else if LWH[3] = Maximum(LWH) Then
"Height"
else
"Error"

But it doesn't solve any problems with any side being the same length.

What would happen if the Data was all the Same?

Length Width Height LWH
30 30 30 ??


 
Presumably, there would be a business rule in place to determine which would be considered the longest if one or more values are the same. For instance, if the rule is that Height should be considered the longest if it's the same size as Length or Width. You would just run through the check in that order:

if LWH[3] = Maximum(LWH) Then
"Height"
else if LWH[1] = Maximum(LWH) Then
"Length"
else if LWH[2] = Maximum(LWH) Then
"Width"
else
"Error"

-dave
 
This is what I came up with and expanded on it to take into consideration the other calculations that I had to perform within the checker for the longest length. I also had to find the next longest side of the carton. Then take the measurement and calculate it.

Code:
      if ({PRODMSTR.LENGTH} >= {PRODMSTR.WIDTH}
     and {PRODMSTR.LENGTH} >= {PRODMSTR.HEIGHT}) then 
        
     (if {PRODMSTR.WIDTH} >= {PRODMSTR.HEIGHT} then 

     ({PRODMSTR.LENGTH} * 2 + {PRODMSTR.WIDTH} * 2) + {PRODMSTR.HEIGHT}
 
      else if {PRODMSTR.HEIGHT} >= {PRODMSTR.WIDTH} then 

      ({PRODMSTR.LENGTH} * 2 + {PRODMSTR.HEIGHT} * 2) + {PRODMSTR.WIDTH})


      else  if ({PRODMSTR.WIDTH}  >= {PRODMSTR.LENGTH}
      and {PRODMSTR.WIDTH} >= {PRODMSTR.HEIGHT}) then

     (if {PRODMSTR.LENGTH} >= {PRODMSTR.HEIGHT} then

      ({PRODMSTR.WIDTH} * 2 + {PRODMSTR.LENGTH} * 2) + {PRODMSTR.HEIGHT}

       else if {PRODMSTR.HEIGHT} >= {PRODMSTR.LENGTH} then

       ({PRODMSTR.WIDTH} * 2 + {PRODMSTR.HEIGHT} * 2) + {PRODMSTR.LENGTH})


        else   if ({PRODMSTR.HEIGHT} >= {PRODMSTR.WIDTH} and {PRODMSTR.HEIGHT} >= {PRODMSTR.LENGTH}) then 

      (if {PRODMSTR.LENGTH} >= {PRODMSTR.WIDTH} then

      ({PRODMSTR.HEIGHT} * 2 + {PRODMSTR.LENGTH} * 2) + {PRODMSTR.WIDTH}

        else if {PRODMSTR.WIDTH} >= {PRODMSTR.LENGTH}  then 

        ({PRODMSTR.HEIGHT} * 2 + {PRODMSTR.WIDTH} * 2) + {PRODMSTR.LENGTH})

I know I still have to come up with something if all three sides of the cartons are the same. This is for UPS carton dimensions and calculations for their 100 weight service. The people in the warehouse now do not have to calculate if this works correctly. So far it is. I am sure there was a few other ways to do it better but this is what I came up with and could understand with my experience and then be able to expand on it.

Any other suggestions would be appreciated.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top