Polymorphic mapping allows a single source business object to map to one of many potential destination business objects. To do this form of mapping, you must:
Example: Below is sample code from the first attribute in one of the destination business objects in a main polymorphic map. In this example, ObjInput is the Instance variable for the source business object, ObjOutput1 is the Instance variable for the output object which contains this code, and InputToOutput1 is the submap which performs the actual mapping from ObjInput to ObjOutput1. In this case, the condition which dictates whether this mapping occurs is based on the value of the Attr1 attribute within the source business object. Your condition will obviously vary.
BusObj[] rSrcBO = new BusObj[1]; BusObj[] rDstBO = new BusObj[1]; rSrcBO[0] = ObjInput; String Attr1Val = ObjInput.getString("Attr1"); if (Attr1Val.equals("Poly1")) { try { rDstBO = DtpMapService.runMap("InputToOutput1", DtpMapService.CWMAPTYPE,rSrcBO,cwExecCtx); ObjOutput1.setContent(rDstBO[0]); } catch (MapFailureException e) { e.toString(); e.printStackTrace(); raiseException(e); } catch (MapNotFoundException e) { raiseException("MapNotFoundException", "runMap did not find map"); } catch (Exception e) { e.printStackTrace(); } }