SAP Connector > Part VI: Data Integration Using IDocs > Mapping and mapping tasks using IDocs > Outbound mapping to read IDocs from SAP example
  

Outbound mapping to read IDocs from SAP example

You can read material master (MATMAS) IDocs from SAP and write it to a relational database object.
In this example to read the MATMAS IDocs, perform the following steps:
Step 1: Import MATMAS metadata using the SAP Metadata utility.
Perform the following steps to import the MATMAS IDoc:
  1. 1. Launch the SAP Metadata utility and specify the SAP connection properties to connect to the SAP system.
  2. 2. Verify that you select the IDoc option and then connect to the SAP system.
  3. The Next button is enabled only after you establish a connection to the SAP system.
  4. 3. Enter the MATMAS as the message type and MATMAS04 as the IDoc type to fetch the IDoc segments and fields for MATMAS.
  5. 4. To read IDocs, select the Interpreter transformation.
  6. 5. Retain the default output directory for the generated mapplet.
Step 2: Import the generated mapplet to Data Integration.
Log in to Data Integration and import the MATMAS mapplet XML file from the output directory.
Step 3: Configure a mapping using the generated mapplet.
Perform the following steps to configure a mapping:
  1. 1. Configure an SAP source. Specify an SAP IDoc Reader connection.
  2. 2. Add the Mapplet transformation. Draw a link to connect the Source transformation to the Mapplet transformation.
  3. 3. Map the incoming IDoc Record field with the IDocData field in the mapplet
  4. 4. Configure the Mapplet transformation. Select the generated Mapplet from the output directory.
  5. 5. Configure a target database object to which you can write the material master details. Draw a link to connect the Control Output Group in the Mapplet transformation to the Target transformation.
  6. Note: Based on your requirement, you can choose to configure multiple target objects for each segment in the IDoc and for the IDoc_Interpreter_Error_Output_Group.

Step 1: Importing MATMAS IDoc metadata

    1. Navigate to the SAP Metadata utility installation directory and double-click the SAPUtil.bat file.
    The Import SAP IDOC/BAPI/RFC wizard appears.
    2. Select the SAP system to which you want to connect.
    All systems specified in the sapnwrfc.ini file appear in the drop-down list.
    3. Enter the SAP user name.
    4. Enter the password associated with the SAP user.
    5. Enter the client number.
    6. Enter the language code.
    7. Select IDoc and click Connect.
    The SAP Metadata utility establishes a connection to the SAP system.
    The following image shows the Connection Properties dialog box in the SAP Metadata utility:
    Specify the properties to connect to the SAP system
    8. Click Next.
    The Step 2: Select SAP IDoc Prepare Transformation page appears.
    9. Enter the message type as MATMAS and the IDoc type as MATMAS04, and click Fetch.
    You can view the segment and field details of the IDoc.
    10. Select the Interpreter transformation and the scope of the transformation as Transaction.
    The following image shows the SAP IDoc specification dialog box:
    Import the MATMAS metadata using the SAP Metadata utility.
    11. Select the segments you want to include in the mapplet.
    You can click Select All Segments to include all segments in the IDoc. You can click Deselect All Segments to remove all selected segments except required segments from the IDoc.
    12. Retain the default directory for the output files and click OK.
    13. Click Finish.
The MATMAS04_Interpreter_Mapping.xml mapplet for the MATMAS IDoc is created in the <SAP Metadata Utility installation directory>/generatedMappings directory.

Step 2: Importing the MATMAS04_Interpreter_Mapping mapplet to Data Integration

    1. To create a mapplet, click Data Integration > New > Mapplets > Mapplet - PC Import and then click Create.
    To edit a mapplet, on the Explore page, navigate to the mapplet. In the row that contains the mapplet, click Actions and select Edit.
    2. Enter an unique name for the IDoc mapplet.
    3. Optionally, enter a description for the IDoc mapplet you want to import.
    The following image shows the Mapplet Details:
    The mapplet name for the IDoc mapplet is displayed.
    4. Select the mapplet type as Active.
    5. Click Upload to navigate to the XML file you generated using the SAP Metadata utility.
    The Upload Metadata XML File dialog box appears.
    6. Click Choose File.
    7. Navigate to the <SAP Metadata Utility installation directory>/generatedMappings directory, select the MATMAS04_Interpreter_Mapping.xml file, and click Open.
    The following image shows the input and output details of the MATMAS04_Interpreter_Mapping mapplet:
    The input and output details are displayed for the selected file.
    8. Click OK.
    You can view the imported mapplet in the Mapplets page.

Step 3: Configuring an outbound mapping with the MATMAS IDoc

    1. To create a mapping, click Data Integration > New > Mappings. Select Mapping and click Create.
    2. Enter a name and description for the mapping, and click OK.
    3. To configure an SAP source, on the Transformation palette, click Source.
    4. In the Properties panel, on the General tab, enter a name and description.
    5. Click the Source tab and select an SAP IDoc Reader connection.
    When you select an SAP IDoc Reader as connection, the source type is a single object and source object is the IDoc Reader Object.
    6. If required, configure the advanced source properties.
    The following image shows the SAP source details:
    On the Source tab, SAP IDoc Reader connection is selected.
    7. To add an IDoc mapplet transformation, on the Transformation palette, click Mapplet.
    8. On the General tab, enter a name and description for the mapplet.
    9. Draw a link to connect the Source transformation to the Mapplet transformation.
    10. On the Mapplet tab, click Select.
    The Select Mapplet dialog box appears.
    11. Specify an IDoc mapplet that you imported using the Interpreter transformation and click OK.
    The following image shows the MATMAS mapplet details:
    On the Mapplet tab, an IDoc mapplet is selected.
    12. To preview the incoming single IDoc Reader Object, click Incoming Fields.
    The following image shows the incoming single IDoc Reader object:
    A list of the incoming single IDoc Reader objects.
    13. Click Field Mappings to map the incoming IDoc Record field with the IDocData field in the mapplet.
    14. To add a Target transformation, on the Transformation palette, click Target.
    15. On the General tab, enter a name and description.
    16. Click the Target tab, and configure the required target database details.
    Note: When you use IDoc Listener as a source, you can specify only those targets that honor commit. Contact Global Customer Support for the list of supported targets.
    17. Draw a link to connect the mapplet groups to the target database object.
    18. Save and run the mapping.