How to import exchange rates using B1if

Hi There,

In response to the beautiful article by Atilla Aykut Genç, Updating Exchange Rates Automatically in SAP Business One, I would like to explain how to obtain the same result using SAP Business One Integration Framework (B1if).

This is a basic solution to import exchange rates, implemented some times ago while studying B1if.

It has beem tested on an SAP Business One 9.0 environment.

Scenario

Import exchange rates from European Central Bank at a scheduled time using B1if.

The main advantage of using B1if is that no programming knowledge is needed, except a little XSL a XPath.

It also does not need any system privilege on the B1if server to install and run services, view logs, schedule tasks, etc

How To

Step 1: Create a Scenario Package

Create a new scenario package as the image below

Step 2: Create a new Scenario Step

Create a new step, assign it to the package created at Step 1.

Define Inbound as Void (Timer based):


Don’t forget to define your Timer. Save and Close.


Define Outbound as void also, save your step.


Step 3: Processing


Here is the processing flow:

atom3

This atom prepares the connection information for the httpcall (atom2).

  

atom2

This atom calls www.ecb.europa.eu and get Exchage Rates XML.

Note that Stop processing if fails is set to false, letting the step to continue and to be handed over later, at atom0. You could define an SLD entry for Reference for connectivity.

atom8

This atom calls SQL and get DirectRate / IndirectRate from OADM and gets all the currencies configured in your SAP Business One Company.

Note: select your SLD entry SysId. See documentation to find out how to configure it at runtime.

brach/path

This verifies we had a readable XML from ECB.

atom7

This atom prepares the for-each loop that calls SBObob function to insert/update exchange rates. It also checks against atom8_2 result (list of defined currencies in Company) and prepare an ExchageRate nodeset.

  

for-each

Loops thru ExchangeRate nodes generated by atom7 XSL.

The for-each atom xpath  expression is

 /vpf:Msg/vpf:Body/vpf:Payload[./@id='atom7']/ExchangeRate 

B1 Function

This is the call to GetCurrencyRate of SBObob object. This is the same call as DI API, so you can use SDK help to get reference. B1if, in this case, has poor help.


Note: again you have to select for the right SysId.


Parameters:


Parameters is an X-Path that gets the full parameters string passed to SetCurrencyRate SBObob function.


concat(/ExchangeRate/@currency, ",", /ExchangeRate/@date, ",", /ExchangeRate/@rate, ",true")

atom4

This atom corrects the join-unbranch flow and ensure a valid output message. It can be generated by B1if by pressing Generate button in the definition window.

  

final (atom0)

In this example a final result and error notification are not managed.

Results


This is what I get at atom0 during a Test:


  

Notes

  • Thanks to Atilla who give me the idea to write this little article.
  • For production environment you would add error management, some Configuration (SysId entries), maybe user notification (SAP Business One internal messaging, email, etc).
  • Different web servers may respond with different XML so this scenario will actually work with ECB only.
  • Please note that this is my very first document here in SCN: don’t hesitate to inform me if there’s something wrong or something that could be done better!

Regards,

Pierre

New NetWeaver Information at SAP.com

Very Helpfull

User Rating: Be the first one !
Comments (0)
Add Comment