‎2008 May 19 11:28 AM
Good morning,
I'm using FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send an attachment file .txt to some email recipients.
The problem is that when i open the file in notepad, the content is all in one line. Otherwise, if i open the file in MSWord or other editors, the information is displayed correctly, following the pattern:
line1
line2
...
line i
I post the code, could you tell me if i'm coding something wrong?
REPORT zmmc062d_2.
TABLES: lfa1.
DATA: BEGIN OF reg_sal OCCURS 10,
cif(9),
asterisco(1),
codigo(10),
END OF reg_sal.
DATA:
objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
doc_chng LIKE sodocchgi1,
remitent LIKE soextreci1-receiver,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
tab_lines LIKE sy-tabix,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
t_desti TYPE TABLE OF zmaildest WITH HEADER LINE,
destinataris TYPE TABLE OF somlreci1 WITH HEADER LINE,
sistema LIKE sy-sysid.
doc_chng-obj_name = 'SENDFILE'.
doc_chng-obj_descr = 'Proveedores de TMB'.
objtxt = 'Adjunto archivo con los códigos de Proveedores de TMB'.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
* Creation of the entry for the compressed document
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
SELECT * FROM lfa1 WHERE ktokk = 'NTMB' AND
loevm NE 'X'.
CONCATENATE lfa1-stcd1 '*' lfa1-lifnr INTO objbin.
APPEND objbin.
ENDSELECT.
DESCRIBE TABLE objbin LINES tab_lines.
objhead = 'PROVEEDORES.TXT'.
APPEND objhead.
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
objpack-obj_name = 'PROVEEDORES'.
objpack-obj_descr = 'PROVEEDORES'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
* @
CLEAR destinataris.
destinataris-receiver = 'email_address'. " commented
destinataris-express = 'X'.
destinataris-rec_type = 'U'. "<------------------ URL
destinataris-copy = 'X'.
APPEND destinataris.
* EnvÃo del correo:
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
receivers = destinataris
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc <> 0.
* MESSAGE W006(ZP) WITH 'Missatge no enviat.'.
ENDIF.
Lots of thanks,
Javi
‎2008 May 20 9:47 AM
Hi javier,
1. One problem is that there is no NEW LINE character.
2. Even if we open a txt file in notepad, behind the scenes
there is a NEWLINE character, at the end of every line,
and hence it is interpreted and instead of displaying the
ascii character, the contents are displayed in the next line.
3.
change your code slightly like this:
CONCATENATE lfa1-stcd1 '*' lfa1-lifnr
CL_ABAP_CHAR_UTILITIES=>CR_LF
INTO objbin.
regards,
amit m.
‎2008 May 19 11:35 AM
SELECT * FROM lfa1 WHERE ktokk = 'NTMB' AND
loevm NE 'X'.
CONCATENATE lfa1-stcd1 '*' lfa1-lifnr INTO objbin.
APPEND objbin.
clear objbin.
ENDSELECT.
I have written clear statement please try it.
Regards,
madan.
‎2008 May 20 8:24 AM
I'm still having the same problem. The output in notepad (.txt) is displayed in one line. If i copy and paste the results here, it is shown correctly, but opening the file, it follows the following patter:
XXXXXX XXXXXX XXXXXX
XXXXX XXXXXX XXXXXX
XXXX XXXXXX XXXXX
...
Any possibility?
Thanks.
Javier
‎2008 May 20 8:42 AM
Hi,
better u can convert this to pdf format and attach it. or use .doc
some time .txt format is giving problem when number of lines are more. please tick the word wrap while opening.
‎2008 May 20 9:24 AM
Yes, in ".doc" everything is correct, but i wanted to know why i can't reach the same output in ".txt".
I don't understand your last sentence Binu "please tick the word wrap while opening."
What does it means? Thanks for your quickly reply!
‎2008 May 20 9:41 AM
‎2008 May 20 9:45 AM
Hi Javier,
This might be problem with ur local PC settings. Try this option.
Open some notepad file and type something which is more than one line. Now in menu format->select word wrap.
Now download ur file from code and try to open the same and see.
Thanks,
Vinod.
‎2008 May 20 9:47 AM
OK, thanks Srinivas.
The format is still wrong, checking this option. And when i maximize the window it changes.
I think i'll finally decide to export it in MSWord... because i can't resolve this notepad problem.
‎2008 May 20 9:51 AM
I was posting when i read the following responses.
Finally my problem is solved!!!!
Writing:
CONCATENATE lfa1-stcd1 '*' lfa1-lifnr INTO objbin.
CONCATENATE objbin cl_abap_char_utilities=>cr_lf
INTO objbin.
APPEND objbin.
Lots of thanks to all of you, who help me!
Javier
‎2008 May 20 9:47 AM
Hi javier,
1. One problem is that there is no NEW LINE character.
2. Even if we open a txt file in notepad, behind the scenes
there is a NEWLINE character, at the end of every line,
and hence it is interpreted and instead of displaying the
ascii character, the contents are displayed in the next line.
3.
change your code slightly like this:
CONCATENATE lfa1-stcd1 '*' lfa1-lifnr
CL_ABAP_CHAR_UTILITIES=>CR_LF
INTO objbin.
regards,
amit m.