Receive CSV attachment via Mail Adapter and process into ABAP proxy

Hi,
I have the following scenario:
1. Receive e-mail with CSV attachment
2. Process through Mail adapter (KeepAttachments = Yes in order to retain the CSV attachment)
3. Receive into ABAP proxy (with CSV attachment)
The next step is to read the attachment in the ABAP proxy and process the CSV attachment data into CRM.
The CSV attachment contains the data I wish to process - the body of the e-mail will not contain this information.
The problem I have is reading the attachment data in the proxy - not sure of the methods/class to call - anyone got any ideas ?
Another question is this the best way to do this and process the CSV attachment data ?
I know I could use the PayloadSwapBean to switch the payload to the attachment but then I am stumped with how the attachment is processed through PI 7.1 - how do you transform the CSV format payload into XML so PI will be able to process it through mapping.
Either option is viable - an answer to either question would be great.
1. How do you read the attachment data in an inbound ABAP proxy ?
2. How do you transform the CSV attachment data after the PayloadSwapBean from CSV to XML ?
Kind regards
Colin.

Hi Colin
As you are not interested in processing the body of email. Swap the payload to the attachment using the PayloadSwapBean
Change the content from CSV to XML using MessageTransformBean. Now pass this information to Proxy. You dont need to deal with attachments in proxy.
It is not possible to read attachment in server proxy because the class and interface you create will not have data type which can refer to an attachment processing interface in ABAP.
Thanks
Gaurav

