Talend example to connect to SAP

Before proceeding with the ETL process to load the fact table sales, we pause to see how to use Talend to connect to SAP using tSapConnection components, and tSapOutput tSapInput.In our project, we could have used these components to make reading data from the ERP (but we used the component tOracleInput to read directly from the database). Although the SAP component of Talend is free to use it you need a Java library provided by SAP (sapjco.jar), we'll have installed in our system. This library can be downloaded only if they are registered users Sap (http://service.sap.com/connectors ). Sapjco version we have installed is 2.1.8 (there is a post, the 3.0.4, but that does not work Talend). How to install the library sapjco.jar is:

  • Once downloaded the appropriate file (depending on the version of operating system you're using), unzip it into a directory of your choice.The test, in our case, we have made using Windows Vista.
  • If you have an older version of the dll librfc32.dll in the windows system32 directory, substitute it with the coming of Sap.
  • Include the installation directory in the PATH environment variable (in our case c: \ sapjco).
  • Finally, we add to the CLASSPATH environment variable sapjco.jar file with full path (for example, CLASSPATH = c: \ sapjco \ sapjco.jar).

Then install the library in the directory of classes and found that Talend is properly installed.To do this, we drop the file in the directory sapjco.jar <directorio_instalacion_talend> \ lib \ java. Talend then opened, and the Modules tab, check that appears sapjco.jar module installed correctly (as we see in the picture).

Finally, we will see a practical example SAP connection to retrieve information using function modules (RFC) implemented in SAP and which can be accessed from Talend (this is really what allows us to make the component, accessed through Sap their RFC'sy BAPIs). The RFC's (Remote Function Call) are the basis for communication between SAP and any external system.Are components of programming (ABAP program, for example), encapsulated in a function, with a corresponding interface input and output data, which also can be called from within the SAP, or remotely if enabled " Remote Access Module "(as we see in the picture below). In this case, is when we call, for example, from Talend.

Definition of the RFC "RFC_READ_TABLE" in Sap

Sap has scheduled many RFC's as standard, and also we can build ours with code that performs the tasks you want.In addition, there is another type of RFC's within SAP, BAPIs calls, including additional rules integrated with the SAP application operation (eg, the BAPI BAPI_SALESORDER_CREATEFROMDAT2 allows the creation of a sales order from the data we pass to the function in the interface).

Example: Reading the contents of a table using the RFC "RFC_READ_TABLE."

We will conduct a Job in Talend to read the contents of a table in SAP, in particular, we will retrieve all materials that are of a certain type.The full Job is structured as follows:

In Talend tSapInput use the component to the RFC call to SAP. To do this, we must know what is the interface that has defined this in Sap to know that we can pass parameters and results and what kinds of data structures can receive. In transaction SE37 of Sap can see are defined as function modules, and see how it will perform communication with that component. For example, RFC_READ_TABLE function module (as shown in the picture below), has 5 input parameters defined in the Import tab.Which we will use in our example are: QUERY_TABLE (the table you want details), DELIMITER (delimiter for the data).

RFC definition Sap - Import (input parameters)

There is also the Export tab, where we could see that we have output parameters (in the case of variables or simple structures).In the case of working with tables, they will appear in the Tables tab. Tables are complex structures of Sap (as an array of data.) Tables can be used both to receive data from the RFC to pass them. In our example, use the DATA table to receive the records retrieved from the database.

RFC definition Sap - Tables (parameters Input / Output)

Then again Talend and will complete the various fields of the component:

  • Client: Sap principal of which will recover the data.
  • Userid: user for the connection.Must have permissions to execute the RFC and to access the desired data.
  • Password: password.
  • Language: switching language.
  • Host Name: Host where the server is located Sap.
  • System Number: SAP instance number of the server (usually the 00 where there is only one server).
  • Function name: Name of RFC to which we rely.

Example Usage tSapInput component

  • Initialize input: initialization of the input parameters.Are the values ​​we pass to the function block. In our case, we observe that we have passed simple values ​​(variables) and values ​​we have also passed some of the tables.
    • Single Input: parameters "QUERY_TABLE" and "DELIMITER" are input_single type (single-entry) and wiping initialize a value, namely the name of the table you want to read and the delimiter to use.
    • Table input: enter values ​​in two tables.Table OPTIONS TEXT field, indicate a condition to restrict the reading of data (like a condition where). Table FIELDS, FIELDNAME field, we tell Sap which fields of the table are those who want to recover (in this case the source of the material, its type and product line). In this way, we limit both the number of records returned, as the fields obtained (do not want to see all fields of each record in this table.) See how to specify multiple values ​​for the field FIELDNAME FIELDS table, we have multiple entries separated by commas.
  • Outputs: definition of the structures where we will manage the data returned by Sap.Here indicate the type of retrieved value (table_output for when the result is a table), the name of the table in Sap (TableName field (Structure Name) and name of the Schema (be a name for the data flow, we put any). In our example, we read of the DATA Sap table, a table of records, each record has a unique field called WA. The steps in this section for a proper definition of exchange details are as follows:
  • We first output stream down the button of the sign "+". Schema clicked on will give a name to this flow (registros_devueltos in our example) and indicate the fields that make the outlet structure tSapInput component.In this case, we will only have a field called WA (as we see in the picture), which corresponds to the DATA table field of Sap.

Definition of the output structure "registros_devueltos"

  • It is then necessary to associate this column to Sap component where data is retrieved. To do this click on the Mapping field, and we will open a new window. Here we flow appeardata defined in the previous step but the field XPatchQuerys Schema, which is what allows us Talend Map the field to the field of SAP data dictionary, so you can receive data correctly Sap (values ​​should be introduced in XPatchQuerys enclosed in double quotes, using the symbol ").
Mapping between the structure of output and the Sap Talend

In this example, we have a relatively simple way to retrieve data from SAP into a single control.Knowing the different existing RFCs and BAPIs SAP, we can surely much more complex tasks and take advantage of functionality that are defined in Sap. It may even be a way of interfacing with SAP using these components already defined and packaged. To see in detail how we define each component, you can access the full HTML documentation generated by Talend here . You can download the zip file containing the documentation here