‎2005 Aug 01 7:26 PM
Hello Everyone
I am trying to attach an excel sheet to email and for this I am using SO_DOCUMENT_SEND_API1 function module. Everything works fine, except after the last field it puts blank spaces (close to 100). Is there a way that I can cut the extra spaces. I tried condensing before appending it to the internal table but still it doesnt work.
Any help is greatly appreciated. Thanks in advance.
Sunil Achyut
‎2005 Aug 02 3:10 AM
Hi, I have met the same problem.
It due to the internal table which used to stored attach has too long defination, and the length of attach file hasn't been set correct.
PACKING_LIST-DOC_SIZE.
You should calculate this value accurately.
I mean you should set the byte length of your file into it. If the value set to it more than the file actually length, the blank will be occur.
In addition, here is a former topic I sent in SDN, for you reference.
Thanks
‎2005 Aug 02 12:25 AM
Sunil,
Can you paste an excerpt of your code so we can see what you are doing? Especially the bits where you define the attachments ie the PACKING_LIST and the CONTENTS parameters.
Cheers,
Pat.
‎2005 Aug 02 1:25 AM
Hello Patrick
Thanks for your reply. The following is my source code.
data: ld_mtitle like sodocchgi1-obj_descr,
ld_email like somlreci1-receiver,
ld_format type so_obj_tp ,
ld_attdescription type so_obj_nam ,
ld_attfilename type so_obj_des ,
ld_sender_address like soextreci1-receiver,
ld_sender_address_type like soextreci1-adr_typ,
ld_receiver like sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = i_email_to.
ld_mtitle = i_title.
ld_format = i_format.
ld_attdescription = i_attr_description.
ld_attfilename = i_filename.
ld_sender_address = i_email_from.
ld_sender_address_type = i_email_from_addr_ty.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
clear w_doc_data.
read table it_attach index w_cnt.
w_doc_data-doc_size = ( w_cnt - 1 ) * 255 + strlen( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
clear t_attachment.
refresh t_attachment.
t_attachment[] = it_attach[].
Describe the body of the message
clear t_packing_list.
refresh t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
describe table it_message lines t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
append t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
describe table t_attachment lines t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
append t_packing_list.
Add the recipients email address
clear t_receivers.
refresh t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
append t_receivers.
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
importing
sent_to_all = w_sent_all
tables
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
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.
Thanks
Sunil Achyut
‎2005 Aug 02 3:10 AM
Hi, I have met the same problem.
It due to the internal table which used to stored attach has too long defination, and the length of attach file hasn't been set correct.
PACKING_LIST-DOC_SIZE.
You should calculate this value accurately.
I mean you should set the byte length of your file into it. If the value set to it more than the file actually length, the blank will be occur.
In addition, here is a former topic I sent in SDN, for you reference.
Thanks
‎2005 Aug 05 3:18 PM
Hello Zhenglin
Thanks for your input, I did try changing the doc_size but still I get the blank spaces. It was supposed to go into testing, so I had to login that as bug, I hope I solve it when I start working on it again.
Thanks
Sunil Achyut
‎2005 Aug 05 4:55 PM
Hi, I guess you see the blank in the outbox of SBWP, right?
Don't worry the blank in the tail show in the sap, if you really set the field I mentioned correctly, the length of the attachment will be accurate when it sent out.
E.G. when you receive it on your outlook, check the attachment, the blank will disappear.
Try it, you will achieve it.
thanks
In addition, please attention that the accurate doc_size is set to the size field of Package list item, not other doc_size. This is a critical point.
Message was edited by: zhenglin gu
‎2007 Mar 08 3:12 PM
Hai Sunil,
I have a same issue like the one u have .I've got 17 columns as the output screen in SAP(of some report).I need to send this same thing through email to the recepient through the same FM.But this time in EXCEL SHEET.All the field gets populated correctly as the header columns.Now in the respective columns the concern data should be placed and this is going on perfectly and the number of entries in output of same report is been displayed properly in the concern field of the EXCEL SHEET.But the problem with the 17th column in the excel sheet is it is having lot of space after the data content and the size of the field is set to 40 characters.But even though there is lot of space for this i have to move the last field to such and extent that it should end like a column in the sheet.This is making to have lot of gap and there is an upload problem.My team lead suggested me to check out the length of each field and gaved me the precise field length of column in sheet and in Sap.I dont have any problem with the display of the output in SAP.But when i mail it the problem occurs.Please help its really urgent.............
Note: I've tried various methods which were in this thread and in different forum with the same issue but still my i did'nt get the output as i need.