‎2007 Oct 08 8:30 AM
Hi Experts,
I am trying to send a mial with text attachement from the r/3. Everything is working fine except the data format in the text file.
I have filled the contetents table as shown below.
data: word1(15) type c,
word2(15) type c,
tab_space(15) type c,
idx type i.
word1 = 'firstword'.
word2 = 'secondword'.
tab_space = ' '.
idx = 1.
do 3 times.
concatenate word1 word2 into contents .
*insert wa_contents into table contents .
append contents.
*concatenate word1 word2 into contents .
*insert wa_contents into table contents .
append contents.
enddo.
and the packing list table as shown below
DESCRIBE TABLE contents LINES count.
REFRESH packing_list.
packing_list-transf_bin = 'X'.
packing_list-head_start = 1.
packing_list-head_num = 1.
packing_list-body_start = 1.
packing_list-body_num = count.
packing_list-doc_type = 'RAW'.
APPEND packing_list.
CLEAR packing_list.
* Create attachment notification
packing_list-transf_bin = ''.
packing_list-head_start = 1.
packing_list-head_num = 1.
packing_list-body_start = 1.
packing_list-body_num = count.
packing_list-doc_type = 'TXT'.
packing_list-obj_descr = 'Material Infotype'.
packing_list-obj_name = 'Material Infotype'.
packing_list-doc_size = count * 255.
APPEND packing_list.
the mail sending code is shown below.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = document_data
* PUT_IN_OUTBOX = ' '
* SENDER_ADDRESS = SY-UNAME
* SENDER_ADDRESS_TYPE = 'B'
* COMMIT_WORK = ' '
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
* SENDER_ID =
TABLES
packing_list = packing_list
* OBJECT_HEADER =
contents_bin = attachment
contents_txt = contents
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = real_recipients
* 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
.
The problem is in the attachment file, the data is appearing as shown below:
firstwordsecondword
firstwordsecondword
firstwordsecondword
the second and third lines are not starting from the begining of new line. I do not understand why. Is that something problem with the packing parameters.
thanks
sankar
‎2007 Oct 08 11:37 AM
Hi Sankar,
Change you concatnate statement like this.
concatenate word1
word2
CL_ABAP_CHAR_UTILITIES=>CR_LF
into contents .
Regards,
Vijay
‎2007 Oct 08 8:42 AM
hi just modify your concatenate statement:
data: c_tab type char2 value ' '.
do ...
concatenate word1 word2 into contents separated by c_tab .
append contents.
clear contents.
enddo.
Hope That Helps
Anirban M.
‎2007 Oct 08 9:37 AM
Hi Anirban
I have done the modifications. Now I get the o/p in the taxt file like this
firstword secondword
xxxxxxxxxxxxxxxxxxxxfirstword secondword
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXfirstword secondword
( X indicates the balnk space )
I wane the o/p in the text file like this
firstword secondword
firstword secondword
firstword secondword
all lines starting from the same point.
thanks
sankar
Message was edited by:
sankar rao
Message was edited by:
sankar rao
‎2007 Oct 08 10:18 AM
I have written something like the below and it works for me please check.
DATA: t_data TYPE STANDARD TABLE OF char50,
w_data TYPE char50.
DATA: word1(15) TYPE c,
word2(15) TYPE c,
tab_space(15) TYPE c,
idx TYPE i.
word1 = 'firstword'.
word2 = 'secondword'.
tab_space = ' '.
idx = 1.
DO 3 TIMES.
CONCATENATE word1 word2 INTO w_data SEPARATED BY tab_space.
APPEND w_data TO t_data.
CLEAR w_data.
ENDDO.
LOOP AT t_data INTO w_data.
WRITE:/ w_data.
ENDLOOP.and here is my output:
firstword secondword
firstword secondword
firstword secondwordHope That Helps
‎2007 Oct 08 10:34 AM
Hi Ani,
When I disply the o/p in the report it is working fine, But in the text file attachment the text is appearing like this
firstword secondword
xxxxxxxxxxxxxxxxfirstword secondword
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXfirstword secondword.
X represents the blank space.
thanks
sankar
‎2007 Oct 08 12:07 PM
Try the following:
packing_list-doc_type = 'RAW' " 'TXT'.
packing_list-obj_descr = 'Material Infotype'.
packing_list-obj_name = 'Material Infotype'.
packing_list-doc_size = count * 255.
APPEND packing_list.Hope That Helps
Anirban M.
‎2007 Oct 08 9:04 AM
Hi
check out below link,
http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
Regards,
Raghavendra
‎2007 Oct 08 10:39 AM
Hi,
try like this.
DATA: t_data TYPE STANDARD TABLE OF char50,
w_data TYPE char50.
DATA: word1(15) TYPE c,
word2(15) TYPE c,
tab_space(15) TYPE c,
idx TYPE i.
word1 = 'firstword'.
word2 = 'secondword'.
tab_space = ' '.
idx = 1.
DO 3 TIMES.
CONCATENATE word1 word2 INTO w_data SEPARATED BY tab_space.
APPEND w_data TO t_data.
CLEAR w_data.
ENDDO.
and change your pack list part like this .
t_objpack-transf_bin = 'X'.
t_objpack-head_start = 1.
t_objpack-head_num = 1.
t_objpack-body_start = 1.
t_objpack-body_num = count.
t_objpack-doc_type = 'TXT'.
t_objpack-obj_name = 'text1'.
t_objpack-obj_descr = 'Txt2'.
t_objpack-doc_size = count * 255.
t_objpack-mess_type = space.
APPEND t_objpack.
CLEAR t_objpack.
‎2007 Oct 08 11:37 AM
Hi Sankar,
Change you concatnate statement like this.
concatenate word1
word2
CL_ABAP_CHAR_UTILITIES=>CR_LF
into contents .
Regards,
Vijay