‎2012 Jan 05 3:51 PM
Hi,
I hope someone can offer advice on my problem.
My requirement is to allow users to select one or more documents from an ALV grid. I am then required to send these documents to multiple users via email using function module SO_DYNP_OBJECT_SEND.
I can successfully send one document as an attachment. However, I can't seem to figure out how to send multiple documents as attachments using SO_DYNP_OBJECT_SEND. Is this done in the packing list?
Is there some way to tell the program where the 1st attachment ends and the 2nd attachment starts?
My attachment content is in i_att_cont.
CALL FUNCTION 'SO_DYNP_OBJECT_SEND'
EXPORTING
object_hd_change = l_title
object_type = 'RAW'
raw_editor = abap_true
starting_at_x = '5'
starting_at_y = '1'
ending_at_x = '120'
ending_at_y = '20'
edit_title = 'X'
external_commit = abap_true
TABLES
objcont = i_objcont
rec_tab = i_rec_tab
packing_list = i_packing_list
att_cont = i_att_cont
exclude_fcode = i_exclude_fcode
EXCEPTIONS
object_not_sent = 1
owner_not_exist = 2
parameter_error = 3
OTHERS = 4.
If you require more information, please let me know. I will be happy to provide it.
Thanks.
‎2012 Jan 05 5:57 PM
Hi Jennifer,
I am not sure with this fm possible.Can you go through this [Multiple Attachments|http://wiki.sdn.sap.com/wiki/display/Snippets/SendMailhavingMultipleFilesasAttachmentusingobjectorientedtechnique] wiki.Check if it is useful.
Regards,
Madhu.
‎2012 Jan 05 6:09 PM
Hi Madhu,
I must use the function module SO_DYNP_OBJECT_SEND to send the attachments (and not CL_BCS classes). This is a user requirement. They want to see the pop-up screen and enter email text and add recipients.
Thank you,
Jennifer
‎2012 Jan 06 7:54 PM
I finally found the solution.
The trick is to ensure you put the correct values in the body_start, body_num and objlen fields of the packing list.
Each additional attachment should start (body_start) at the end of the last attachment + 1.
The value for body_num is equal to the number of lines in the attachment being added.
And the objlen field is calculated by multiplying the number of lines in the attachent * 255.
Static data
gs_packing_list-file_ext = lv_ext.
gs_packing_list-transf_bin = 'X'.
gs_packing_list-objla = sy-langu.
gs_packing_list-objtp = 'EXT'.
gs_packing_list-objdes = lv_filename.
gs_packing_list-objnam = 'Attachment'.
gs_packing_list-head_start = 1.
gs_packing_list-head_num = 1.
Body Start
CLEAR lv_count.
DESCRIBE TABLE gt_temp_att_cont LINES lv_count.
gs_packing_list-body_start = lv_count + 1.
Body Num + Object Length
CLEAR lv_count.
DESCRIBE TABLE gt_att_cont LINES lv_count.
gs_packing_list-body_num = lv_count.
gs_packing_list-objlen = lv_count * 255.
APPEND gs_packing_list TO gt_packing_list.
Hopefully this helps some desperate soul in the future.
‎2016 Sep 08 11:45 PM
Old post, but just for anyone looking at this going forward, the object length is calculated incorrectly and you might get corrupt files this way. When you calculate the length don't just take the number of lines * 255 as the last line might not (and most likely won't) have a length of 255.
So use :
gs_packing_list-objlen = ( lines( gt_att_cont) - 1 ) * 255 + strlen( gt_att_cont[ lines( gt_att_cont ) ]-line ).