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

SO_DOCUMENT_SEND_API1

PS_1978
Active Participant
0 Likes
567

Hi,

I am using the Function Module to send email with attachment. The program is running fine and i am able to send email with the attachment successfully. There are 10 lines in the internal table, but in the attachment i can see all of them in 5 or 6 lines. I want each record in a separate line. Please suggest me how to proceed this.

Secondly with the body of the message. How can we enter the text in new line?

Regards,

Phani.

5 REPLIES 5
Read only

Laxmana_Appana_
Active Contributor
0 Likes
537
Read only

Former Member
0 Likes
537

check OBJ- Size .

Regards

Prabhu

Read only

0 Likes
537

Hi Prabhu,

As per your suggestion, i have checked the document size and corrected it. But the problem is still there.

Have a look at the code used to append the attachment table:

<b>

class cl_abap_char_utilities definition load.
constants:
    con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
    con_cret type c value cl_abap_char_utilities=>CR_LF.


  CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
         INTO it_attach SEPARATED BY con_tab.
*  CONCATENATE it_attach con_cret INTO it_attach.
  APPEND  it_attach.

  LOOP AT it_ekpo INTO wa_charekpo.
    CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
                wa_charekpo-aedat wa_charekpo-matnr
           INTO it_attach SEPARATED BY con_tab.
*    CONCATENATE it_attach con_cret INTO it_attach.
    APPEND  it_attach.
  ENDLOOP.

</b>

Code for Finding Document size and filling corresponding details:

<b>

CLEAR w_doc_data.
describe TABLE it_attach LINES w_cnt.
  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[] = pit_attach[].

</b>

Code of the FM:

<b>

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.

</b>

Thanks in Advance,

Regards,

Phani.

Read only

0 Likes
537

describe TABLE it_attach LINES w_cnt.

READ TABLE it_attach INDEX w_cnt.

<b> w_doc_data-doc_size =

( w_cnt - 1 ) * 1055 + STRLEN( it_attach ).</b>

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[] = pit_attach[].

are u missing columns or rows ?

Regards

Prabhu

Read only

Former Member
0 Likes
537

Hai,

Coming in 5 /6 lines is due to unequal lengths of internal tbale line length and the length of line in the out put file(generalluy 255 characters) you see.

So decrease the length of line filed in the internal table in you report.

Hope you could get it after this correction.

<b>Reward Points if it helps you.</b>

Regds,

Rama chary.Pammi