I couldn't find a function to translate capacity unit of measures in standard nav, so I developed it by myself and i want to share it with you if you need it. It's a really stupid function that takes as parameters the value to translate, the code of the "from" and "to" unit of measures. The function translate the value in minutes, and than translate the minutes in the resulting unit of measure.
As I said, really stupid.
P.S.: If there's a standard function for this, please suggest it to me.
PARAMETERS
Var Name DataType Subtype Length
No DECValue Decimal
No CDFromUOM Code 10
No CDToUOM Code 10
RETURN VALUE
Decimal type
VARIABLES
Name DataType Subtype Length
TBFromCapUoM Record Capacity Unit of Measure
TBToCapUoM Record Capacity Unit of Measure
FUNCTION:
FNTTranslateCapacity(DECValue : Decimal;CDFromUOM : Code[10];CDToUOM : Code[10]) : Decimal
TBFromCapUoM.GET(CDFromUOM);
TBToCapUoM.GET(CDToUOM);
IF TBFromCapUoM.Type <> TBToCapUoM.Type THEN BEGIN
CASE TBFromCapUoM.Type OF
TBFromCapUoM.Type::"100/Hour": BEGIN
DECValue := DECValue * 0.6;
END;
TBFromCapUoM.Type::Minutes: BEGIN
DECValue := DECValue * 1;
END;
TBFromCapUoM.Type::Hours: BEGIN
DECValue := DECValue * 60;
END;
TBFromCapUoM.Type::Days: BEGIN
DECValue := DECValue * 60 * 24;
END;
END;
CASE TBToCapUoM.Type OF
TBFromCapUoM.Type::"100/Hour": BEGIN
DECValue := DECValue / 0.6;
END;
TBFromCapUoM.Type::Minutes: BEGIN
DECValue := DECValue / 1;
END;
TBFromCapUoM.Type::Hours: BEGIN
DECValue := DECValue / 60;
END;
TBFromCapUoM.Type::Days: BEGIN
DECValue := DECValue / 60 / 24;
END;
END;
END;
EXIT(DECValue);
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Comments
It takes WorkCenter and another UOM and returns a decimal.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!