cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the functionality under com.sap.odp.api.common.types.AttachmentIfc;

former_member227405
Participant
0 Kudos
151

Hello Expert,

I tried to use the API com.sap.odp.api.common.types.AttachmentIfc for  uploading the attachment to any document Type.

please correct me if I could use this.

The method under this API setFileData(attachmentName,sfile,iBean,session) .

When I am using the above method I am getting exception like.

I think I am not able to call the setFileData() corectly.

Could some one please help me.

Thanks

Sonu

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Kumar,

The third parameter of the method call must be ParentObjectReferenceIfc:

setFileData(attachmentName, new java.io.FileInputStream("PathToFile"),

  TypeFactory.createParentObjectReference(vendor),session);

Francisco

former_member227405
Participant
0 Kudos

HI Nascimento,

I am able to set the parameter inside the setFileData() correctly but I want call this method from Supplier class(copy one attachment supplier to antother suplier).

As AttachmentIfc is interface we can simply make an object and call this setFileData().

So could you please help me how can I use this method from Supplier class(toolbar script)?

Thanks

Sonu Kumar

Former Member
0 Kudos

Hi,

Do you want to copy the attachments collection beetween suppliers? I create this method:

copyAttachmentsToSupplier(supplier) {

  iAttachments = doc.attachments.iterator();

  for(attachmentMember:iAttachments){

  newAttachment = supplier.attachments.create();

  if(attachmentMember.attachment.getIsFileAttachment()){//Copy File Attachment

  newAttachment.attachment.setFileData(attachmentMember.displayName,

  new java.io.FileInputStream(attachmentMember.attachment.getFileData(session)),

  TypeFactory.createParentObjectReference(supplier),

  session);

  } else {// Copy URL

  newAttachment.attachmentUrl = attachmentMember.attachmentUrl;

  newAttachment.attachmentDisplayName = attachmentMember.attachmentDisplayName;

  newAttachment.attachment.setURL(attachmentMember.attachmentDisplayName, attachmentMember.attachmentUrl);

  }

  //Fields required

  newAttachment.ownerRef = attachmentMember.ownerRef;

  newAttachment.ownerEmail = attachmentMember.ownerEmail;

  newAttachment.ownerName = attachmentMember.ownerName;

  newAttachment.displayName = attachmentMember.displayName;

  newAttachment.description = attachmentMember.description;

  newAttachment.attachmentVisibility = attachmentMember.attachmentVisibility;

  newAttachment.getFieldMetadata("MODIFIED").set(newAttachment,TypeFactory.createSysDatetime(new java.util.Date()));

  supplier.attachments.add(newAttachment);

  }

  }

Hope this is helpful

Francisco

former_member227405
Participant
0 Kudos

Hi Francisco,

I appreciate your feedbcak .I try to use this as I was tring to copy the one supplier attachemnt to another supplier.

Actually I have to write an script which takes Fileattachment from Server(FTP server)and attach to the respective vendore.SO for this process to check the functionality of SetFileData()I tried to first copy the one vendor attachment to another.

If you have something related to this(automatic file attchement to vendor)Please kindly suggest.

Thanks & regards

Sonu