11-26-2010 9:31 AM
Hi Experts,
iám trying to send a text-file from my application server via Mail.
The Function Modul which i found is "SO_NEW_DOCUMENT_ATT_SEND_API1".
The Disadvantages for this FM is, that i cant sending mail directly from Application Server.
-> First i must upload my tex-file in a internal table and must give him.
-> If i have a row´s in my text-file which have more than 255 Characters, than it will not work because this FM allowed only 255 Characters.
What can i do?
Have anyone another idea, because i had search in sdn but nothing found!!!
Thanks in forward.
11-26-2010 9:50 AM
Hi ,
See the example code below, we have to use the FM 'TEXT_SPLIT', this will split at 255 and prepare new line.
Final table for the FM SO_NEW DOCUMENT_ATT_SEND_API is i_attach.
LOOP AT i_email.
CONCATENATE i_email-matnr
i_email-werks
i_email-lgort
i_email-kunnr
i_email-name1
i_email-vbeln
i_email-posnr
i_email-lfimg
i_email-pkconf
i_email-cost
i_email-curr
i_email-sal_order
i_email-sal_itm
i_email-ord_qty
i_email-bu
i_email-prctr
i_email-usg_ind
i_email-ord_reas
i_email-accp_dat
i_email-instal_date
i_email-dismat_date
INTO l_string SEPARATED BY con_tab.
WHILE l_string <> space.
CALL FUNCTION 'TEXT_SPLIT'
EXPORTING
length = 255
text = l_string
IMPORTING
LINE = i_attach
REST = l_string.
IF l_string = space.
CONCATENATE i_attach con_cret INTO i_attach.
APPEND i_attach.
CLEAR i_attach.
ELSE.
APPEND i_attach.
CLEAR i_attach.
ENDIF.
ENDWHILE.
Thanks and Regards,
Bharani
11-26-2010 9:36 AM
Hi,
The reason is because the itab for attachment in the mail is less than 255 length. Hence we have to convert the original data of attachment, and put into a proper table of the required length.
you can try using fm
SX_TABLE_LINE_WIDTH_CHANGE
before putting the contents in the email itab.
regards,
amit m.
11-26-2010 9:50 AM
Hi ,
See the example code below, we have to use the FM 'TEXT_SPLIT', this will split at 255 and prepare new line.
Final table for the FM SO_NEW DOCUMENT_ATT_SEND_API is i_attach.
LOOP AT i_email.
CONCATENATE i_email-matnr
i_email-werks
i_email-lgort
i_email-kunnr
i_email-name1
i_email-vbeln
i_email-posnr
i_email-lfimg
i_email-pkconf
i_email-cost
i_email-curr
i_email-sal_order
i_email-sal_itm
i_email-ord_qty
i_email-bu
i_email-prctr
i_email-usg_ind
i_email-ord_reas
i_email-accp_dat
i_email-instal_date
i_email-dismat_date
INTO l_string SEPARATED BY con_tab.
WHILE l_string <> space.
CALL FUNCTION 'TEXT_SPLIT'
EXPORTING
length = 255
text = l_string
IMPORTING
LINE = i_attach
REST = l_string.
IF l_string = space.
CONCATENATE i_attach con_cret INTO i_attach.
APPEND i_attach.
CLEAR i_attach.
ELSE.
APPEND i_attach.
CLEAR i_attach.
ENDIF.
ENDWHILE.
Thanks and Regards,
Bharani
11-26-2010 10:14 AM
Thanks for your helps,
but the first idea with the FM "SX_TABLE_LINE_WIDTH_CHANGE" was not possible.
The row in my text-file has 728 characters and it is separated by comma.
I dont now, but is it possible to send a mail directly with a attachement, that i can give to a FM the Path/link from the Text-File???
Than the FM can get this file directly from the Application Server and can sending!
Is this idea possible?
11-26-2010 10:21 AM
Hi,
TEXT_SPLIT can split the 728 char to first 255 then again , it will see the remaining 255 char if it reach the last then carriage return and line feed will be added to the line, that means it is the end of line.
Thanks and Regards,
Bharani
11-26-2010 10:43 AM
Thank you Bharani,
but look in my textfield is the row separated by commas like:
9000;0,00;EUR;SPAIN;......... and this row is 750 characters long.
I need this separation for excel. If i make a split with 255 characters, than i have 3 rows for 1 complete row.
But if i open this text-file with excel, than excel will think that this 3 rows are all new rows.
11-26-2010 2:28 PM
I think if the data is passed as binary, it can be resolved. Check if this wiki helps.....
http://wiki.sdn.sap.com/wiki/display/Snippets/Tosendamailattachmentwithmorethan255charactersinaline
11-29-2010 2:44 PM
Hello Satyajit,
i have understand your example, but if i send my internal table with Binary-Format, how can the user open the Attachement-File??
In this File is a CSV-Format with separation ";".
Can the Receiver directly still open this File in Excel, when i send it in Binary-Format??
11-30-2010 10:51 AM
There should be no problems with the file contents. Try it once....
Also, I'm not sure if there is an function module/class which can directly send the file from application server as an email attachment. As per my knowledge, in any case we need to read the data into internal table and then send it as an attachment.
11-30-2010 3:27 PM
Sorry,
but it not works with Binary-Format.
Because if i create a Binary-Format an sending this as attachment-File, than the receiver cant open this file in Excel.
The Receiver must become a txt, csv or excel-file.
But problem is, that i cant sending a attachement with more than 255 characters per line.
I have become also a idea to work with Function Modul u201CSX_TABLE_LINE_WIDTH_CHANGEu201D, but how will it works??
I have a internal table with one column-name = "line".
And this Internal table can have many rows, Each of these rows have more than 255 characters.
If someone know the usage for this Function Modul, than please show me a simple coding.
12-01-2010 7:52 AM
I'm not sure about this problem. Could you please attach relevant sections of your code...............
12-01-2010 10:49 AM
TYPES: BEGIN OF struc_list,
line TYPE string,
END OF struc_list.
DATA: op_liste TYPE STANDARD TABLE OF struc_list,
wa_liste TYPE struc_list,
li_contents-line TYPE xstring,
li_contents_hex TYPE STANDARD TABLE OF solix WITH HEADER LINE,
i_contents_hex TYPE STANDARD TABLE OF solix WITH HEADER LINE,
t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
e_document_data LIKE sodocchgi1,
t_contents_txt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
The Table *opliste*_ have many entry(rows) and each of them are ca. 750 Characters long.
Input in the Table *opliste*_:
Row 1: Company Code;WRBTR1;Currency1;WRBTR2;Currency2;WRBTR3;Currency3;.................
Row 2: 9000;0,00;EUR;0,00;EUR;0,00;EUR;0,00;EUR;0,00;EUR;................
Row 3: ....................
..............
Reason for Separation ";":
The Receiver of this text-file, should open it with Excel. They need it only for Excel-calculation.
But problem now is, that i can only sending text-files with maximum 255 Characters per Row.
And the idea with Binary-Format cant be opened with Excel.
**********************************Email Sending with attachment***********************************
*Converting the table contents for attachment to xstring
LOOP AT op_liste INTO wa_liste.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = wa_liste-line
IMPORTING
buffer = li_contents-line
EXCEPTIONS
failed = 1
OTHERS = 2.
*Converting the table contents from xstring to binary
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = li_contents-line
APPEND_TO_TABLE = 'I_CONTENTS_HEX'
TABLES
binary_tab = li_contents_hex.
LOOP AT li_contents_hex.
APPEND li_contents_hex TO i_contents_hex .
ENDLOOP.
ENDLOOP.
DESCRIBE TABLE i_contents_hex LINES tab_lines.
Data-Information for Mail
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
t_packing_list-body_num = tab_lines.
t_packing_list-doc_type = 'BIN'.
t_packing_list-obj_name = 'ANLAGE'.
t_packing_list-doc_size = tab_lines * 2000.
t_packing_list-obj_descr = 'Protokoll'.
APPEND t_packing_list.
e_document_data-obj_name = 'TEST'.
e_document_data-obj_descr = 'OPLISTE Excel-Format'.
t_contents_txt = 'Sehr geehrte Damen und Herren, Hallo, usw'.
APPEND t_contents_txt.
t_receivers-receiver = 'John.Debtorsap.com'.
t_receivers-rec_type = 'U'.
APPEND t_receivers.
FM called for sending the mail to the intended recipients
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = e_document_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = sent_to_all
TABLES
packing_list = t_packing_list
object_header = i_objhead
contents_hex = i_contents_hex
contents_txt = t_contents_txt
receivers = t_receivers.
12-01-2010 11:51 AM
Concatenate all the lines in the internal table to one string using line feed of CL_ABAP_CHAR_UTILITIES after each line. Then convert the string to xstring and xstring to binary, instead of converting each line separately...
12-01-2010 12:22 PM
... can you give me a coding as an example?
And after each row at end of a line i must put the Class CL_ABAP_CHAR_UTILITIES????
For what and how you will put it?
Please try to send me a coding, that iám able to relate your ideas.
Edited by: ETN_58 on Dec 1, 2010 1:22 PM
07-19-2011 1:58 PM
Hi ..
I am geting same problem that sening the text file attachment mail in background in which more than 255 char row length is required. But after 255 char the program turncate the rest text in attached file data.
Please help me out...
11-26-2010 10:43 AM