
When you insert callable objects into actions, you need to map their parameters. Depending on the type of the callable object, you have to define different mappings:
IGPObjectReference
|
Copying Input Parameters to Local Context |
importcom.sap.caf.eu.gp.process.api.IGPCallableObject; importcom.sap.caf.eu.gp.process.api.IGPModifiableAction; importcom.sap.caf.eu.gp.structure.api.IGPStructureInfo; importcom.sap.caf.eu.gp.structure.api.IGPAttributeInfo; importjava.util.Collection; importjava.util.Iterator; // retrieve action's local context IGPStructureInfo local = action.getLocalParameters(); // retrieve the callable object for execution IGPCallableObject exco = a.getExecuteCallableObject().getCallableObject(); // retrieve object's input context IGPStructureInfo in = exco.getInputParameters(); // retrieve input attributes Collection attributes = in.getAttributes(); // for each attribute in the list for(Iterator iter = attributes.iterator(); iter.hasNext();) {IGPAttributeInfo attribute = (IGPAttributeInfo) iter.next(); // create a corresponding attribute in local structure IGPAttributeInfo aCopy = local.addAttribute(attribute.getTechName(), attribute.getNamespace(), attribute.getType()); // set multiplicity of the new attribute aCopy.setMultiplicity(attribute.getMultiplicity());} // retrieve input substructures Collection structures = in.getStructures(); // for each structure in the list for(Iterator iter = structures.iterator(); iter.hasNext();) {IGPStructureInfo struct = (IGPStructureInfo) iter.next(); // create a corresponding structure in local structure IGPStructureInfo sCopy = local.addStructure(struct.getTechName(), struct.getNamespace()); // set multiplicity of the new structure sCopy.setMultiplicity(struct.getMultiplicity()); // use recursion to copy content of structure ... } // finally, save the modified local context action.setLocalParameters(local); |
By analogy, copy the output parameters you need to pass to the action.
| Mapping Local Action Parameters to Input Callable Object Parameters |
|---|
importjava.util.Iterator; importcom.sap.caf.eu.gp.base.api.IGPObjectReference; importcom.sap.caf.eu.gp.process.api.IGPModifiableAction; importcom.sap.caf.eu.gp.structure.api.IGPMappingGroup; importcom.sap.caf.eu.gp.structure.api.IGPStructureInfo; importcom.sap.caf.eu.gp.structure.api.IGPAttributeInfo; // retrieve the object reference to the callable object for execution in action "a" IGPObjectReferenceref = a.getExecuteCallableObject(); // retrieve the input mapping information IGPMappingGroupinMap = ref.getInputMapping(); // retrieve input definition of CO IGPStructureInfoin = ref.getReferencedObject().getInputParameters(); // for each attribute in CO's input IteratorattrList = in.getAttributes().iterator(); while(attrList.hasNext()) {IGPAttributeInfo attr = (IGPAttributeInfo) attrList.next(); // map action's local to CO's input attribute inMap.addMappingRule( new String[] {attr.getTechName()}, new String[] {attr.getTechName()}); } // for each structure in CO's input Iterator structList= in.getStructures().iterator(); while(structList.hasNext()) {IGPStructureInfo struct = (IGPStructureInfo) structList.next(); // map action's local to CO's input structure inMap.addMappingRule( new String[] {struct.getTechName()}, new String[] {struct.getTechName()}); } // save input mapping ref.setInputMapping(inMap); |
| Mapping Output Callable Object Parameters to Local Action Parameters |
|---|
// retrieve output definition of CO IGPMappingGroupoutMap = ref.getOutputMapping(); // map everything from CO's output to action's local parameters outMap.addMappingRule( new String[] {}, new String[] {}); // save output mapping ref.setOutputMapping(outMap); |
For more information, see Defining Mappings Within an Activity in Defining Activity Mappings .