Similar Messages

  • File attachement in mail adapter

    Hi ,
    I need to send users an error report which I have captured in the form of a file. Is it possible to attach this file as an attachement via mail adapter. I have been reading that the payload can be sent as attachment by specifying the interface namespace and interface name. But my requirement is to trigger the mail once the file has been completely written and not for every message. The reason being I could have 3000 records in the file and I dont want to send 3000 MAILS out but just 1 mail for the entire 3000 records...
    Thanks,
    Teresa

    Hi Teresa,
    I hope, I understand you right.
    When you use the file-adapter for sending the file, you can without mapping send this file out to a mail receiver as attachment, there is nothing special to do.
    Regards
    Stefan

  • How to Send Appointment via mail adapter

    Hi Guys,
         I need to send the appointment and vTodo via mail adapter, any way i need to develop a mail adapter module. Till now i have finished this part,and i can send normal mail even normal mail with attachment. But i don't know how to send appointment via mail adapter.
    This is payload content of appointment which got from Exchange server to gmail:
    _=_NextPart_001_01C71EC0.97A011C6
    Content-Type: text/plain;
        charset="GB2312"
    Content-Transfer-Encoding: quoted-printable
    When: 2007=C4=EA6=D4=C227=C8=D5=D0=C7=C6=DA=C8=FD 3:30 =CF=C2=CE=E7-4:00 = =CF=C2=CE=E7 (GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi.
    Where: China
    ~*~*~**
    This is calendar content
    _=_NextPart_001_01C71EC0.97A011C6
    Content-class: urn:content-classes:calendarmessage
    Content-Type: text/calendar;
        method=REQUEST;
        name="meeting.ics"
    Content-Transfer-Encoding: 8bit
    BEGIN:VCALENDAR
    METHOD:REQUEST
    PRODID:Microsoft CDO for Microsoft Exchange
    VERSION:2.0
    BEGIN:VTIMEZONE
    TZID:(GMT+01.00) Sarajevo/Warsaw/Zagreb
    X-MICROSOFT-CDO-TZID:21
    BEGIN:STANDARD
    DTSTART:20070112T140000
    TZOFFSETFROM:+0100
    TZOFFSETTO:+0100
    END:STANDARD
    BEGIN:DAYLIGHT
    DTSTART:20070112T140000
    TZOFFSETFROM:+0100
    TZOFFSETTO:+0200
    END:DAYLIGHT
    END:VTIMEZONE
    BEGIN:VEVENT
    DTSTAMP:20061213T141132Z
    DTSTART;TZID="(GMT+01.00) Sarajevo/Warsaw/Zagreb":20070112T140000
    SUMMARY:This is calendar test
    UID:040000008200E00074C5B7101A82E0080000000030D51864C81EC701000000000000000
    010000000CA9F127EA8947844BC4DD47F269BDEA9
    ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN="Xu, Rocky":MAILTO:rocky@***.com
    ORGANIZER;CN="Xu":MAILTO:rocky@**.com;roc*@gmail.com
    LOCATION:Shanghai
    DTEND;TZID="(GMT+01.00) Sarajevo/Warsaw/Zagreb":20070112T160000
    DESCRIPTION:This is calendar content\N
    SEQUENCE:0
    PRIORITY:5
    CLASS:
    CREATED:20061213T141132Z
    LAST-MODIFIED:20061213T141133Z
    STATUS:CONFIRMED
    TRANSP:OPAQUE
    X-MICROSOFT-CDO-BUSYSTATUS:BUSY
    X-MICROSOFT-CDO-INSTTYPE:0
    X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
    X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
    X-MICROSOFT-CDO-IMPORTANCE:1
    X-MICROSOFT-CDO-OWNERAPPTID:367904726
    X-MICROSOFT-CDO-APPT-SEQUENCE:0
    X-MICROSOFT-CDO-ATTENDEE-CRITICAL-CHANGE:20061213T141132Z
    X-MICROSOFT-CDO-OWNER-CRITICAL-CHANGE:20061213T141132Z
    END:VEVENT
    END:VCALENDAR
    _=_NextPart_001_01C71EC0.97A011C6--
    My question is
      1. How to generate this kind of payload in mail adapter module?
      2. It is possible to send appointment via mail adapter?
    Following i can get from other system, even using mail package check or not using mail package check.
    BEGIN:VCALENDAR
    METHOD:REQUEST
    PRODID:Microsoft CDO for Microsoft Exchange
    VERSION:2.0
    BEGIN:VTIMEZONE
    TZID:(GMT+08.00) Kuala Lumpur/Singapore
    X-MICROSOFT-CDO-TZID:21
    BEGIN:STANDARD
    DTSTART:16010101T000000
    TZOFFSETFROM:+0800
    TZOFFSETTO:+0800
    END:STANDARD
    BEGIN:DAYLIGHT
    DTSTART:16010101T000000
    TZOFFSETFROM:+0800
    TZOFFSETTO:+0800
    END:DAYLIGHT
    END:VTIMEZONE
    BEGIN:VEVENT
    DTSTAMP:20070608T025852Z
    DTSTART;TZID="(GMT+08.00) Kuala Lumpur/Singapore":20070608T110000
    SUMMARY:This is meeting request with attachment
    UID:040000008200E00074C5B7101A82E0080000000000A9BD0BA7A9C701000000000000000
    010000000C5E16D144D1612498C0EF7E2115EFEC4
    ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN="Xu, Rocky
    ":MAILTO:roc*@**
    ORGANIZER;CN="Xu,y":MAILTO:roc*@**
    LOCATION:India labs
    DTEND;TZID="(GMT+08.00) Kuala Lumpur/Singapore":20070608T113000
    DESCRIPTION:This is content!  <<shanghai.txt>> \N
    SEQUENCE:0
    PRIORITY:5
    CLASS:
    CREATED:20070608T025925Z
    LAST-MODIFIED:20070618T033505Z
    STATUS:CONFIRMED
    TRANSP:OPAQUE
    X-MICROSOFT-CDO-BUSYSTATUS:BUSY
    X-MICROSOFT-CDO-INSTTYPE:0
    X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
    X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
    X-MICROSOFT-CDO-IMPORTANCE:1
    ATTACH:CID:008501c7b159$a9d41d3b$_CDOEX
    X-MICROSOFT-CDO-OWNERAPPTID:1468557271
    X-MICROSOFT-CDO-APPT-SEQUENCE:0
    X-MICROSOFT-CDO-ATTENDEE-CRITICAL-CHANGE:20070608T025852Z
    X-MICROSOFT-CDO-OWNER-CRITICAL-CHANGE:20070608T025852Z
    END:VEVENT
    END:VCALENDAR
    Thanks & regards
    Rocky

    Hi
    have a look at this
    You can use Java/ABAP proxies to do this job for you..
    Java Proxy >> will read the mail(with the attachments) with the help of Java APIs and send the message into XI ABAP Proxy >> for this you will have to first convert the attachment into a message and then you can proceed in the regular fashion.
    Not all adapters can process attachments, I'm not sure why you are having trouble with using module processor in the mail adapter. Just check if the service pack that you are using supports this feature.
    If you are on WAS 6.10 and above you can achieve this and there is an excellent weblog by Thomas Jung on this topic at
    /people/thomas.jung3/blog/2004/09/09/receiving-e-mail-and-processing-it-with-abap--version-610-and-higher
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/6d967fbc-0a01-0010-4fb4-91c6d38c5816
    reading Pdf Through mail easly done with Java Proxy, which will read the mail(with the attachments) with Java APIs and send the message into XI and then map with the Target ABAP proxy structure .
    Thanks

  • This is regarding CBMA in SAP PI 7.3.1. I have set up the alert mail using default java mail client.I do receive the alerts via mail. But my requirement is to direct all the mails to Business workplace inbox in ECC.

    This is regarding CBMA in single stack SAP PI 7.3.1. I have set up the alert mail using default java mail client.I do receive the alerts via mail. But my requirement is to direct all the alert mails to Business workplace inbox in ECC.
    So I need to set up PI to redirect mails to ECC Business workplace user inbox (sbwp). From here rules are set up & routed per distribution list.
    Please guide me how I can achieve this requirement.

    Hi,
    yes, it is a little bit different. This is the issue.....  
    But I am not sure if your links will help:
    1) /people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-graphical-variable
    is about a different solution. I do not need to count the number of lines of the source message.
    And the second variable is about concat line by line from unbound node to unbound node.
    My issue is:
    Souce:
    Message line (0...unbound) ! ! ! ! ! ! ! !
    .    ResultLine   (1..1)
    Mapping:
    =>   ResultLine1
           ResultLine2
           ResultLine........          => into UDF to an element  (1..1) in one mapping operation.
    So that all "ResultLine"s are included.
    The result is explained in the given link for Mail attachment with UDF.
    So I am not sure how to use this thread for my issue.
    In the comments of that blog Christoph Gerber writes that the new variable feature can only handle single values.
    So it is not suitable for my purposes as I have a list of values here that needs to be moved into the target message field.
    2) http://wiki.sdn.sap.com/wiki/display/Java/UsingEditJavaSectioninMessageMapping
    shows where to find the button "Java section" which is not available here in 7.1
    3) /people/sap.user72/blog/2005/10/01/xi-new-features-in-sp14
    too is about the nice little button for Java Section that is no longer existing on PI 7.1 screen for mappings.  
    So my issue is: How to replace the Java section function with global variables in PI 7.1?
    Best regards
    Dirk

  • Cannot receive/send emails via Mail on Mac using 10.6.8, keeps asking for password, very frustrating. Any ideas please? Regards

    Cannot receive/send emails via Mail on Mac using 10.6.8, keeps asking for password, very frustrating. Any ideas please? Regards

    One more time, iCloud mail accounts are .me, .mac and .icloud. New ones are only .icloud.
    iCloud mail is a standard Imap account that can be used with any mail client in existence. But You are talking about the ability to automatically setup an iCloud account in mail, which did not exist until 10.7.2.
    You can use password or token authentification with iCloud mail (in Mail) it is your choice.
    Set the account manually, set it as Imap, use imap.mail.me.com (no P number) for the incoming email and smtp.mail.me.com as the outgoing server.
    The full settings (ports and security) are here. Use them and it will work, regardless of domain (mac, me and icloud addresses all use the same settings.
    IMAP (Incoming Mail Server) information:
    Server name: imap.mail.me.com
    SSL Required: Yes
    Port: 993
    Username: [email protected] (use your @me.com address from your iCloud account)
    Password: Your iCloud password
    SMTP (outgoing mail server) information:
    Server name: smtp.mail.me.com
    SSL Required: Yes
    Port: 587
    SMTP Authentication Required: Yes
    Username: [email protected] (use your @me.com address from your iCloud account)
    Password: Your iCloud password
    Note: If you receive errors using SSL, try using TLS instead. SSL is required for both IMAP and SMTP connection with iCloud. POP is not supported by iCloud. 
    For more information on how to use this information with your email application, consult your application's documentation.

  • Send Attachment via mail

    Hi All,
    My requirement is to send the contents of an internal table as an attachment via mail to an external mail address.
    I am working in SAP version 3.1H.
    Would anybody provide a sample code of how to do so?
    regards,
    Paul

    Hi,
    If you require small example you can also have look on the
    following sample code which will post internal table data as attachment. Please not email address has to be customised in the <b>SAP usermaintaince.</b>
    FORM send_mail.
      it_doc_chng-obj_name  = text-016.
      it_doc_chng-obj_descr = text-016.
      DESCRIBE TABLE it_objtxt LINES g_lines.
      READ TABLE it_objtxt INDEX g_lines.
      it_objpack-doc_size = ( g_lines - 1 ) * 255 + STRLEN( it_objtxt ).
      it_objpack-doc_type   = 'RAW'.
      APPEND it_objpack.
      it_objpack-head_start = 1.
      it_objpack-head_num   = 0.
      it_objpack-body_start = 1.
      it_objpack-transf_bin = 'X'.
      it_objpack-body_num   = g_lines.
      it_objpack-doc_type   = 'RAW'.
      it_objpack-obj_name   = 'ATTACHMENT'.
      it_objpack-obj_descr  = g_file.
      APPEND it_objpack.
    completing the recipient list
      SORT it_vmail.
      DELETE ADJACENT DUPLICATES FROM it_vmail.
      IF l_client NE 'P'.
        it_reclist-receiver = p_email.
        it_reclist-express =  'X'.
        it_reclist-rec_type = 'U'.
        APPEND it_reclist.
      ELSE.
        LOOP AT it_vmail.
          it_reclist-receiver = it_vmail-smtp_addr.
          it_reclist-express =  'X'.
          it_reclist-rec_type = 'U'.
          APPEND it_reclist.
        ENDLOOP.
      ENDIF.
      it_rec_mail[] = it_reclist[].
      IF NOT p_copy IS INITIAL.
        it_reclist-receiver = p_copy.
        it_reclist-express =  'X'.
        it_reclist-copy =  'X'.
        it_reclist-rec_type = 'U'.
        APPEND it_reclist.
      ENDIF.
      CLEAR it_download[].
      it_download[] = it_objtxt[].
    **********Sending the mail with attachment*****************
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_MAPI'
        EXPORTING
          document_data              = it_doc_chng
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = it_objpack
          contents_bin               = it_objtxt
          contents_txt               = it_objtxt
          receivers                  = it_reclist
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      CASE sy-subrc.
        WHEN 0.
          IF p_update = 'X'.
            PERFORM reference_update.
          ENDIF.
         PERFORM down_load.
          WRITE:/01 text-019.
          SKIP.
          LOOP AT it_rec_mail.
            FORMAT COLOR 5 INTENSIFIED OFF.
            WRITE:/01 text-010,20 it_rec_mail-receiver.
          ENDLOOP.
          ULINE.
        WHEN 1.
          WRITE: / text-012.
        WHEN 2.
          WRITE: / text-013.
        WHEN 4.
          WRITE: / text-014.
        WHEN OTHERS.
          WRITE: / text-015.
      ENDCASE.
      REFRESH:it_objpack,
              it_objtxt,
              it_reclist,
              it_rec_mail.
      CLEAR:it_objpack,
            it_objtxt,
            it_reclist,
            g_lines,
            it_rec_mail.
    ENDFORM.                    " send_mail
    Regards
    Suresh Babu Karanam

  • HT4644 How do I get an image on a Samsung TV via HDMI adapter and cable.  Currently get only a static imgae of desktop and gray grainy screen for everything else.

    How do get an image on a Samsung HD TV via HDMI adapter and cable?
    Currently get a static image of the desktop and then a grainy gray picture.

    If it's like mine, I used another post's advice. Go to system preferences, then display and click on "mirror". Then in system preferences go to sound and click on "HDMI".  I did this while I was connected to my Samsung TV and it worked then.

  • Wanted to put a file via a drag and drop into applications on my finder sidebar.  it missed and landed in the sidebar itself.  i can not remove it.  i can not even highlight it.  how can i remove it from the sidebar.

    I wanted to put a file via a drag and drop into applications on my finder sidebar.  it missed and landed in the sidebar itself.  i can not remove it.  i can not even highlight it.  how can i remove it from the sidebar.

    Try holding down the Command key and dragging the file well off the sidebar.
    Hope this helps.

  • Dynamic attachment name with receiver mail adapter and use mail package

    We need to send mapped XML payload as attachment (with dynamic name) to a recepient (recepient email id is part of input xml payload, but not part of the mapped XML payload).
    I could probably do this using the adapter module (as per the following link),
    http://wiki.sdn.sap.com/wiki/display/XI/Adapter%20Module%20PI%207.0%20Set%20Attachment%20Name?bc=true
    I would like to explore if this would be feasible using Mail package and XI payload.I already have a Java mapping that is converting the input XML to required Output format. If I am using Mail package (XI Payload), how do I go about sending this Output XML from java mapping as attachment to email id available in the input payload?

    Hi,
    1) XML payload as attachment (with dynamic name)
    2) recipient (recipient email id is part of input xml payload, but not part of the mapped XML payload)
    These two is possible by using Mail Package. You have a standard xsd for mail package which you can download from the SAP Note 748024.
    The xml created in you java mapping which will be your attachment should be put into the <content> tag of the mail package xml structure. and the file name can be set in the <Content_Type> tag.
    <?xml version="1.0"; encoding="UTF-8"?>
    <p2:Mail xmlns:p2="http://sap.com/xi/XI/Mail/30">
    <Subject>My Invoice</Subject>
    <From>from email address<;/From>
    <To>to email address</To>
    <Content_Type>text/plain;name="MyFile.csv";</Content_Type>  --> file name here
    <Content>123;A49;aaa</Content>   -> attachment xml here
    </p2:Mail>
    And you have to select MailPackage in the receiver mail adapter.
    Regards,
    Aravind

  • Plain text and attachment in Mail Adapter (Receiver)

    Hello,
    we have to generate a mail in the mail-adapter with a specific text and an attachment.
    The attachment is a document in pdf-format, that is generated inside an adapter-module out of the payload-document.
    An additional text has to be added to the mail for the receiver in plain-text-format, like "Dear customer ... enclosed you will find ...".
    Is it possible to mix plain-text and attachments in the mail adapter? Does anybody know how we can do that?
    Regards,
    Thorsten

    Hi,
    yes you can do it very easily inside the adapter module
    if you're already using the adapter module then
    you can just enhance it a little bit
    you can add the pdf to the attachment section and
    leave dear customer in the standard payload
    you can even make it a little bit more dynamic
    and create a module that will take the input from
    the communication channel config (modules tab) - for example xml tag name in which you will specify
    the dear customer (or any other text) and after this
    the pdf creating can use the xml without this tag...
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions">XI FAQ - Frequently Asked Questions</a>

  • Receive mail with PDF attachment into XI and send to ABAP proxy

    Hi,
    I have a scenario where I need to receive a mail into XI that has a PDF attachment. This attachment needs to be retained as ultimately I need to send the message into CRM via an ABAP proxy and read the attachment and load against a business partner.
    However, as I am only on SP13 I do not have the parameters such "Keep Attachments" available to use.
    So I have two questions:
    1. How do I receive the mail into XI with the PDF attachment ?
    2. How do I read the attachment in an ABAP proxy ?
    Any guidance in either question would be appreciated.
    Cheers
    Colin.

    hi,
    you say that there's no keep attachment
    indicator but does the XI store the attachment or not?
    maybe it stores all attachmens
    (I work with sp16 and I don't remember how it worked with sp13)
    but try maybe it accepts attachments by default
    then it would be quite easy
    if you use then use the attachement in abap proxy
    (like I said you won't have to use any java)
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • Can XI Message be mapped to a flat file attachment in Mail adapter

    Hi guys,
    I have a requirement, where I have ECC system seding a XI message to XI.
    Now XI has to convert this to a flat file may be tab delimited and send this as an attachment in email using receiver mail adapter.
    I want to avoid BPM and make it simple.
    Appreciate any help on this topic.
    Regards
    Sujan

    Hi,
    Here are some mapping examples.
    /people/rahul.nawale2/blog/2006/07/18/java-mapping-an-alternate-way-of-reading-a-csv-file
    /people/alessandro.guarneri/blog/2007/03/25/xi-java-mapping-helper-dom
    /people/carlosivan.prietorubio/blog/2007/12/21/implementing-a-java-mapping-in-sap-pi
    /people/venkataramanan.parameswaran/blog/2006/12/12/java-mapping-to-handle-flat-files-in-sap-xi
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii
    /people/michal.krawczyk2/blog/2005/02/25/simple-java-code-in-graphical-mapping--xi
    Vishal

  • PDF attachment in mail adapter

    Hi
    I am reading mailbox using mail adapter. But i cannot read the PDF attachment in that mail. I use "PayloadSwapBean" in the module, but it is packing the mailbody to the text file, but they is no sign of PDF attachment. How to read the attachment.
    Regards
    Andy

    Hi Anandan,
    You can use Java/ABAP proxies to do this job for you..
    Java Proxy >> will read the mail(with the attachments) with the help of Java APIs and send the message into XI ABAP Proxy >> for this you will have to first convert the attachment into a message and then you can proceed in the regular fashion.
    Not all adapters can process attachments, I'm not sure why you are having trouble with using module processor in the mail adapter. Just check if the service pack that you are using supports this feature.
    If you are on WAS 6.10 and above you can achieve this and there is an excellent weblog by Thomas Jung on this topic at
    /people/thomas.jung3/blog/2004/09/09/receiving-e-mail-and-processing-it-with-abap--version-610-and-higher

  • Sender Mail Adapter Configuration - Process Multiple Attachments

    Dear sirs,
    I need to process several attachments at the same mail message as individual payloads.
    In default configuration of sender mail adapter only the body of message is used as payload.
    So I added PayloadSwapBean Module at Processing Sequence and it processed the attachment I set in Module Configuration.  I'm not able to process all attachments available, just one attachment is sent to PI pipeline.
    How can I process all attachments of a single mail message?
    Thank you in advance.
    Fabio Purcino

    Hi Jose,
    We are trying to implement reading multiple attachment in sender mail adapter. 
    Our Requirement is : Reading a mail having multiple .xls files. This should be read and converted to payload .
    package multiswap;
    //import com.sap.aii.adapter.xi.ms.XIMessage;
    import com.sap.aii.af.lib.mp.module.*;
    import com.sap.aii.af.lib.trace.Trace;
    import com.sap.aii.af.sdk.xi.mo.Message;
    import com.sap.aii.af.sdk.xi.mo.MessageContext;
    import com.sap.aii.af.sdk.xi.mo.xmb.XMBMessageOperator;
    import com.sap.aii.af.sdk.xi.mo.xmb.XMBPayload;
    import com.sap.aii.af.sdk.xi.util.PayloadType;
    import com.sap.aii.af.service.auditlog.Audit;
    import com.sap.aii.af.service.cpa.*;
    import com.sap.engine.interfaces.messaging.api.MessageDirection;
    import com.sap.engine.interfaces.messaging.api.MessageKey;
    import com.sap.engine.interfaces.messaging.api.Payload;
    import com.sap.engine.interfaces.messaging.api.auditlog.AuditLogStatus;
    import java.util.Hashtable;
    import java.util.Iterator;
    import java.util.Locale;
    import javax.ejb.*;
    public class MultiSwapRead
        implements SessionBean, Module
        private static final String VERSION_ID = "$Id: //tc/xpi.af/NW731EXT_07_REL/src/_af_application_ejb_module/ejbm/api/com/sap" +
    "/aii/af/app/modules/PayloadSwapBean.java#1 $"
        private static final Trace TRACE = new Trace("$Id: //tc/xpi.af/NW731EXT_07_REL/src/_af_application_ejb_module/ejbm/api/com/sap" +
    "/aii/af/app/modules/PayloadSwapBean.java#1 $"
        private static final String SIGNATURE_PROCESS = "process(ModuleContext , ModuleData)";
        protected Hashtable cachedChannels;
        protected SessionContext myContext;
        public MultiSwapRead()
            cachedChannels = new Hashtable();
        public void ejbRemove()
        public void ejbActivate()
        public void ejbPassivate()
        public void setSessionContext(SessionContext context)
            myContext = context;
        public void ejbCreate()
            throws CreateException
        public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)
            throws ModuleException
            if(TRACE.beLogged(200))
                TRACE.entering("process(ModuleContext , ModuleData)", new Object[] {
                    moduleContext, inputModuleData
            ModuleData outputModuleData;
            Iterator itr;
            outputModuleData = inputModuleData;
            String chid = moduleContext.getChannelID();
            TRACE.infoT("process(ModuleContext , ModuleData)", ModuleCategories.SAP_MODULE_ROOT, (new StringBuilder()).append("performing payload swap for channel ").append(chid).toString());
            LookupManager lman = LookupManager.getInstance();
            Channel chan = null;
      try {
      chan = (Channel)LookupManager.getInstance().getCPAObject(CPAObjectType.CHANNEL, chid);
      } catch (CPAObjectNotFoundException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
      } catch (CPAException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
            Direction direction = chan.getDirection();
            String swapkey = moduleContext.getContextData("swap.keyName");
            String keyvalue = moduleContext.getContextData("swap.keyValue");
            Object obj = inputModuleData.getPrincipalData();
            Object pivotedObj = inputModuleData.getSupplementalData("mp.pivoted");
            boolean pivoted = pivotedObj == null || !(pivotedObj instanceof Boolean) ? false : ((Boolean)pivotedObj).booleanValue();
            Message mo = null;
            if(obj instanceof com.sap.engine.interfaces.messaging.api.Message)
                mo = (Message)((com.sap.engine.interfaces.messaging.api.Message)obj);
            } else
            if(obj instanceof MessageContext)
                mo = ((MessageContext)obj).getMessage();
            } else
                TRACE.warningT("process(ModuleContext , ModuleData)", ModuleCategories.SAP_MODULE_ROOT, "no message found");
            if(mo != null && XMBMessageOperator.numberOfPayloads(mo) > 0)
               // String midstr = XMBMessageOperator.getMessageId(mo).toString();
                MessageKey auditkey = new MessageKey(((com.sap.engine.interfaces.messaging.api.Message) mo).getMessageId(), com.sap.engine.interfaces.messaging.api.MessageDirection.INBOUND);
                itr = (Iterator) mo.getAttachments();
                if(swapkey != null && keyvalue != null)
                    StringBuffer textSwappingbyBuf = new StringBuffer();
                    textSwappingbyBuf.append("Swap: swapping by '").append(swapkey).append("' ? '").append(keyvalue).append("'");
                    String textSwappingby = textSwappingbyBuf.toString();
                    TRACE.infoT("process(ModuleContext , ModuleData)", ModuleCategories.SAP_MODULE_ROOT, textSwappingby);
                    Audit.addAuditLogEntry(auditkey, AuditLogStatus.SUCCESS, textSwappingby);
                   while (itr.hasNext()){
                    boolean swappedp = swapPayloads(mo, swapkey, keyvalue);
                    String swappedStatus = swappedp ? "Swap: successfully swapped" : "Swap: no matching payload found";
                    Audit.addAuditLogEntry(auditkey, AuditLogStatus.SUCCESS, swappedStatus);
                } else
                    StringBuffer textInvalidBuf = new StringBuffer();
                    textInvalidBuf.append("Swap: parameter missing ");
                    if(swapkey == null)
                        textInvalidBuf.append("swap.keyName");
                    if(swapkey == null && keyvalue == null)
                        textInvalidBuf.append(" and ");
                    if(keyvalue == null)
                        textInvalidBuf.append("swap.keyValue");
                    String textInvalid = textInvalidBuf.toString();
                    TRACE.warningT("process(ModuleContext , ModuleData)", ModuleCategories.SAP_MODULE_ROOT, textInvalid);
                    Audit.addAuditLogEntry(auditkey, AuditLogStatus.WARNING, textInvalid);
            } else
                String messageEmpty = "Swap: message is empty or has no payload";
                TRACE.infoT("process(ModuleContext , ModuleData)", ModuleCategories.SAP_MODULE_ROOT, messageEmpty);
            return outputModuleData;
        private static boolean swapPayloads(Message mo, String swapkey, String keyvalue)
            swapkey = swapkey.toUpperCase(Locale.ENGLISH);
            keyvalue = keyvalue.toUpperCase(Locale.ENGLISH);
            int ifound = -1;
            for(int i = 0; i < XMBMessageOperator.numberOfPayloads(mo); i++)
                XMBPayload pldi = XMBMessageOperator.getPayload(mo, i);
                String pldivalue = null;
                if(swapkey.equals("PAYLOAD-DESCRIPTION"))
                    pldivalue = pldi.getPayloadDescription();
                } else
                if(swapkey.equals("PAYLOAD-NAME"))
                    pldivalue = pldi.getPayloadName();
                } else
                    pldivalue = pldi.getContentAttribute(swapkey);
                if(pldivalue == null)
                    continue;
                pldivalue = pldivalue.toUpperCase(Locale.ENGLISH);
                if(pldivalue.indexOf(keyvalue) < 0)
                    continue;
                ifound = i;
                break;
            if(ifound >= 0)
                XMBPayload pldfound = XMBMessageOperator.getPayload(mo, ifound);
                if(pldfound.getPayloadType() != PayloadType.APPLICATION)
                    XMBPayload pldapp = XMBMessageOperator.getApplicationPayload(mo);
                    if(pldapp == null)
                        pldfound.setPayloadType(PayloadType.APPLICATION);
                    } else
                        pldapp.setPayloadType(PayloadType.APPLICATION_ATTACHMENT);
                        pldfound.setPayloadType(PayloadType.APPLICATION);
                    TRACE.infoT("process(ModuleContext , ModuleData)", ModuleCategories.SAP_MODULE_ROOT, "successfully swapped");
                return true;
            } else
                TRACE.warningT("process(ModuleContext , ModuleData)", ModuleCategories.SAP_MODULE_ROOT, "no matching found");
                return false;
    We couldn't go further. Please have a look in highlighted code.
    Regards,
    Kesava.

  • From message to attachment in Mail adapter

    Hello,
    I am searching for information about this issue:
    An incoming message from a WebService needs to be mapped to a target structure . SAP PI has to create a file (csv) and add it as an attachment to a mail.
    So this is the process:
    WebService -> Mapping -> File -> Attachment in eMail
    I am not sure if this is possible to move the target structure as a csv-file attachment into the eMail.
    Please can anybody help!
    This is really appreciated!
    Best Regards
    Dirk

    Thank you, Hareenkumar!
    The first link seems to be the right one to help me!
    So the solution should be to use a Java mapping to generate the required file structure
    and add it then as an attachment to the mail.
    And thank you, Abhishek!
    I will try this first as it seems to be easier to implement for me.
    But this needs some weeks as we are analyzing requirements currenly and need to find out what is possible with PI and what is the effort for impolementation!
    So I will come back later!
    Regards
    Dirk
    Edited by: Meinhard Dirk on Dec 7, 2010 12:09 PM

