Mapping child business objects

When the source business object contains child business objects, how you map the child business object depends on the cardinality of the child in the source and destination business objects. This section provides information on how to map child business objects in the following cases:

Mapping single-cardinality source and destination

To map a single-cardinality source child business object to a single-cardinality destination business object:

Example: This kind of mapping would be needed for the following map:

SAP_CustomerMaster

to

Customer.CustomerAddress

Mapping single-cardinality source to multiple-cardinality destination

If the source child business object is of cardinality 1, it contains data to be mapped only to a single instance of the destination child business object. To map a single-cardinality source child object to a multiple-cardinality destination child object, follow the procedure described in Mapping single-cardinality source and destination. There is no need to create a submap.

Example: This kind of mapping would be needed for the following map:

SAP_CustomerMaster.SAP_CustCreditCentralData[1]

to

Customer.CustomerInformation.CustomerCreditData[n]

Mapping multiple-cardinality source and destination

To map a multiple-cardinality source child business object to a multiple-cardinality destination business object, you need to create a multiple-cardinality submap. For an introductions to submaps, see Transforming with a submap.

Example: This kind of mapping would be needed for the following map:

SAP_CustBankData[n] 

to

Customer.CustomerInformation.CustomerBankData[n]

When you transform multiple source business objects of the same type, perform the subtasks outlined in Table 67.

Table 67. Creating a multiple-cardinality submap
Subtask Associated procedure (see . . . )
1. Creating a multiple-cardinality submap, which performs the transformations for attributes in one source object to one destination business object. Steps for creating the multiple-cardinality submaps
2. Calling this submap from the main map, in the multiple-cardinality attribute of the destination business object. The call to the submap is within a for loop that loops through each business object within the multiple-cardinality object so that each business object is passed to the submap. Steps for calling the multiple-cardinality submap

Steps for creating the multiple-cardinality submaps

To create a submap that maps multiple-cardinality child objects from the source to destination object, you create a map with a single source business object and the single destination business object. This map contains the transformations for attributes in the source object to the corresponding attributes in the destination object.

To create a multiple-cardinality submap, perform the following steps from within Map Designer Express:

  1. Close your main map and start a new map.
  2. In the Diagram tab, drag the source child business object into the left half of the map workspace area and the destination child business object into the right half.

    To map the SAP_CustBankData business object to the Customer.CustomerInformation.CustomerBankData business object, drag SAP_CustBankData into the left half of the workspace and CustomerBankData into the right half.

  3. Save the submap.

    Recommendation: You should begin submap names with the prefix "Sub_". For example: Sub_SaCwCustBankData.

  4. Set the verb of the destination object as described in Setting the destination business object verb.
  5. Map individual attributes as described in Specifying standard attribute transformations and More attribute transformation methods.
  6. Compile the submap by selecting Compile from the File menu.

    Result: If everything is correct, the following message displays:

    Map validation OK.
    Map compilation successful.

Tip:
If you forget to compile the submap, you cannot see it in the Submap dialog. The message No submaps available displays.

Steps for calling the multiple-cardinality submap

To call the multiple-cardinality submap, call it with the runMap() method from the main map, in the multiple-cardinality attribute of the destination business object. The call to the submap is within a for loop that loops through each business object within the multiple-cardinality object so that each business object is passed to the submap.

