foreignKeyXref()

Performs a lookup in the relationship table in the relationship database based on the foreign key of the source business object, adding a new relationship instance in the foreign relationship table if the foreign key does not exist.

Syntax

public static void foreignKeyXref(String relDefName, 
       String appParticpntDefName, String genParticpntDefName, 
       BusObj appSpecificBusObj, String appForeignAttr,
       BusObj genericBusObj, String genForeignAttr,
       CxExecutionContext map_ctx)
 

Parameters

relDefName
The name of the simple identity relationship name that manages the foreign business object.
appParticpntDefName
The name of the participant definition for the application-specific business object in the simple identity relationship. The type of this participant is the foreign application-specific business object.
genParticpntDefName
The name of the participant definition for the generic business object in the simple identity relationship. The type of this participant is the foreign generic business object.
appSpecificBusbj
The application-specific business object that contains the reference to the foreign object.
appForeignAttr
The name of the attribute in the application-specific business object that contains a key value for the foreign business object.
genericObject
The generic business object to or from which the appSpecificObject is being mapped.
genForeignAttr
The name of the attribute name in the generic business object that contains the generic reference to a foreign business object.
map_ctx
The map execution context. To pass the map execution context, use the cwExecCtx variable, which Map Designer Express defines for every map.

Return values

None.

Exceptions

RelationshipRuntimeException
 

Notes

The foreignKeyXref() method performs a foreign key lookup on the relationship table for the AppParticpntDefName participant; that is, it checks the foreign relationship table for a relationship instance that matches the value in the foreign key of the appSpecificBusObj business object. If this lookup fails, the foreignKeyXref() method adds a new relationship instance for the application-specific key to the foreign relationship table; it does not just set the foreign key in the destination business object to null (as the foreignKeyLookup() method does). This method can be used in both inbound and outbound maps.

The foreignKeyXref() method performs the following validations on arguments that are passed in:

If any of these validations fails, foreignKeyXref() throws the RelationshipRuntimeException exception.

Once the arguments are validated, the action that foreignKeyXref() takes depends on the following information:

The foreignKeyXref() method handles all of the basic adding of relationship instances in the foreign relationship table for the appropriate combination of calling context and verb. For more information on the actions that foreignKeyXref() takes, see "Using the Foreign Key Cross-Reference function block".. Table 89 and Table 90 provide the actions for each of the calling contexts.

Examples

On the Clarify_SFAQuote to Order map, the CustomerId field is a foreign key lookup. This is because Sales Order Processing Collab calls Customer Wrapper.

if (ObjSAP_OrderLineItem.get("SAP_OrderLineObjectIdentifier[0]")
       != null) 
    {
    if (ObjSAP_OrderLineItem.getString(
 "SAP_OrderLineObjectIdentifier[0].ObjectQualifier").equals("002")) 
       {
       BusObj temp = ObjSAP_OrderLineItem.getBusObj(
          "SAP_OrderLineObjectIdentifier[0]");
       if (temp.isNull("ItemId")) 
          {
          logWarning(5003,
    "SAP_OrderLineItem.SAP_OrderLineObjectIdentifier[1].ItemId");
          }
       else 
          {
          try 
             {
             IdentityRelationship.foreignKeyXref(
                "Item", 
                "SAPMbasc", 
                "CWItba",
                temp, 
                "ItemId", 
                ObjOrderLineItem, 
                "ItemId", 
                cwExecCtx);
             } 
          catch (RelationshipRuntimeException re) 
             { 
             logWarning(re.getMessage()); 
             }
  
          if (ObjOrderLineItem.get("ItemId") == null )
             {
             logError(5009, "OrderLineItem.ItemId",
          "SAP_OrderLineItem.SAP_OrderLineObjectIdentifier.ItemId", 
                "Item", 
                "SAPMbasc", 
                strInitiator);
  
             throw new MapFailureException("ForeignKeyXref() failed");
             }
          }
       }
    }
 

See also

foreignKeyLookup()

"Performing foreign key lookups"

Copyright IBM Corp. 2003