Maybe you are looking for

  • Flash Builder 4.6 horribly unresponsive

    I'm using Flash builder 4.6 (and have used prior versions of flash builder as well) with a flex/actionscript project on a Windows 7, 64 bit box.  Flash Builder itself (not the launched application) is horribly slow and unresponsive.  I do not have th

  • Getting error as :  log4j : WARN No appenders could be found for logger

    Hi all, I am using IBM - Rational Application Developer (RAD) for the development of my project service task. I am trying to use log4j to log various events like errors and warnings and so on .... But I am getting following errors in console window o

  • All burned discs are coming up blank.

    Hi So I've burned some DVDs and after it is done it refuses to believe there are any files on it. The reflective side shows that difference in colour in the areas used and it takes its time burning and verifies afterwards so the files are there. I've

  • To get return back to stock for unconsumed material once already issued

    Dear Team, Can you share if user already taken the issue for the reservation fully and suppose some of quantities not not issued and want to return again back to stores then what would be the best practice ,pl can share your opinion.. Thanks, Dharmve

  • How do I upgrade OS X 10.1.5 to Tiger?

    I recently purchased a 5th generation iPod but this required an upgrade of my Mac's software to Tiger, OS X 10.4. I confirmed on the Apple website that my software could be upgraded to Tiger without deleting my hard drive. Unfortunately, when I try t