on 08-26-2013 7:50 AM
HI,
I am working on copying the MA attachment to the contract doc "Final signed document."
But the code throws the error "A reflection error occurred accessing the object".
Please find the code below and let me know your thoughts on this
com.sap.odp.api.common.types.AttachmentIfc actualAttach = com.sap.odp.api.common.types.TypeFactory.createAttachment();
parentBean1 = com.sap.odp.api.common.types.TypeFactory.createParentObjectReference(oConDocObj);//oConDocObj is the contract document bean
actualAttach.setFileData("name",fileStream,parentBean1,session);// fileStream is read from FILE_DATA of FCI_ATTACHMENT_BLOB table.
oConDocObj.getFieldMetadata("SIGNED_DOC").set(oConDocObj,actualAttach);
Regards
Krishna
Hi Krishna,
Are you talking about copying the attachment from attachments menu from toolbar?
If yes then you can use scripting viz.
OrderedSubordinateCollectionIfc maAttachments=masterAgreement.getAttachments();
if(maAttachments.size()>0)
{
AttachmentSubIBeanIfc attachment=(AttachmentSubIBeanIfc)maAttachments.get(0);
}
once you get the attachment from Master Agreement you can copy it to contract document using IAPIs of AttachmentSubIBeanIfc interface.
Hope this helps,
Kumud
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI
Thanks for the reply.
I am trying to copy attachment from the menu. Infact I am able to get the attachment, but the issue was with setting it .
I am trying to set it as shown below.And this gives the error
oConDocObj.getFieldMetadata("SIGNED_DOC").set(oConDocObj,actualAttach);
Any thoughts?
Regards
Krishna
Hi Krishna,
As you told that you are trying to copy attachments from the menu, then the attachments from menu are of AttachmentSubIBeanIfc type. You are trying to copy the object of AttachmentSubIBeanIfc to field of AttachmentIfc because of which reflection error is coming.
You can try this way
//gets attachment from MA
attachmentFromMA=null;
OrderedSubordinateCollectionIfc maAttachments=masterAgreement.getAttachments();
if(maAttachments.size()>0)
{
AttachmentSubIBeanIfc attachment=(AttachmentSubIBeanIfc)maAttachments.get(0);
attachmentFromMA=attachment.getAttachment()
;
}
Once you have got the attachment you can set it the SIGNED_DOC
//sets the attachment
doc.getFieldMetadata("SIGNED_DOC").set(doc,attachmentFromMA);
Hope this helps,
Regards,
Kumud
User | Count |
---|---|
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.