on 07-28-2010 5:49 PM
Hi Gurus,
is it possible to add an attachment during a ABAP mapping? Like it is possible for proxy!
I want to attach a jpg file during the mapping. I found also class interface CL_MAPPING_ATTACHMENTS with a
few method e.g. SET_ATTACHMENT but it does not wotk.
Anyone of you knows some solutions or hinds?
Thanks in advance.
Michael,
is it possible to add an attachment during a ABAP mapping? Like it is possible for proxy!
Yes, it is possible.
I had worked on similar scenario and I had used - Interface "IF_XMS_MESSAGE" ... here you can find lots of methods for attachments like "GETATTACHMENTBYNAME", GETATTACHMENTSBYTYPE", "GETATTACHMENTS" etc.
This should help resolving your issue.
Regards,
Neetesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Neetesh Raj ,
thank you for the.
Could you please explain a little bit more? I haven't tried it yet but for me it would be logical to use
IF_XMS_RESOURCESETBINARYDATA to set the attachment and afterwards IF_XMS_MESSAGEADDATTACHMENT.
Do you mean it like this?
Thank You!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Michael,
It depends on what your requirement is. I will give you an example, which you can use as a sample. Suppose you are getting multiple attachments with the message.
So, follow these steps :-
1. get the number of attachments with "numberofattachments";
2. get each attachment using "getattachmentatindex";
3. get attachment type using "GETTYPE";
4. determine the attachment kind (Binary or text) using "GETKIND";
5. If Binary, then use "GETBINARYDATA" .. OR if text, use "GETTEXTDATA".
You can use Try and Catch for all these, you can do the catch with interface "CX_XMS_EXCEPTION" for each of these.
Hope this answers your question.
Regards,
Neetesh
HI,
I found an other solution or lets say I found an error in my interface call. IF_MAPPING_ATTACHMENTS -> set_attachment is working, sorry!!!
TRY.
CALL METHOD attachments->set_attachment
EXPORTING
content_id = '1.jpg'
content_type = if_xms_resource=>mimetype_jpeg
content = l_data.
CATCH cx_xms_system_error .
ENDTRY.
The Attachment is in the Payload, but now I get an error from the adapter, when I use file or mail receiver adapter! For a little test I used http receiver and there it is working!?
"com.sap.engine.interfaces.messaging.api.exception.MessagingException: Could not queue receive for message df9cc710-62c9-85f1-b25f-005056c00008(INBOUND). Reason: java.lang.NullPointerException: while trying to invoke the method com.sap.aii.af.sdk.xi.lang.Binary.getBytes() of an object returned from com.sap.aii.af.sdk.xi.mo.xmb.XMBPayload.getContent() "
I get it in FILE and EMAIL Adapter!? Do you know the reason? I'm still looking for it.
Edited by: Michael Kulak on Jul 30, 2010 8:50 PM
Edited by: Michael Kulak on Jul 30, 2010 9:04 PM
Receiver File adapters do not support attachments, only the sender adapter supports.
You can use the Axis adapter in file mode, this supports attachment :
http://help.sap.com/saphelp_nw04/helpdata/en/45/a3c48c87cd0039e10000000a11466f/frameset.htm
Another way around is that you use two receivers for the message, one writes the file and the second one handles the attachment.
For receiver mail adapter - if you want to forward XI attachments in e-mail attachments, then set the Keep Attachments indicator.
Hope this helps.
Regards,
Neetesh
Hi,
sounds bad. Because I have to transfer additional pictures for a payload through the file (ftp) adapter. I tried it also with the Axis Adapter but it is not working either.
How do you mean to use two receivers?
Thanks
edit: Ok now I know what you mean with two receivers! One for the payload and one for the attachment.
But I tried something different. For testing reasons I created a proxy and a report to send the attachment. In the file adapter (receiver) I zip the payload. And the everything is fine, I get the picture zipped. (This option can't be used in my scenario!)
I think the problem is caused by the adapter engine itself, maybe I have to set additional values in my mapping!? I also found a SAP Note(1422354), but it does not solve the problem.
Edited by: Michael Kulak on Aug 2, 2010 2:11 PM
Found the reason why following error occurs:
"com.sap.engine.interfaces.messaging.api.exception.MessagingException: Could not queue receive for message df9cc710-62c9-85f1-b25f-005056c00008(INBOUND). Reason: java.lang.NullPointerException: while trying to invoke the method com.sap.aii.af.sdk.xi.lang.Binary.getBytes() of an object returned from com.sap.aii.af.sdk.xi.mo.xmb.XMBPayload.getContent() "
It is because of the content_id in the following call:
CALL METHOD attachments->set_attachment
EXPORTING
content_id = '1.jpg'
content_type = if_xms_resource=>mimetype_jpeg
content = l_data.
It has to be empty! Then the scenario works but without a filename. And that is a problem because I can have multiple attachments. Any Idea?
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.