Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Multiple Attachments in SO_OBJECT_SEND

Former Member
0 Likes
1,252

Hello, I hope someone could help me with this one:

My requirement calls for the reports in smartform to be generated into pdf, and then emailed to the specific user. Now, so far managed to generate my smartform into pdf using the function module CONVERT_OTF:

  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      FORMAT                      = 'PDF'
      MAX_LINEWIDTH               = 132
    IMPORTING
      BIN_FILESIZE                = w_bin_filesize
    TABLES
      otf                         = t_otf
      lines                       = t_pdf_tab
    EXCEPTIONS
      ERR_MAX_LINEWIDTH           = 1
      ERR_FORMAT                  = 2
      ERR_CONV_NOT_POSSIBLE       = 3
      ERR_BAD_OTF                 = 4
      OTHERS                      = 5

My problem is that I need to attach more than 1 reports to my email. Checking several reference codes, I saw that I need to place the contents of <b>t_pdf_tab</b> into the <b>OBJCONT</b> parameter of SO_OBJECT_SEND. How will I be able to attach my second, third, etc. reports to the email? Is appending the lines of t_pdf_tab of each smartform to an internal table and pass it to OBJCONT?

Please help. Points for any helpful answer. Thanks in advance

5 REPLIES 5
Read only

Former Member
0 Likes
821

Hi Maple,

I am sending you the example code.

please go through it you will get the idea.

************1st attachment data taken into lt_objbin1

Loop at ITAB.

Append lt_objbin1 .

Endloop.

****1st Attachemnt

  • Write Packing List (Attachment)

l_att_type = 'txt'.

DESCRIBE TABLE lt_objbin1 LINES l_tab_lines.

READ TABLE lt_objbin1 INDEX l_tab_lines.

lt_objpack1-doc_size = ( l_tab_lines - 1 ) * 255

+ STRLEN( lt_objbin1 ).

lt_objpack1-transf_bin = 'X'.

lt_objpack1-head_start = 1.

lt_objpack1-head_num = 0.

lt_objpack1-body_start = 1.

lt_objpack1-body_num = l_tab_lines.

lt_objpack1-doc_type = l_att_type.

lt_objpack1-obj_name = 'Cost allocation file'.

lt_objpack1-obj_descr = 'Cost allocation file'.

APPEND lt_objpack1.

******lt_objbin1 is the attachment table. here in the 1st line size is from 0 to l_tab_lines .

*****************2nd Attachment data taken into itab2.

Loop at ITAB.

Append lt_objbin1 .

Endloop.

******************2nd Attachment

  • Write Packing List (Attachment)

l_att_type = 'txt'.

DESCRIBE TABLE lt_objbin1 LINES l_tab_lines1.

l_tab_lines2 = l_tab_lines1 - l_tab_lines.

READ TABLE lt_objbin INDEX l_tab_lines2.

lt_objpack1-doc_size = ( l_tab_lines2 - 1 ) * 255 + STRLEN( lt_objbin1 )

.

lt_objpack1-transf_bin = 'X'.

lt_objpack1-head_start = l_tab_lines2.

lt_objpack1-head_num = 0.

lt_objpack1-body_start = l_tab_lines + 1.

lt_objpack1-body_num = l_tab_lines2.

lt_objpack1-doc_type = l_att_type.

lt_objpack1-obj_name = 'Success file '.

lt_objpack1-obj_descr = 'Success file '.

APPEND lt_objpack1.

*****************Here the line size is from l_tab_lines + 1 to l_tab_lines2.

All the variables must be declared properly.

let me know if you need anymore clarifications on this.

Reward points if u find this suggestion helpful.

Thanks,

Yuvaraj

Read only

0 Likes
821

Hello Yuvaraj!

Thanks for the tip. I have another question, though. When you attach the ITAB contents to lt_objbin1, do you still need to perform the TABLE_COMPRESS function? If yes, what will be the parameters?

Thanks again.

Read only

0 Likes
821

Hi,

Check this

aRs

Read only

0 Likes
821

Hi Maple,

In this case no need to perform the TABLE_COMPRESS function.

It will work.

I have used it and using this code only I have sent two attachments as text files.

Lel me know if u still need any clarification on this.

Thanks,

Yuvaraj

Read only

Former Member
0 Likes
821

Did not use SO_OBJECT_SEND.

Used instead the following classes:

cl_bcs

cl_document_bcs

cl_sapuser_bcs

cl_cam_address_bcs