Creating Instances problem

fmhigue
Member Posts: 290
Guys I got the following code to identify between USA and MEXICO company. But I am getting an error message, the problem is cause because the instance but I do not know how to fix it.
This is the error message I am getting:
"There is no curency exchange rate within the filter". Filters: Currency Code:1, Starting Date: 07/02/04
Here is the code
.
END ELSE BEGIN //MEXICO COMPANY STARTING
USItem.CHANGECOMPANY(CompanyInformation.DSIUSCompanyName);
USCurrencyExchRate.CHANGECOMPANY(CompanyInformation.DSIUSCompanyName);
USItem.GET(Item."No.");
//Code to use Vendor Cost from US Company
IF USItem."Use Secondary Vendor" THEN BEGIN
VendorCost := USItem."Sec. Vendor Cost";
VendorCurr := USItem."Sec. Vendor Currency";
END ELSE BEGIN
VendorCost := USItem."Vendor Cost";
VendorCurr := USItem."Vendor Currency";
END;
//Code to change any currency to dollars
IF VendorCurr = 'USD' THEN
UnitCost := VendorCost
ELSE BEGIN
CurrencyFactor := USCurrencyExchRate.ExchangeRate(WORKDATE,VendorCurr);
UnitCost :=
ROUND(USCurrencyExchRate.ExchangeAmtFCYToLCY(WORKDATE,VendorCurr,VendorCost,CurrencyFactor));
END;
P.S. I am using Exchange Rate from the US company because we do not use those on Mexico.
This is the error message I am getting:
"There is no curency exchange rate within the filter". Filters: Currency Code:1, Starting Date: 07/02/04
Here is the code
.
END ELSE BEGIN //MEXICO COMPANY STARTING
USItem.CHANGECOMPANY(CompanyInformation.DSIUSCompanyName);
USCurrencyExchRate.CHANGECOMPANY(CompanyInformation.DSIUSCompanyName);
USItem.GET(Item."No.");
//Code to use Vendor Cost from US Company
IF USItem."Use Secondary Vendor" THEN BEGIN
VendorCost := USItem."Sec. Vendor Cost";
VendorCurr := USItem."Sec. Vendor Currency";
END ELSE BEGIN
VendorCost := USItem."Vendor Cost";
VendorCurr := USItem."Vendor Currency";
END;
//Code to change any currency to dollars
IF VendorCurr = 'USD' THEN
UnitCost := VendorCost
ELSE BEGIN
CurrencyFactor := USCurrencyExchRate.ExchangeRate(WORKDATE,VendorCurr);
UnitCost :=
ROUND(USCurrencyExchRate.ExchangeAmtFCYToLCY(WORKDATE,VendorCurr,VendorCost,CurrencyFactor));
END;
P.S. I am using Exchange Rate from the US company because we do not use those on Mexico.
0
Comments
-
If you follow the logic of the 'ExchangeRate' function, you will see it calls a function 'FindCurrency'. That function uses a new Currency Exchange Rate record (named 'CurrencyExchangeRate2[CacheNo]') to look up the appropriate exchange rate record.
I believe that your problem is that CHANGECOMPANY has not been called on the 'CurrencyExchangeRate2[CacheNo]' record, so it is looking for records in the Mexico company. There are none, therefore the error message.
This is the difficulty with cross-company stuff -- it is a lot more complex than we wish it would be.
To solve your problem, you have to add a function to the Currency Exchange Rate record that you can call before using the 'ExchangeRate' function. This function should take the new company name, and store it in a global text variable. Then you must modify the 'FindCurrency' function so that it calls CHANGECOMPANY on 'CurrencyExchangeRate2[CacheNo]', if a new company name exists in the global text variable.
Use with care... Test extensively... Be afraid, be very afraid...0 -
Thank you a lot FB.
You know something then I will considered synch vendor cost from US company to Mexico and if the vendor has any kind of currency different from USD. I will change those to USD
Paco0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions