cancel
Showing results for 
Search instead for 
Did you mean: 

Content ID using Java Mapping

Former Member
0 Kudos

Hi,

I have created attachment using ABAP proxy. But during runtime I want to get Content ID of the attachment in Java mapping. Please advice on this

Thanks,

Dinesh

Accepted Solutions (1)

Accepted Solutions (1)

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Dinesh Babu,

Try this Java Mapping [Link1|http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/mapping/api/Attachment.html ]

package com.JavaMapping;

import java.util.Collection;
import com.sap.aii.mapping.api.*;
import java.util.Iterator;

public class ContentID_Attachments extends AbstractTransformation {

    @Override
    public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {
        try {
            // Get Content ID's
            InputAttachments inputAttachments = transformationInput.getInputAttachments();

            if (inputAttachments.areAttachmentsAvailable()) {
                Collection<String> collectionIDs = inputAttachments.getAllContentIds(true);
                for (Iterator<String> it = collectionIDs.iterator(); it.hasNext();) {
                    String ContentID = it.next();
                }
            }
            
            //Read input payload and write the same to output payload.
            /*InputStream inputstream = transformationInput.getInputPayload().getInputStream();
            OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();
            byte[] b = new byte[inputstream.available()];
            inputstream.read(b);
            String inputFileContent = new String(b);
            outputstream.write(inputFileContent.getBytes());
             */
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Regards,

Raghu_Vamsee

Answers (2)

Answers (2)

sunil_singh13
Active Contributor
0 Kudos

Dineshbabu,

Attachment can be accessed in mapping only if ABAP atack passes the Attachment to Java stack during JCO call for Mappin services during Run time. Make sure you have checked the Box Attachment in Operation mapping in PI 7.1.

Thanks,

Sunil Singh

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You need to use java mapping and I already answered possible solutions here