cancel
Showing results for 
Search instead for 
Did you mean: 

copying attachment from MA to contract document

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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