Interface methodologies

So now we have discussed interface types, interface technologies, and the built-in interfaces in Microsoft Dynamics NAV.

Let's design and develop a new business to business interface. We will use the objects from Chapter 7, Storage and Logistics, to create the interface.

One of our customers wants to e-mail the shipments from now on instead of faxing. The e-mail will contain an Excel file in a predefined format.

Let's bring back the data model we designed for the logistics part of the solution in Chapter 7, Storage and Logistics.

The design

The process starts in the registration table. From a registration, we generate shipments and shipments are combined into a Route with stops.

So we need to move the data from the Excel sheet to the registration table.

When a customer delivers us an Excel sheet with information, it seldom happens that they exactly use the same fields as our table. Therefore, we need to create a mapping. Each field in the Excel sheet needs to be mapped to a field and missing fields need to be identified and discussed.

The Excel Sheet we get from the customer looks like this:

The mapping

Let's try to map this information to our Logistics Registration Worksheet table, as follows:

Field number

Field name

Data type

Length

Mapped field

1

Registration Batch

Code

10

-

2

Line No.

Integer

 

-

6

Shipment Date

Date

 

Date

8

Product No.

Code

20

Goods Code

10

Description

Text

50

Description

12

Unit of Measure

Text

10

-

16

Quantity

Decimal

 

Pallets

20

Length

Decimal

 

Length

21

Width

Decimal

 

Width

22

Height

Decimal

 

Height

31

Gross Weight

Decimal

 

-

32

Net Weight

Decimal

 

Weight

36

Units per Parcel

Decimal

 

-

37

Unit Volume

Decimal

 

-

53

Ship-to Name

Text

50

Delivery At

55

Ship-to Address

Text

50

Address

57

Ship-to City

Text

30

City

58

Ship-to Contact

Text

50

-

59

Ship-to Post Code

Code

20

Postal Code

60

Ship-to County

Text

30

-

61

Ship-to Country/Region Code

Code

10

-

Most of the fields in the Excel sheet can be mapped to a field in our table.

The implementation of our storage and logistics add-on requires a real-time interface with a Radio Frequency application. The RF scanners are used for the pick process. The RF application uses its own database system with tables we should populate and read afterwards.

The scenario

The RF application has three tables. Our interface needs to export data to the Pick Lines table, and it needs to import data from the two remaining tables, Finished Picks and Exceptions.

To run the interface, we have created three codeunits and a table. The SQL Statement table is used to log each interface session.

The solution

The RF NAS Timer (123.456.730) codeunit is started from the NASHandler function in codeunit ApplicationManagement. It uses an indefinite loop.

The solution

Let's look at the C/AL code that is required to make this work:

The SLEEP function is used to make sure the interface only runs each minute. By breaking the SLEEP function into smaller intervals it is possible to stop the Windows Service that executes this C/AL code in between the SLEEP command.

The RF Helper (123.456.732) codeunit is a wrapper codeunit that is used for error catching and maintaining readability.

During each run of the interface we create a new SQL Statement ID, which we can filter on to trace any errors:

Then the three interface functions are triggered to synchronize the three required tables.

The RF application needs data from the Storage Line table. We first create a mapping to the RF application as we did with the Excel interface earlier in this chapter.

This mapping is saved in a buffer table for traceability:

The actual data is moved to the RF database using an INSERT command.