Scenario 2: Retrieving data from an SAP system by calling a BAPI function using document type parameters - 6.1

Talend Components Reference Guide

EnrichVersion
6.1
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

This scenario describes a Job that retrieves data from a table named SFLIGHT in an SAP system by calling the BAPI function RFC_READ_TABLE with defined input and output parameters of type Document.

Prerequisites:

The SAP connection has been set up in the Repository tree view, with

  • the RFC_READ_TABLE function retrieved and saved under the SAP Bapi folder of the SAP connection,

  • and the XML metadata for the input and output schemas of the RFC_READ_TABLE function retrieved and saved under the File xml node.

For more information about how to set up an SAP connection and retrieve SAP functions and SAP function schemas as XML metadata, see Talend Studio User Guide.

Adding the components

  1. Create a Job and drop the node RFC_READ_TABLE in the SAP Bapi folder of the SAP connection onto the design workspace as a tSAPBapi component to reuse the connection to the SAP system.

  2. Add the following components to the Job by typing theirs names in the design workspace or dropping them from the Palette:

    • a tFixedFlowInput component: to generate the input data flow.

    • two tXMLMap components: to map and transform the input and output data flows respectively.

    • three tLogRow components: to display the output data corresponding to the DATA, FIELDS, and OPTIONS output parameters respectively.

Configuring the components

Configuring the input component

  1. Double-click tFixedFlowInput to open its Basic settings view on the Component tab.

  2. Click the [...] button next to Edit schema to open the schema editor to define the input schema. In this example, the input schema is composed of four columns: DELIMITER and QUERY_TABLE of string type, and ROWCOUNT and ROWSKIPS of integer type.

  3. In the Mode area, select the Use Single Table option and specify the value for each column. In this example, ";" for the DELIMITER column, "SFLIGHT" for the QUERY_TABLE column, 10 for the ROWCOUNT column, and -1 for the ROWSKIPS column.

  4. Connect tFixedFlowInput to the first tXMLMap using a Row > Main connection.

Configuring the tSAPBapi component

  1. Double-click tSAPBapi to open its Basic settings view on the Component tab.

  2. Clear the tick it to enable multiple input/output;not tick it to enable document check box to allow using input and output parameters of type Document.

  3. Click the [...] button next to Edit schema to open the schema editor.

  4. Click the [+] button to add a column doc of type Document.

    When done, click OK to close the schema editor.

  5. Right-click the first tXMLMap, select Row > *New Output* (Main) from the contextual menu and click tSAPBapi. In the pop-up dialog box, enter in and then click OK and accept schema propagation from the target component tSAPBapi. The first tXMLMap will be connected to tSAPBapi using a link named in (Merge order:1).

Mapping the input data flow

  1. Double-click the first tXMLMap to open its map editor. In the in table on the right side, right-click the node doc and select Import From Repository from the contextual menu.

  2. In the pop-up [Metadata] dialog box, select Input_Schema in the folder RFC_READ_TABLE and click OK to close the dialog box. The schema is added to the XML tree.

  3. Drag and drop all columns in the input table main:row1 on the left side to the corresponding elements in the in table on the right side. Then in the in table, delete the other elements that do not need an input value.

  4. Click OK to save the settings and close the map editor.

  5. Connect tSAPBapi to the second tXMLMap using a Row > Main connection.

Mapping the output data flow

  1. Right-click the second tXMLMap, select Row > *New Output* (Main) from the contextual menu and click the first tLogRow. In the pop-up dialog box, enter DATA and then click OK. The second tXMLMap will be connected to the first tLogRow using a connection named DATA (Main order:1).

  2. Do the same to connect the second tXMLMap to the second tLogRow using a connection named FIELDS (Main order:2), and to the third tLogRow using a connection named OPTIONS (Main order:3).

  3. Double-click the second tXMLMap to open its map editor. In the main:row2 table on the left side, right-click the node doc and select Import From Repository from the contextual menu. In the pop-up [Metadata] dialog box, select Output_Schema in the folder RFC_READ_TABLE and click OK to close the dialog box. The schema is added to the XML tree.

  4. Drag and drop the node WA under the DATA element in the input table main:row2 on the left side into the DATA table on the right side.

  5. Do the same to drag and drop the nodes FIELDNAME, OFFSET, LENGTH, TYPE, and FIELDTEXT under the FIELDS element in the input table main:row2 on the left side into the FIELDS table on the right side, and drag and drop the node TEXT under the OPTIONS element in the input table main:row2 on the left side into the OPTIONS table on the right side.

  6. Right-click the item node under the DATA node and select As loop element from the contextual menu to set it as the loop element.

  7. Do the same to set the item nodes under the FIELDS and OPTIONS nodes as the loop element.

  8. Click the set Loop Function button on the upper-right corner in the DATA table to configure the source loop.

    Click the [+] button to add a row, and then click in the Xpath field and select the source loop row2.doc:/RFC_READ_TABLE/TABLES/DATA/item from the drop-down list. When done, click OK to close the dialog box.

  9. Do the same to set the source loop for the FIELDS and OPTIONS tables to row2.doc:/RFC_READ_TABLE/TABLES/FIELDS/item and row2.doc:/RFC_READ_TABLE/TABLES/OPTIONS/item respectively.

  10. Click OK to close the map editor.

Configuring the output components

  1. Double-click the first tLogRow to open its Basic settings view on the Component tab.

  2. Click the Sync columns button to retrieve the schema from the preceding component.

  3. In the Mode area, select Table (print values in cells of a table) for a better display of the result.

  4. Do the same to configure the second and the third tLogRow components.

Saving and executing the Job

  1. Press Ctrl + S to save the Job.

  2. Press F6 to run the Job.

    As shown above, ten rows of data from the SFLIGHT table is retrieved and displayed on the console.