Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in send mail with .txt file attached

Former Member
0 Kudos

According to the diferent checks, I found the next problems:

1.- Between each caracters there is an space, example:(E Q U I P M E N T) and could be (EQUIPMENT), the last one is the correct form.

2.- For example, two registers in my internal table appear in one line of my .txt file, but i want that each register of my internal table appear in differents lines of my .txt file.

3.- The length of each register of my internal table (objbin) is 255 characters, but i really want that the length of each register of my internal table be 1023 characters.

Thank you

8 REPLIES 8

Former Member
0 Kudos

Hi Marta,

The problem with 1 character space is comining because there is a missing entry

in table TSOTD(not sure if this is the table..I did long back please check..).

Anyway in this table all the File types are declared which are referred by the system while sending the mail.

So may be you can insert and entry in this table in debug mode and try to send the file again.

This should solve your problem.

Anway will try to get more detail on the same and get back to you soon..

<b>Reward points if this helps.

Manish</b>

Former Member
0 Kudos

Hi Manish,

I can´t find this table 'TSOTD'. Do you know where could I find it?

Thank you.

Former Member
0 Kudos

The table TSOTD don't have the entry 'TXT' either 'XLS'. But if I attache a '.xls' file, the email that I received is correct. so, somebody knows why I can´t receive correctly a .txt file and correctly '.xls' file?

Thank you.

Former Member
0 Kudos

Hi Marta,

Execute the program below:

You need to enter the File type and Description. It will update the required tables with the new file type. And then try to sent the mail again.

Well this fixes the issue with blank spaces

SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-001.

PARAMETERS : p_file TYPE so_obj_tp OBLIGATORY,

p_desc TYPE so_tp_des.

SELECTION-SCREEN END OF BLOCK b.

START-OF-SELECTION.

DATA: wa_tsotd TYPE tsotd,

wa_tsott TYPE tsott.

*-- File Type

wa_tsotd-objtp = p_file.

wa_tsotd-deflt = 'X'.

*-- File Type Description

wa_tsott-langu = 'E'.

wa_tsott-objtp = p_file.

wa_tsott-tpdes = p_desc.

*-- Update File type and Description

MODIFY tsott FROM wa_tsott.

COMMIT WORK.

MODIFY tsotd FROM wa_tsotd.

COMMIT WORK.

CLEAR: wa_tsotd,wa_tsott.

<b>Reward points if this helps.

Manish</b>

Former Member
0 Kudos

I execute your program and tables had been modified correcttly but the issue continue. Do you know why can be?

Thank you.

Former Member
0 Kudos

This is my perform:

FORM z_envia_correo .

DATA: docu_data LIKE SODOCCHGI1,

tablines TYPE i,

destinatarios like somlreci1 occurs 1 with header line.

DATA: BEGIN OF packlist OCCURS 0.

INCLUDE STRUCTURE SOPCKLSTI1.

DATA: END OF packlist.

DATA: BEGIN OF objbin OCCURS 0.

INCLUDE STRUCTURE SOLISTI1.

DATA: END OF objbin.

DATA: BEGIN OF object_header OCCURS 0.

INCLUDE STRUCTURE SOLISTI1.

DATA: END OF object_header.

DATA: BEGIN OF contents OCCURS 0.

INCLUDE STRUCTURE SOLISTI1.

DATA: END OF contents.

*-->ihv270907

DATA: l_string TYPE string,

l_fecha(10) TYPE c,

l_dia(2) TYPE c,

l_mes(2) TYPE c,

l_ano(4) TYPE c,

l_hora(8) TYPE c,

l_h(2) TYPE c,

l_min(2) TYPE c,

l_seg(2) TYPE c.

*<--ihv270907

  • Variable del destinatario para enviar el mail

DATA: l_usrnam TYPE string.

*Caracter salto de linea

FIELD-SYMBOLS <hex_container> TYPE c.

CONSTANTS: zz_tab TYPE x VALUE '0D' LENGTH 4. "valor del salto de linea en hexadecimal

ASSIGN zz_tab TO <hex_container> CASTING.

  • cargo el texto de cabecera del mail

CLEAR docu_data.

docu_data-obj_name = 'ZFLOTA'.

CONCATENATE 'ZFLOTA' sy-datum INTO docu_data-obj_descr SEPARATED BY space.

docu_data-proc_type = 'T'.

docu_data-proc_name = 'ZFLOTA'.

  • cargo el texto del cuerpo del mail

CLEAR contents.

*-->ihv270907

l_string = TEXT-I04.

REPLACE '&' IN l_string WITH sy-uname.

l_ano = sy-datum+0(4).

l_mes = sy-datum+4(2).

l_dia = sy-datum+6(2).

CONCATENATE l_dia l_mes l_ano INTO l_fecha SEPARATED BY '/'.

REPLACE '&' IN l_string WITH l_fecha.

l_h = sy-uzeit+0(2).

l_min = sy-uzeit+2(2).

l_seg = sy-uzeit+4(2).

CONCATENATE l_h l_min l_seg INTO l_hora SEPARATED BY ':'.

REPLACE '&' IN l_string WITH l_hora.

contents = l_string.

*<--ihv270907

APPEND contents.

DESCRIBE TABLE contents LINES tablines.

READ TABLE contents INDEX tablines.

docu_data-doc_size = ( tablines - 1 ) * 255 + STRLEN( contents ).

  • cargo el contenido del attachmet

LOOP AT g_gt_outtab_mail.

g_gt_outtab_mail-line+254(1) = <hex_container>.

MOVE g_gt_outtab_mail-line TO objbin-line.

APPEND objbin.

ENDLOOP.

  • genero el nombre del archivo a ser attachado

CLEAR object_header.

object_header-line = 'ZFLOTA.txt'.

APPEND object_header.

  • armo las caracteristicas del mail

CLEAR packlist.

packlist-head_start = 1.

packlist-head_num = 0.

packlist-body_start = 1.

packlist-body_num = tablines.

packlist-transf_bin = space.

packlist-doc_type = 'RAW'.

APPEND packlist.

  • armo las caracteristicas del attachment

DESCRIBE TABLE objbin LINES tablines.

packlist-transf_bin = 'X'.

packlist-head_start = 1.

packlist-head_num = 0.

packlist-body_start = 1.

packlist-body_num = tablines.

packlist-doc_type = 'TXT'.

packlist-obj_name = 'ZFLOTA.txt'.

packlist-obj_descr = 'ZFLOTA.txt'.

packlist-doc_size = tablines * 250.

APPEND packlist.

  • Destinatarios

l_usrnam = sy-uname.

MOVE: l_usrnam TO destinatarios-receiver.

destinatarios-rec_type = 'B'. "U externo; B -> SAP

destinatarios-sap_body = 'X'.

APPEND DESTINATARIOS.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = docu_data

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = packlist

OBJECT_HEADER = object_header

CONTENTS_BIN = objbin

CONTENTS_TXT = contents

RECEIVERS = destinatarios

  • EXCEPTIONS

  • TOO_MANY_RECEIVERS = 1

  • DOCUMENT_NOT_SENT = 2

  • DOCUMENT_TYPE_NOT_EXIST = 3

  • OPERATION_NO_AUTHORIZATION = 4

  • PARAMETER_ERROR = 5

  • X_ERROR = 6

  • ENQUEUE_ERROR = 7

  • OTHERS = 8

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " z_envia_correo

Thank you.

Former Member
0 Kudos

Hi frndz,

I m also facing the same problem. Got any solution...?

Former Member
0 Kudos

Following thread helped me to solve the issue.. Might help you also..

Regards,

Vignesh.