Click or drag to resize

clsImportExchangeRateSBO Class

Changes an exchange rate for a time range in SAP Business One via DI-API.

Please make sure, that SAP Business One DI-API in 32 or 64 bit is installed according to the usage of this interface. The logon user in MARIProject has to have a corresponding user linked to the selected company database.

Use MPInterface.bImportExchangeRateSBO(clsImportExchangeRateSBO, clsImportBaseeImportMode) to import.

Inheritance Hierarchy
SystemObject
  MARIInterfaceclsImportBase
    MARIInterfaceclsImportExchangeRateSBO

Namespace:  MARIInterface
Assembly:  MARIInterface (in MARIInterface.dll) Version: 8.0.0.100
Syntax
public class clsImportExchangeRateSBO : clsImportBase

The clsImportExchangeRateSBO type exposes the following members.

Constructors
  NameDescription
Public methodclsImportExchangeRateSBO
Initializes a new instance of the clsImportExchangeRateSBO class
Top
Methods
Fields
  NameDescription
Public fieldCompanyID
Internal company id from the MARIProject Database. Default=1.
Public fieldCurrency
ISO Currency Code. Has to be different to the system currency of MARIProject.
Public fieldDateFrom
Date for the new exchange rate. When DateTo is empty, only the this date is changed.
Public fieldDateTo
This date can be used to define a range for the new exchange rate. If null, only DateFrom is used.
Public fieldExchangeRate
ExchangeRate Between the Currency and the MARIProject System Currency
Top
Remarks
Examples
Set a day exchange rate in SBO via DI-API
/// <summary>
/// Push daily rate to SBO via DI-API/Service Layer
/// </summary>
/// <param name="ISOCurrCode">ISO: EUR, USD, CAD</param>
/// <param name="cRate">1.1</param>
/// <param name="dtDayForRate">Day</param>
/// <param name="nCompanyID">1,2,3 based on the MPSysConnections table in MARIProject</param>
/// <returns></returns>
private bool FillExchangeRate(string ISOCurrCode, decimal cRate, DateTime dtDayForRate, short nCompanyID) {

    clsImportExchangeRateSBO oNewRate = new clsImportExchangeRateSBO();
    oNewRate.Currency = ISOCurrCode; // USD versus system currency EUR. or CAD versus system currency USD
    oNewRate.ExchangeRate = cRate; // Depending on the settings in the SBO database the rate has to be used as USD/EUR or EUR/USD
    oNewRate.DateFrom = dtDayForRate;
    oNewRate.DateTo = dtDayForRate;
    oNewRate.CompanyID = nCompanyID; // Linked company database to MARIProject (default=1)
    if (oMPInterface.bImportExchangeRateSBO(oNewRate, MARIInterface.clsImportBase.eImportMode.ValidateAndImport)) {
        Log($"FillExchangeRate({ISOCurrCode},{cRate},{dtDayForRate.ToShortDateString()}) Saved.");
        return true;
    } else {
        LogFail($"FillExchangeRate({ISOCurrCode},{cRate},{dtDayForRate.ToShortDateString()}): {oMPInterface.oErrors.PrintErrors()}");
        return false;
    }
}
See Also