LINQ to SAP

Microsoft has heralded in a new age of external data access with LINQ (Language Integrated Query). LINQ to SQL, for example, allows you to access the data on an SQL server. From version 3.0 and up, ERPConnect also contains a so-called LINQ provider. In such, LINQ to SAP is an add-on for the traditional ERPConnect.


The following code shows how the SAP table MAKT (material texts) is accessed. The actual query is integrated in the code. Output is further processed with the help of a loop. In contrast to other types of calls, LINQ to SAP is 100% type-safe and offers total IntelliSense support.



The LINQ to SAP Designer is seamlessly integrated in Visual Studio 2008.



In addition to table calls, LINQ to SAP also supports BAPIs. The code example below shows the execution of the BAPI_EMPLOYEE_GETLIST module, which outputs a list based on a search term. The parameters and tables available in the function are defined in the Designer. This way the code remains clear and concise; in a best-case scenario, the call is reduced to a single line.





SAP queries from the SQ01 and SQ02 transactions are highly suitable for further processing with LINQ to SAP. The selection parameters can be filled in as needed, either statically (i.e. in the Designer) or dynamically (in the code).





In conclusion, the following snippet of code shows BW objects being called. If you have query variables, these can either be directly filled in the LINQ code or, again, statically filled. All BW releases from 3.0 and up are supported.