cancel
Showing results for 
Search instead for 
Did you mean: 

How to email an attachment with more than 255 characters?

Former Member
0 Kudos

Hi everybody,

i need to send via smtp a file that has more than

255 characters per line (exactly 455 characters).

The functions provided by sap like,

SO_NEW_DOCUMENT_ATT_SEND_API1 or SO_OBJECT_SEND

Moderator notice. These function modules are obsolete. Use the CL_BCS classes instead.

uses a table with structure SOLI-line = char 255

this makes impossible to send an attachment with 455 char.

any ideas?

any example?

thank's in advance.

fersud

Message was edited by: Matthew Billingham

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi I am in a same situation were I need to attache excel with each record carying more that 500 char . I hope you have got solution on this. Appreciate if you could help me with the same. I went through what Thomas jung has mentioned, but still my level of understanding is not too high to get it.

Appreciate your help.

Thanks

David

Former Member
0 Kudos
Former Member
0 Kudos

L.S.,

for me following works fine:

form create_text_content

changing text_content type soli_tab.

data: begin of crlf,

x(1) type x value '0D',

y(1) type x value '0A',

end of crlf.

data str type string.

clear text_content[].

*it_file is an internal table

*data: begin of it_file occurs 0,

*line(330) type c,

*end of it_file.

loop at it_file into wa_file.

concatenate str wa_file crlf into str.

endloop.

call function 'SCMS_STRING_TO_FTEXT'

exporting

text = str

  • IMPORTING

  • LENGTH =

tables

ftext_tab = text_content.

endform. "create_text_content

Cheers,

Stefan.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Be careful hardcoding your own Hex values. If you ever convert to a Unicode system, you will have to clean this up. It is much better to us the SAP Class CL_ABAP_CHAR_UTILITIES. There are static attributes that are dynamically filled with the correct values (Unicode/NonUnicode).

CL_ABAP_CHAR_UTILITIES=>CR_LF

Former Member
0 Kudos

Hi,

There has been some discussion on the same topic some time ago. I am not sure what the outcome of discussion was, but one of the ways could be to write a small routine that breaks your text into lines of 255 or less characters and append them in the table SOLI-LINE or take a look at FM 'SX_TABLE_LINE_WIDTH_CHANGE' to change string length.

Additionally, take a look at , especially read the mentioned weblogs by Thomas Jung for sending email.

See if it helps.

Regards

Message was edited by: Shehryar Khan

Message was edited by: Shehryar Khan

Former Member
0 Kudos

Try as well.

Regards

Former Member
0 Kudos

Shehryar Khan, thank's for your response,

the situation is that: i need to send a file as an attachment via email to a

machine outside my office wich doesn't have any connection with our SAP system.

this file has a row structure that contains 455 characters.

The problem i'm facing is that the type SOLI and SOLIX used by SAP to

send an attachment structure holds up to 255 characters per line and i

can't parse my line to 255 because it is a line where there are table fields.

any sugestion or idea will be welcomed.

thank's

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Have you tried breaking your structure into 255 chunks? I don't know what the structure you are moving from looks like, but you should be able break it back up into the SOLI structure. The end of a line in SOLI doesn't create a Carriage Return/Line Break. You have to insert these yourself like in the following:

* Create document
      clear mail_line.
      move 'This is a test E-Mail'(d01) to mail_line.
      concatenate mail_line
                  cl_abap_char_utilities=>newline
                  into mail_line.
      append mail_line to l_mailtext.

What kind of attachment are you wanting to create - a text tab delimited file for reading in a spreadsheet application such as excel? You might try reassembling your data table into a single string with newlines where you need them. Then use function module SCMS_STRING_TO_FTEXT to turn it back into SOLI. This is what I have done in the past. I'm afraid without knowing more about your source structure and attachment type, this is about all I can tell you.

Former Member
0 Kudos

I've solved the problem just doing what you said,

Thank you Thomas and thank's all of you who

answered my post.

best regards!!

Former Member
0 Kudos

Fernando, I have the same problem - I need to break up a file that is 2000 bytes long. It is a CVS file that has delimiters of ",". Could you send me the code you used to change this (I believe Thomas provided you answer. Any help would be mosted appreciated. I can be reached at scott.strong@us.ibm.com. Thanks - this is urgent for me too - I have a client that we are sending these huge files to their customers.

Former Member
0 Kudos

Thomas,

I need one more help, as you are saying if the record length is more than 255 characters, it needs to be split into chucks of 255 characters by using the following:

Create document

clear mail_line.

move 'This is a test E-Mail'(d01) to mail_line.

concatenate mail_line

cl_abap_char_utilities=>newline

into mail_line.

append mail_line to l_mailtext.

But assuming the case if at each end of the length(255 char) if a new line character is introduced the record is splitted up. And i need it in the form of single record back without giving the user any chance to rearrange the contents of the text file.

The ultimate requirement is that the record should not be splitted up when the tab delimited file received is opened.

I need some help on this as well.

Bill

Former Member
0 Kudos

Friends,

Any help on the item below?

Bill

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The key here is to put your content back into a binary table. See in the example all the lines of the internal table are concatenated together into a single string separated by a Line Feed:

loop at it_file into wa_file.
concatenate str wa_file cl_abap_char_utilities=>cr_lf into str.
endloop.

Then this single character string is converted to a binary table. All 255 bytes of each line will be used up. The number of lines in the internal table no longer correspond to the number of lines in your output.

call function 'SCMS_STRING_TO_FTEXT'
exporting
text = str
* IMPORTING
* LENGTH =
tables
ftext_tab = text_content.

The other thing you might try is in your packing list, you could mark the item TRANSF_BIN and use the contents_bin instead of contents_txt parameter.

You might even try using function module TABLE_COMPRESS to go from an internal table with a much larger line size to the interface table size (255). The online help for the SEND_API function module has an example of this, although it results ina Binary table. You might loose your line feeds altogher and back to the previous solution.

Former Member
0 Kudos

Hi...

The class cl_abap_char_utilities does not exist in version 46C... Do you have a workaround for the same problem in 46C?

Thank's...

0 Kudos

Thanks This works for me too

LOOP AT <dyn_table> INTO <dyn_wa>.


     DO.

       lv_field_index = sy-index.

       ASSIGN COMPONENT lv_field_index OF STRUCTURE <dyn_wa> TO <fs_field>.

       v_char = <fs_field>.

       CONDENSE v_char.

       CLEAR : wfcat.

       READ TABLE ifcat INTO wfcat INDEX lv_field_index.

       IF wfcat-datatype EQ 'DATS'.

         WRITE <fs_field> TO v_char DD/MM/YYYY.

       ENDIF.

       IF sy-subrc <> 0.

         EXIT.

       ELSE.

         CONCATENATE  gv_text   v_char INTO gv_text SEPARATED BY

                cl_abap_char_utilities=>horizontal_tab.

       ENDIF.

     ENDDO.

     CONCATENATE gv_text cl_abap_char_utilities=>newline INTO gv_text.

     CALL FUNCTION 'SCMS_STRING_TO_FTEXT'

       EXPORTING

         text      = gv_text

       TABLES

         ftext_tab = gt_text.

     CLEAR gv_text.


   ENDLOOP.