Skip to Content
0
May 22, 2009 at 10:49 AM

Converting IWDResource to Array of Bytes

40 Views

Hi,

I want to add an attachment to a process through web dynpro CO.

This attachment should be visible to all current / consecutive actions in this process.

String filename = wdContext.currentContextElement().getUploadedFile().getResourceName();	
IGPExecutionContext executionContext = wdContext.currentContextElement().getCtx_va_executionContext();
    	
IWDClientUser clientUser = WDClientUser.getCurrentUser();
IUser iuser = clientUser.getSAPUser();			

IGPRuntimeManager runtimeManager = GPProcessFactory.getRuntimeManager();

IGPRuntimeAttachmentList rtList = runtimeManager.getAttachmentList(executionContext.getProcessId(), null, iuser);

IGPAttachment rtAttachment = rtList.add(filename, filename, IGPAttachment.TYPE_FILE,
							 iuser.getUniqueID(), byteArray );

runtimeManager.persistAttachmentList(executionContext.getProcessId(), null, rtList, iuser);

This is the code I found on SAP Help. But I am using FileUpload UI element which is bound to context attribute named UploadedFile of type IWDResource.

But in method, I need to pass byte[]. How do I convert Resource to array of bytes?

Thanks and regards,

Amey Mogare

Edited by: Amey Mogare on May 25, 2009 8:22 AM