SAP Connector > Part VI: Data Integration Using IDocs > Mapping and mapping tasks using IDocs > Inbound mapping to write IDocs to SAP example
  

Inbound mapping to write IDocs to SAP example

You can create material master (MATMAS) in SAP using MATMAS IDoc type.
In this example to write MATMAS IDoc to SAP, 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 MATMAS03 as the IDoc type to fetch the IDoc segments and fields for MATMAS.
  5. 4. To write IDocs, select the Prepare 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 multiple flat file sources to provide data to the mapplet input fields.
  2. 2. Add the Mapplet transformation. Draw a link to connect the Source transformation to the Mapplet transformation.
  3. 3. Configure the Mapplet transformation. Select the generated mapplet from the output directory.
  4. 4. Configure an SAP object to write the material master details and a flat file object to write the error details. Draw a link to connect the IDoc_Prepare_Output_Group_For_MATMAS03 to the IDocWriter object. Draw another link to connect the IDoc_Prepare_Error_Output_Group_For_MATMAS03 to the Error_Output flat file object.

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.
    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 MATMAS03, and click Fetch.
    You can view the segment and field details of the IDoc.
    10. Select the Prepare transformation and the scope of the transformation as All Input.
    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. To add other fields into the Control Record input group of a mapplet, perform the following steps:
    1. a. Click Control Page. Add more control records if you have more than one logical system.
    2. b. Select the checkbox for the field that you want to add, and then click Partner Profile > New .
    3. c. Enter the key and value for the partner profile. The key is the field name, and the value is the partner type.
    4. d. Optionally, to add a control record field to the mapplet, from the Control Record page, select the checkbox for the field you want to add. This will enable you to map the selected control record fields when you configure a mapping, integration template, or mapping task.
    13. Retain the default directory for the output files and click OK.
    14. Click Finish.
The MATMAS03_Prepare_Mapping.xml mapplet for the MATMAS IDoc is created in the <SAP Metadata Utility installation directory>/generatedMappings directory.

Step 2: Importing the MATMAS03_Prepare_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.
    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 MATMAS03_Prepare_Mapping.xml file, and click Open.
    8. Click OK.
    You can view the imported mapplet in the Mapplets page.

Step 3: Configuring an inbound 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 a flat file 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 flat file connection.
    6. Add separate flat file sources for the control_input group and segments in the MATMAS IDoc.
    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. On the Mapplet tab, click Select.
    The Select Mapplet dialog box appears.
    10. Specify an IDoc mapplet that you imported using the Prepare transformation and click OK.
    11. Draw a link to connect the Source transformations to the Mapplet transformation. For example, connect the Control_Input source object to the Control_Input_Group for the MATMAS IDoc.
    12. To preview the incoming fields, click Incoming Fields.
    The following image shows the incoming fields:
    The configured incoming fields is displayed.
    13. Click Field Mappings to map the incoming fields with the mapplet input fields.
    The following image shows the field mapping in the mapplet:
    The Incoming Fields is mapped with the mapplet input fields to configure an inbound mapping.
    14. To add a Target transformation for writing to SAP, on the Transformation palette, click Target.
    1. a. On the General tab, enter a name and description.
    2. b. Click the Target tab and configure SAP target details.
    15. To add a flat file Target transformation for the error output, on the Transformation palette, click Target.
    1. a. On the General tab, enter a name and description.
    2. b. Click the Target tab and configure flat file target details.
    16. Draw a link to connect the IDoc_Prepare_Output_Group_For_MATMAS03 to the IDocWriter object. Draw another link to connect the IDoc_Prepare_Error_Output_Group_For_MATMAS03 to the Error_Output flat file object.
    The following image shows the mapping for the inbound mapping for the MATMAS IDoc:
    Configured inbound mapping with the MATMAS IDoc.
    17. Save and run the mapping.