Options

Capacity Ledger Entries

BeliasBelias Member Posts: 2,998
edited 2009-04-27 in NAV Tips & Tricks
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. :mrgreen:

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

  • Options
    ara3nara3n Member Posts: 9,255
    A similar function is in CU 99000755 CalendarManagement.

    It takes WorkCenter and another UOM and returns a decimal.
    QtyperTimeUnitofMeasure(WorkCenterNo : Code[20] ;UnitOfMeasureCode : Code[10]) : Return : Decimal 
    Procedure 4 
    WorkCenter.GET(WorkCenterNo);
     
    EXIT(
      ROUND(
        TimeFactor(UnitOfMeasureCode) /
        TimeFactor(WorkCenter."Unit of Measure Code"),
        0.00001));
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    krikikriki Member, Moderator Posts: 9,096
    [Topic moved from 'NAV/Navision' forum to 'NAV Tips & Tricks' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.