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_NEW_DOCUMENT_SEND_API1 - text file getting created

Former Member
0 Likes
2,854

I am using SO_NEW_DOCUMENT_SEND_API1 to send an email My requirement is to send a text line as the email body. But in my email, there is no body coming and a an attached text file is coming with that text. Please check the code below and let me know what to so.

****************************************************  

  DATA: listobject       LIKE abaplist OCCURS 0 WITH HEADER LINE.
  DATA: i_mailpakketje LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
        i_mailheader   LIKE solisti1 OCCURS 1 WITH HEADER LINE,
        i_object       LIKE solisti1 OCCURS 0 WITH HEADER LINE,
        i_mailtekst    LIKE solisti1 OCCURS 10 WITH HEADER LINE,
        i_ontvanger    LIKE somlreci1 OCCURS 5 WITH HEADER LINE.

  DATA: h_true         TYPE c.

  DATA: h_boodschap(40) TYPE c.
DATA: OBJECT_HEADER  LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.

  DATA: doc_chng LIKE sodocchgi1.
  DATA: tab_lines LIKE sy-tabix.

  DATA: user_address LIKE sousradri1 OCCURS 1 WITH HEADER LINE.
  DATA: sent_to_all LIKE sonv-flag.

************************************************

* Create the document which is to be sent
  CONCATENATE 'Foutmelding Content Server: ' sy-sysid
   INTO h_boodschap SEPARATED BY space.
  doc_chng-obj_descr = h_boodschap.

* Mail body text

  APPEND 'Fout opgetreden bij opvragen plaatje!' TO i_mailtekst.

  i_ontvanger-receiver = 'PAL.SUBHAJIT@GMAIL.COM'.
  i_ontvanger-rec_type  = 'U'.
  i_ontvanger-express  = 'X'.
  i_ontvanger-notif_del = 'X'.
  i_ontvanger-notif_read = 'X'.
  i_ontvanger-notif_ndel = 'X'.
  APPEND i_receivers.

   CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
    EXPORTING
      document_data              = doc_chng

       commit_work                = 'X'
    IMPORTING
      sent_to_all                = sent_to_all
    TABLES
      object_content             = i_mailtekst
      receivers                  = i_receivers

    EXCEPTIONS
      too_many_receivers         = 1
      document_not_sent          = 2
      operation_no_authorization = 4
      OTHERS                     = 99.

*********************************

13 REPLIES 13
Read only

Former Member
0 Likes
2,603

For Body of the mail, you need to pass the table in contents_txt.

and for attachment you need to pass it in packing_list.

I am not sure what Object_content is for.

Read only

Former Member
0 Likes
2,603

Hi also define table i_receivers.

DATA: i_receivers LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

Read only

venkateswaran_k
Active Contributor
0 Likes
2,603

    tables

      packing_list               = gt_objpack

      object_header              = gt_objhead

      contents_txt               = gt_objtxt

      receivers                  = gt_reclist

You have to pass the above table - contents_txt ....

Example....gt_output_soli is my output content table....

 

*- Creation of the document attachment
   Describe table gt_output_soli lines g_lines.

*- Don't create attachment if no data is present

  if g_lines <> 0.
    loop at gt_output_soli into gf_output_soli.
      gf_objtxt = gf_output_soli.

*- Append

      append gf_objtxt to gt_objtxt.

*- Clear

      clear gf_objtxt.
    endloop.
  endif.

Regards,

Venkat

Read only

Former Member
0 Likes
2,603

Hi,

I am not able to find this contentc_txt table.

I amusing the FM 'SO_NEW_DOCUMENT_SEND_API1' in SAP ECC 6.0.

Following are the import/export/table values :

Import

======

DOCUMENT_DATA

DOCUMENT_TYPE

PUT_IN_OUTBOX

COMMIT_WORK

Export

======

SENT_TO_ALL

NEW_OBJECT_ID

Tables

==========

OBJECT_HEADER

OBJECT_CONTENT

CONTENTS_HEX  ( take the contents in BINARY mode only)

OBJECT_PARA

OBJECT_PARB

RECEIVERS

---------------------------------------------------------

If this is not the appropriate function module for this purpose, can you please suggest the appropriate function module.

Read only

0 Likes
2,603

Use this function instead.... 

call function 'SO_DOCUMENT_SEND_API1'

    exporting

      document_data              = gf_doc_chng

 

*      put_in_outbox              = 'X'
*      sender_address             = ' '

      commit_work                = 'X'
    importing
      sent_to_all                = g_sent_all
    tables
      packing_list               = gt_objpack
      object_header              = gt_objhead
      contents_txt               = gt_objtxt
      receivers                  = gt_reclist
    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.
  if sy-subrc = 0.
    cl_os_transaction_end_notifier=>raise_commit_requested( ).
    call function 'DB_COMMIT'.
    cl_os_transaction_end_notifier=>raise_commit_finished( ).
  else.
    write 'Not send'.
  endif.

Regards,

Venkat

Read only

0 Likes
2,603

Hi,

  I am still getting the text attachment. Can you please provide me the details related this function module.

Like what the data you have populated in the FM etc.

Read only

0 Likes
2,603

Hi,

Better use new standards with the class CL_BCS!

Anyway your issue is quite common... Check your SMTP settings in SCOT. Output for RAW Text has to be set to TXT, not PDF.

Kr,

Manu.

Read only

0 Likes
2,603

I see it also depends on the config.

Read only

0 Likes
2,603

What do you mean?? Is the output for RAW text is set to TXT in INT/SMTP settings or not?

Read only

venkateswaran_k
Active Contributor
0 Likes
2,603

Look my code  for word gt_objpack... 

   tables

      packing_list               = gt_objpack

for that

you have to set the value as HTM as show below

*- Creation of the entry for the compressed document

  gf_objpack-transf_bin = ' '.
  gf_objpack-head_start = 1.
  gf_objpack-head_num   = 0.
  gf_objpack-body_start = 1.
  gf_objpack-body_num   = g_msg_lines.
  gf_objpack-doc_type   = c_doc_type_htm.   "  value 'HTM',

*- Append

  append gf_objpack to gt_objpack.

*- Clear

  clear gf_objpack.

Regards,

Venkat

Read only

0 Likes
2,603

gf_objpack-doc_type   = c_doc_type_htm.   "  value 'HTM' --->  Now this is  creating a html file attachment instead of text file.

But its not coming in the body.

Read only

0 Likes
2,603

P

Please refer to your SCOT settings as above.

Regards,

Venkat

Read only

Former Member
0 Likes
2,603

The SCOT settings is :

And I am getting the attachment istead of text in the body.