To call a multiple-cardinality submap, perform the following steps from within Map Designer Express:

  1. Close the submap and open the main map.
  2. Select the source child object and the destination child object and select Submap from the transformation rule's combo box.

    For the SAP_CustBankData to Customer.CustomerInformation.CustomerBankData transformation, select SAP_CustBankData and CustomerBankData.

    Result: The Submap dialog box displays.

  3. Select the name of the submap and click OK.

    Example: Sub_SaCwCustBankData

    In this example, you do not need to specify a condition, so click OK.

  4. Open the Activity Editor of the destination child object.

    For the SAP_CustBankData to Customer.CustomerInformation.CustomerBankData transformation, you see code similar to the following in Activity Editor:

    {
    BusObjArray srcCollection_For_ObjSAP_Order_SAP_OrderPartners =
       ObjSAP_Order.getBusObjArray("SAP_OrderPartners");
    
    //
    // LOOP ONLY ON NON-EMPTY ARRAYS
    // -----------------------------
    //
    // Perform the loop only if the source array is non-empty.
    //
    if ((srcCollection_For_ObjSAP_Order_SAP_OrderPartners != null) &&
          (srcCollection_For_ObjSAP_Order_SAP_OrderPartners.size() > 0))
       {
       int currentBusObjIndex_For_ObjSAP_Order_SAP_OrderPartners;
       int lastInputIndex_For_ObjSAP_Order_SAP_OrderPartners =
       srcCollection_For_ObjSAP_Order_SAP_OrderPartners.getLastIndex();
       for (currentBusObjIndex_For_ObjSAP_Order_SAP_OrderPartners = 0;
          currentBusObjIndex_For_ObjSAP_Order_SAP_OrderPartners <=
          lastInputIndex_For_ObjSAP_Order_SAP_OrderPartners;
          currentBusObjIndex_For_ObjSAP_Order_SAP_OrderPartners++)
          {
          BusObj currentBusObj_For_ObjSAP_Order_SAP_OrderPartners =
    (BusObj) (srcCollection_For_ObjSAP_Order_SAP_OrderPartners.elementAt(
          (currentBusObjIndex_For_ObjSAP_Order_SAP_OrderPartners));
    
          //
          // INVOKE MAP ON VALID OBJECTS
          // ---------------------------
          //
          // Invoke the map only on those child objects that meet certain
          // criteria.
          //
          if (currentBusObj_For_ObjSAP_Order_SAP_OrderPartners != null)
             {
             BusObj[] _cw_inObjs = 
                { currentBusObj_For_ObjSAP_Order_SAP_OrderPartners };
             BusObj[] _cw_outObjs =
                DtpMapService.runMap(
                "Sub_SaOrderPartners_to_CwCustomerRole", "CwMap",
                _cw_inObjs, cwExecCtx);
       ObjOrder.setWithCreate("AssociatedCustomers",
                _cw_outObjs[0]);
             }
          }
       }
    }

    Notice that runMap() is a static method, so it is invoked as:

    DtpMapService.runMap()
  5. Make a few changes to this code, as follows:

    Here is the modified code (changes are highlighted in bold):

       {
       BusObjArray srcCollection_For_ObjSAP_
    Order_SAP_OrderPartners =      ObjSAP_Order.getBusObjArray("SAP_OrderPartners");
              
       //
       // LOOP ONLY ON NON-EMPTY ARRAYS
       // -----------------------------
       //
       // Perform the loop only if the source array is non-empty.
       //
       if ((srcCollection_For_ObjSAP_Order_SAP_OrderPartners
          != null) &&
             (srcCollection_For_ObjSAP_Order_SAP_OrderPartners.size()
        > 0))
          {
          int currentBusObjIndex_For_ObjSAP_Order_SAP_OrderPartners;
          int lastInputIndex_For_ObjSAP_Order_SAP_OrderPartners =
             srcCollection_For_ObjSAP_Order_SAP_OrderPartners.getLastIndex();
              
          for (currentBusObjIndex_For_ObjSAP_Order_SAP_OrderPartners
        = 0;
               currentBusObjIndex_For_ObjSAP_Order_SAP_OrderPartners
        <=
               lastInputIndex_For_ObjSAP_Order_SAP_OrderPartners;
               currentBusObjIndex_For_ObjSAP_Order_SAP_OrderPartners++)
             {
               BusObj currentBusObj_For_ObjSAP_Order_SAP_OrderPartners =
     (BusObj) 
                   (srcCollection_For_ObjSAP_Order_SAP_OrderPartners.elementAt(
               currentBusObjIndex_For_ObjSAP_Order_SAP_OrderPartners));
                          
             //
             // INVOKE MAP ON VALID OBJECTS
             // ---------------------------
             //
             // Invoke the map only on those child objects that meet 
                certain
             // criteria.
             //
             if (currentBusObj_For_ObjSAP_Order_SAP_OrderPartners != null)
                {
                currentBusObj_For_ObjSAP_Order_SAP_OrderPartners.setVerb(
                   ObjSAP_Order.getVerb());            BusObj[] _cw_inObjs
     
                =  { currentBusObj_For_ObjSAP_Order_SAP_OrderPartners };
    
                try 
                   {
                   BusObj[] _cw_outObjs = DtpMapService.runMap(
                      "Sub_SaOrderPartners_to_CwCustomerRole", "CwMap", 
                      _cw_inObjs, cwExecCtx);
                   ObjOrder.setWithCreate("AssociatedCustomers", _cw_outObjs[0]);
                   }
                catch (MapNotFoundException me) 
                   {
                   logError(5502, "Sub_SaOrderPartners_to_CwCustomerRole");
                   throw new MapFailureException ("Submap not found");
                   }            }
             }
          }
       }
  6. Once you have added the call to the submap, recompile the main map.

Copyright IBM Corp. 2004, 2005