foreignKeyLookup()

Performs a lookup in a foreign relationship table based on the foreign key of the source business object, failing to find a relationship instance if the foreign key does not exist in the foreign relationship table.

Syntax

public static void foreignKeyLookup(String relDefName, 
       String appParticpntDefName, BusObj
  appSpecificBusObj,       String appForeignAttr,
        BusObj genericBusObj,
 String genForeignAttr, CwExecutionContext map_ctx)
 

Parameters

relDefName
The name of the simple identity relationship that manages the foreign business object.

appParticpntDefName
The name of the participant definition that represents the application-specific business object in the simple identity relationship. The type of this participant is the foreign application-specific business object.

appSpecificBusObj
The variable that contains the application-specific business object, which contains the reference to the foreign business object.

appForeignAttr
The name of the attribute in the application-specific business object that contains a key value for the foreign business object.

genericBusObj
The variable that contains 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 foreignKeyLookup() 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 foreignKeyLookup() method just sets the foreign key in the destination business object to null; it does not insert a row in the foreign relationship table (as the foreignKeyXref() method does). This method can be used in both inbound and outbound maps.

Examples

On the Clarify_PartRequest to Requisition object, the VendorId field is a foreign key lookup. This is because Purchasing does not call Vendor Wrapper. We do not use the foreignKeyXref() method here because we do not want to insert a row if the lookup fails.

if (ObjCustomerRole.isNull("RoleId")) 
    {
    logError(5003, "OrderAssociatedCustomers.RoleId");
    // throw new MapFailureException("OrderAssociatedCustomers.RoleId 
    // is null");
    }
  
 try 
    {
    IdentityRelationship.foreignKeyLookup("Customer", "SAPCust",
          ObjSAP_OrderPartners, "PartnerId", ObjCustomerRole,
          "RoleId", cwExecCtx);
    } 
  
 catch (RelationshipRuntimeException re) 
    {
    logWarning(re.getMessage());
    }
 if (ObjSAP_OrderPartners.get("PartnerId") == null)
    {
    logError(5007, "SAP_OrderPartners.PartnerId",
       "OrderAssociatedCustomers.RoleId", "Customer", "SAPCust",
       strInitiator);
    throw new MapFailureException("ForeignKeyLookup failed");
    }
 

See also

foreignKeyXref()

"Performing foreign key lookups"

Copyright IBM Corp. 1997, 2003