You can find the code for this example in the ERPConnect installation directory in the LINQBapi directory.

Because the terms function modules and BAPIs are almost equivalent, we only speak of BAPIs in the following. In the LINQ application, BAPIs are handled nearly the same way as stored procedures in LINQ to SQL. Drag a function object from the toolbox to the prepared DataContext. The selection of the BAPI is made with the search dialog.

LINQToERP-Function-Modules-001

The following screenshot shows the dialog for editing the function object. If a parameter is to be filled later dynamically in the code when calling it, a checkmark has to be made in the Pass column. Alternatively, a static value can also be entered in the Value cell.

LINQToERP-Function-Modules-002

Working with tables is similar. You can either make transfers to a function as a table object or as a return value. The variable name, the name of the table class and the name of the row class can also be specified. If the fields remain empty, default names will be generated.

LINQToERP-Function-Modules-003

The following code shows how the above example is addressed with an actual parameter and with a return value table.

Click to open C# example.
SAPContext sc = new SAPContext("TestUser","SECRET01");
var MyEmpls = sc.BAPI_EMPLOYEE_GETLIST("T*"); 
foreach (var Empl in MyEmpls) 
   Console.WriteLine(Empl.PERNR + " " + Empl.ENAME); 
Console.ReadLine();
Click to open VB example.
Dim sc As New LINQTable.SAPContext("TestUser", "SECRET01") 
  
Dim MyEmpls = From t In sc.BAPI_EMPLOYEE_GETLIST("T*") Select t 
  
For Each Empl In MyEmpls 
   Console.WriteLine(Empl.PERNR & " " & Empl.ENAME) 
Next 
  
Console.ReadLine()

LINQToERP-Function-Modules-004