cancel
Showing results for 
Search instead for 
Did you mean: 

Problem sending xls file in an attachment via ABAP proxy

Former Member
0 Kudos

Hello,

I have in tmp directory a xls file, I tranfer such file to a table, and afterwards I send in an attachment via ABAP proxy, here is the code:

l_attachment TYPE REF TO if_ai_attachment,

lt_attach TYPE prx_attach,

l_name TYPE string,

lx_string TYPE xstring,

l_string TYPE string,

l_type TYPE string,

des TYPE string.

CLASS cl_ai_factory DEFINITION LOAD.

DATA: BEGIN OF itab OCCURS 0,

raw(255) TYPE x,

END OF itab.

DATA: l_controller TYPE REF TO if_ai_posting_controller.

DATA: it TYPE zhcm_mt_segur_out.

CREATE OBJECT prxy.

OPEN DATASET orig FOR INPUT IN binary MODE.

READ DATASET orig INTO itab-raw.

WHILE sy-subrc = 0.

APPEND itab.

READ DATASET orig INTO itab-raw.

ENDWHILE.

CLOSE DATASET orig.

LOOP AT itab.

CONCATENATE lx_string itab-raw INTO lx_string in byte mode.

ENDLOOP.

L_NAME = 'Segur.xls'.

L_TYPE = CL_AI_ATTACHMENT=>IF_AI_ATTACHMENT~C_MIMETYPE_EXCEL.

TRY.

L_ATTACHMENT =

CL_AI_FACTORY=>CREATE_ATTACHMENT_FROM_binary(

P_DATA = LX_STRING

P_TYPE = L_TYPE

P_NAME = L_NAME ).

APPEND L_ATTACHMENT TO LT_ATTACH.

L_CONTROLLER = CL_AI_FACTORY=>CREATE_CONTROLLER( ).

L_CONTROLLER->SET_ATTACHMENTS( LT_ATTACH ).

CALL METHOD PRXY->EXECUTE_ASYNCHRONOUS

EXPORTING

CONTROLLER = L_CONTROLLER

OUTPUT = IT.

COMMIT WORK.

CATCH CX_AI_SYSTEM_FAULT .

DATA FAULT TYPE REF TO CX_AI_SYSTEM_FAULT .

CREATE OBJECT FAULT.

WRITE 😕 FAULT->ERRORTEXT.

ENDTRY.

I am using a Mail receiver channel, I receive a mail, with to attachments, one .xml and the other one .bin, I save it to my computer and I change the extension to .xls and when I try to open it, the file is not valid and can be opened after being repaired. What Im doing wrong? I would like to receive a valid xls file, what i should change?

Thanks a lot,

Luis

Accepted Solutions (1)

Accepted Solutions (1)

MichalKrawczyk
Active Contributor
0 Kudos

hi,

did you reference to my blog?

/people/michal.krawczyk2/blog/2006/04/19/xi-rfc-or-abap-proxy-abap-proxies-with-attachments

Regards,

michal

Former Member
0 Kudos

Hi Michal,

No I did not see it. I will try it now that way.

Thanks,

Luis

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

check it as it's a complete solution (only with jpg)

Regards,

michal

Former Member
0 Kudos

Hello Luis ,

Please read Michal's blog, it address the problem you are facing.

Thanks,

Naveen

Former Member
0 Kudos

Hi Michal,

thanks for your help, my problem is solved. Only one thing, Is it possible that the .xml attachment does not appear in the e-mail?

Best Regards,

Luis

MichalKrawczyk
Active Contributor
0 Kudos

hi,

you can easily control all attachments from an adapter module

that you can add to your mail communication channel

so - yes you can

Regards,

michal

Former Member
0 Kudos

Hi,

yes I know, I have used the MessageTransformBean module, and the PayloadSwapBean module. But which parameter I should use for leaving only one attachement in the e-mail. I did this configuration:

1

localejbs/AF_Modules/MessageTransformBean

Local Enterprise Bean

<b>trans</b>

2

localejbs/AF_Modules/PayloadSwapBean

Local Enterprise Bean

<b>swap</b>

3

localejbs/AF_Modules/MessageTransformBean

Local Enterprise Bean

<b>trans1</b>

4

localejbs/sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean

Local Enterprise Bean

mail

<i><b>Module configuration</b></i>

trans

Transform.ContentDisposition

inline

swap

swap.keyName

payload-name

swap

swap.keyValue

Segur

trans1

Transform.ContentDescription

Segur

trans1

Transform.ContentDisposition

attachment;filename="Segur.xls"

trans1

Transform.ContentType

application/vnd.ms-excel;name="Segur.xls"

In the e-mail I get one attachement without name .xml and another one Segur.xsl, and I want only one attachment, the last one. What I should change in my configuration??

Best regards,

Luis

Former Member
0 Kudos

Hi,

I have already solved the problem,

Thanks&Regards,

Luis

Answers (0)