Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Taking list of structure as input to a CO

Hi All,

My callable object has following input and output struture:-


	IWDMessageManager myMessage = wdComponentAPI.getMessageManager();
	IGPTechnicalDescription technicalDescription;		
	IWDTextAccessor textAccessor = wdComponentAPI.getTextAccessor();
		
	GPWebDynproResourceAccessor resourceAccessor = new GPWebDynproResourceAccessor(textAccessor);
	technicalDescription = GPCallableObjectFactory.createTechnicalDescription("CO_NAME_KEY", "CO_DESCRIPTION_KEY",resourceAccessor,locale);
		
	//Define Input and Output Structure
	IGPStructureInfo input = technicalDescription.getInputStructureInfo();
	IGPStructureInfo output = technicalDescription.getOutputStructureInfo();
		
	try {
		//Define Input Structure
		IGPStructureInfo inputStr = input.addStructure("I_STR","com.testgp2.input");
		inputStr.setMultiplicity(IGPAttributeInfo.MULITIPLICITY_0_N);			
		inputStr.addAttribute("I_STR_FIRSTNAME",IGPAttributeInfo.BASE_STRING);
		inputStr.addAttribute("I_STR_LASTNAME",IGPAttributeInfo.BASE_STRING);
			
		//Define Output Structure
		IGPStructureInfo outputStr = output.addStructure("O_STR","com.testgp2.output");
		outputStr.setMultiplicity(IGPAttributeInfo.MULITIPLICITY_0_N);
		outputStr.addAttribute("O_STR_FIRSTNAME",IGPAttributeInfo.BASE_STRING);
		outputStr.addAttribute("O_STR_LASTNAME",IGPAttributeInfo.BASE_STRING);
		outputStr.addAttribute("O_STR_COMPLETENAME",IGPAttributeInfo.BASE_STRING);
					
		//Define Result State 
		IGPCOResultStateInfo resultStateSuccess = technicalDescription.addResultState("RESULT_NAME_SUCCESS");
		resultStateSuccess.setNameKey("SUCCESS_KEY");
		resultStateSuccess.setDescriptionKey("SUCCESS_DESCRIPTION_KEY");
			
		//Define Exceptions
		IGPExceptionInfo disaster = technicalDescription.addProcessException("EXCEPTION_NAME_DISASTER");
		disaster.setNameKey("DISASTER_KEY");
		disaster.setDescriptionKey("DISASTER_DESCRIPTION_KEY");
		disaster.setFatal(true);
			
	} catch (GPInvocationException e) {
		return null;
	}
	return technicalDescription;    

Now problem is when I am executing this CO standalone, its working fine but when I try to execute it thru GP its not showing any inputs at runtime. That is the collection size is zero in execute method:-


	IWDMessageManager myMessage = wdComponentAPI.getMessageManager();
	wdContext.currentContextElement().setExecutionContext(executionContext);
	//define Input Structure
	IGPStructure input = executionContext.getInputStructure();		
	try {
		
		//Retrieving all the instances of input structure		
		Collection inputStrList = input.getStructures("I_STR","com.testgp2.input");
		
		myMessage.reportWarning("Size of Collection "+inputStrList.size());
		myMessage.reportWarning("Input Structure Info : \n"+input.getStructureInfo().toString());
		
		
		for(Iterator it = inputStrList.iterator(); it.hasNext();){
			
			IGPStructure inputStr = (IGPStructure) it.next();
			
			myMessage.reportWarning("Inside for loop : \n"+inputStr.getStructureInfo().toString());								
			IPublicCCallableObject2Interface.INAMEElement element =  wdContext.nodeNAME().createNAMEElement();
			
			myMessage.reportSuccess(inputStr.getAttributeAsString("I_STR_FIRSTNAME") + "  "+ inputStr.getAttributeAsString("I_STR_LASTNAME"));
				
			element.setFname(inputStr.getAttributeAsString("I_STR_FIRSTNAME"));
			element.setLname(inputStr.getAttributeAsString("I_STR_LASTNAME"));
			element.setCompleteName(inputStr.getAttributeAsString("I_STR_FIRSTNAME")
									 + " - " 
									 +inputStr.getAttributeAsString("I_STR_LASTNAME"));
				
			wdContext.nodeNAME().addElement(element);
		}
		
		wdContext.currentContextElement().setExecutionContext(executionContext);
			
	} catch (GPInvocationException e) {
		//	   TODO Auto-generated catch block
		e.printStackTrace();
		myMessage.reportWarning(e.getMessage());
		myMessage.reportWarning(e.getLocalizedMessage());
		myMessage.reportWarning(e.getStackTraceString());
	}     

And I have checked the parameter mappings at GP level. They are correct.

Can anybody please suggest?

Regards,

Amey Mogare

Edited by: Amey Mogare on Oct 20, 2008 6:19 AM

Former Member
Not what you were looking for? View more on this topic or Ask a question