cancel
Showing results for 
Search instead for 
Did you mean: 

Attachment removal from OutputAttachments

Former Member
0 Kudos

Hi,

I have a requirement where I have to remove any attachments coming along with the input message. I am removing the output attachments from the global container object using the following code line.

outputAttachments.removeAttachment( <String Input>)

The String here is the ContentIDs of the attachments. But the problem here is the attachments do not get removed. They are getting posted to the target system along with actual payload.

Request to help on how to remove the attachments from the Output message.

Thanks

Veneela

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Do you have the final solution/code for this? I have a similar requirement wherein I have a multi mapping that is being passed the MainDocument along with some attachements which I need to ignore otherwise the mapping outputs a set of duplicate attachments (one set on each of the multi messages) and errors out with 'Use case DUPLICATE_CONTENT_IDS not recognized".

Thanks,
JB

stefan_grube
Active Contributor
0 Kudos

See SAP  Note 1641548: - removeAttachment API doesnt work for attachments in mapping

Former Member
0 Kudos

Hi,

Is your issue solved, I have a similar requirement.

I need to remove SubAttachments after splitting the message based on Attachments.

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Veneela,

I understand you want remove a particular attachment from payload which is flowing through PI.

It is possible, according to API provided by SAP [Link1|http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/mapping/api/OutputAttachments.html ]. I think, the trick here is give correct contentID to method

void removeAttachment(String contentID)

Let say your payload has 3 attachments. 1st attachment contentID = u2018as123u2019 with content (actual text in attachment) = u2018ABCDEFu2019 , 2nd attachment contentID = u2018qw34u2019 with content = u2018GHIJKLu2019, 3rd attachment contentID = u2018zx234u2019 with content = u2018MNOPQu2019.

Now, you must have some business logic to find out which attachment to remove based on attachment payload (test in attachment..

Letu2019s say your business logic is to remove attachment which content starts with u2018GHu2019. Then, read all attachments and there contented, after that, check for content which content starts with u2018GHu2019 and store that particular attachment contentID 'qw34u2019 in a variable to toBeRemovedContentID, finally pass it to method void removeAttachment(String contentID) .

Your code may look like this

// use this method to get collection of contentID Interface InputAttachments
Collection<String> getAllContentIds(boolean withRemoved)
//Loop over collection of contentID, then get each attachment 
//and use business logic to get toBeRemovedContentID
Attachment getAttachment(String contentID) //Interface InputAttachments
byte[] getContent() // method of Attachment Interface
//Finally remove the attachment 
void removeAttachment(String toBeRemovedContentID) // Interface OutputAttachments 

Regards,

Raghu_Vamsee

stefan_grube
Active Contributor
0 Kudos

As far as I know you cannot remove attachments as the SAP developers did not think about this feature.

Maybe you open an OSS ticket for this.