Application Development 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: 

SO_DOCUMENT_SEND_API1 - sender mail address

Former Member
0 Kudos

Hi,

I am using function module SO_DOCUMENT_SEND_API1 to send mail with excel attachment.But i am getting error 6 when i pass karthi@company.com as sender address.

But at the same time I pass sy-user to sender address the mail is sent successfully. Where is the problem.Can't we give generic mail ID while sending mail to externally.

My requirement was to give a constant mail ID as sender irrespective of who ever is sending the mail.

Regards,

Karthik.k

13 REPLIES 13

Former Member
0 Kudos

Hello,

I think the problem is due to the error in the type of the receiver

change it to<b> T_RECEIVERS-COM_TYPE = 'INT'.</b>

Cheers,

Vasanth

Former Member
0 Kudos

Check this sample code, it should help you out. Check once the email address declarations.

&----


*& Report ZEMAIL_ATTACH *

*& *

&----


*& Example of sending external email via SAPCONNECT *

*& *

&----


REPORT ZEMAIL_ATTACH .

TABLES: ekko.

PARAMETERS: p_email TYPE somlreci1-receiver

DEFAULT 'test@sapdev.co.uk'.

TYPES: BEGIN OF t_ekpo,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

aedat TYPE ekpo-aedat,

matnr TYPE ekpo-matnr,

END OF t_ekpo.

DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,

wa_ekpo TYPE t_ekpo.

TYPES: BEGIN OF t_charekpo,

ebeln(10) TYPE c,

ebelp(5) TYPE c,

aedat(8) TYPE c,

matnr(18) TYPE c,

END OF t_charekpo.

DATA: wa_charekpo TYPE t_charekpo.

DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0

WITH HEADER LINE.

DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0

WITH HEADER LINE.

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,

gd_error TYPE sy-subrc,

gd_reciever TYPE sy-subrc.

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

*START_OF_SELECTION

START-OF-SELECTION.

  • Retrieve sample data from table ekpo

PERFORM data_retrieval.

  • Populate table with detaisl to be entered into .xls file

PERFORM build_xls_data_table.

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

*END-OF-SELECTION

END-OF-SELECTION.

  • Populate message body text

perform populate_email_message_body.

  • Send file by email as .xls speadsheet

PERFORM send_file_as_email_attachment

tables it_message

it_attach

using p_email

'Example .xls documnet attachment'

'XLS'

'filename'

' '

' '

' '

changing gd_error

gd_reciever.

  • Instructs mail send program for SAPCONNECT to send email(rsconn01)

PERFORM initiate_mail_execute_program.

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


FORM data_retrieval.

SELECT ebeln ebelp aedat matnr

UP TO 10 ROWS

FROM ekpo

INTO TABLE it_ekpo.

ENDFORM. " DATA_RETRIEVAL

&----


*& Form BUILD_XLS_DATA_TABLE

&----


  • Build data table for .xls document

----


FORM build_xls_data_table.

data: ld_store(50) type c. "Leading zeros

CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode

con_tab TYPE x VALUE '09'. "OK for non Unicode

*If you have Unicode check active in program attributes thnen you will

*need to declare constants as follows

*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 con_cret it_attach INTO it_attach.

APPEND it_attach.

LOOP AT it_ekpo INTO wa_charekpo.

*Modification to retain leading zeros

  • inserts code for excell REPLACE command into ld_store

  • =REPLACE("00100",1,5,"00100")

concatenate '=REPLACE("' wa_charekpo-ebelp '",1,5,"'

wa_charekpo-ebelp '")' into ld_store .

  • concatenate ld_store into .xls file instead of actual value(ebelp)

CONCATENATE wa_charekpo-ebeln ld_store.

*End of modification

wa_charekpo-aedat wa_charekpo-matnr

INTO it_attach SEPARATED BY con_tab.

CONCATENATE con_cret it_attach INTO it_attach.

APPEND it_attach.

ENDLOOP.

ENDFORM. " BUILD_XLS_DATA_TABLE

&----


*& Form SEND_FILE_AS_EMAIL_ATTACHMENT

&----


  • Send email

----


FORM send_file_as_email_attachment tables pit_message

pit_attach

using p_email

p_mtitle

p_format

p_filename

p_attdescription

p_sender_address

p_sender_addres_type

changing p_error

p_reciever.

DATA: ld_error TYPE sy-subrc,

ld_reciever TYPE sy-subrc,

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.

ld_email = p_email.

ld_mtitle = p_mtitle.

ld_format = p_format.

ld_attdescription = p_attdescription.

ld_attfilename = p_filename.

ld_sender_address = p_sender_address.

ld_sender_address_type = p_sender_addres_type.

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

  • Populate zerror return code

ld_error = sy-subrc.

  • Populate zreceiver return code

LOOP AT t_receivers.

ld_receiver = t_receivers-retrn_code.

ENDLOOP.

ENDFORM.

&----


*& Form INITIATE_MAIL_EXECUTE_PROGRAM

&----


  • Instructs mail send program for SAPCONNECT to send email.

----


FORM initiate_mail_execute_program.

WAIT UP TO 2 SECONDS.

SUBMIT rsconn01 WITH mode = 'INT'

WITH output = 'X'

AND RETURN.

ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM

&----


*& Form POPULATE_EMAIL_MESSAGE_BODY

&----


  • Populate message body text

----


form populate_email_message_body.

REFRESH it_message.

it_message = 'Please find attached a list test ekpo records'.

APPEND it_message.

endform. " POPULATE_EMAIL_MESSAGE_BODY

ashish

Former Member
0 Kudos

Hi

I am getting error when I pass karthik@company.com in sender_address and sender_address_type as 'U'.

But at the same time when I pass sy-user to sender_address and 'B' to addrss type mail is sent successfully.

Regards,

Karthik.

Former Member
0 Kudos

Any suggestion.

0 Kudos

Too late, but could be useful to others.

Use FM SO_DOCUMENT_SEND_API1 just like used to do with SO_NEW_DOCUMENT_SEND_API1 and add following importing parameters:

SENDER_ADDRESS = sender email address

SENDER_ADDRESS_TYPE = 'SMTP'.

Regards

0 Kudos

Antonio,

Thank you, you have answered my forum query I placed a while ago. Shame I didn't see this 3 months ago, have not found any other documentation to suggest that this was the solution I was after.

Steve

0 Kudos

Hi,

I am using SO_NEW_DOCUMENT_SEND_API1 but in this FM where do we need to populate senders id.

thanks.

pradeep

0 Kudos

hi,

i m using ' ' fm with parameter,

SENDER_ADDRESS = sender email address

SENDER_ADDRESS_TYPE = 'SMTP'.

but i got an error 'Element NOAUTHORITYCHECK is not available in the container'.

Help Me to Solve It?

Regards,

Parixit Patel.

Panamax Infotel Ltd.

0 Kudos

Check if SAP Office consistency problems exist an fix them:

Program RSSOUSCO

or Transaction SU55

0 Kudos

Hi,

I run the report and it is showing the result as

New Office users:    0

Office users with new delete flags:    0

Records deleted in SOUD:    0

Records deleted in SOUC:    0

Records changed in SOUC:    0

New records in SOUC:    0

Number of users w/o address assignment ( SOUD w/o SO_KEY )    0

Number of users for which SO_KEY could be generated    0

Number of users for which no SO_KEY could be generated subsequently    0

Number of users for which no entry exists in table USR21    0

No. of users with address assignment (SOUD with SO_KEY)    0

Number of users for which no entry exists in table USR21 (user administration)    0

Number of users for which person group <> BC01 is in address    0

Number of users with address reference which is no longer in CAM    0

Number of users with SOUD-USADR<>SPACE / SO_KEY in ADCP=SPACE and no subseq.generation possible    0

Number of users for which SO_KEY was generated subsequently    0

Number of users with SO_KEY to which a more recent object is assigned    0

Number of users for which no change in address assignment was required    0

Number of users for which no where-used list could be created subsequently    0

But Still i m getting that error

Thanks

Saurabh Shrivastava

Former Member
0 Kudos

i was also getting the same error 'element NOAUTHORITYCHECK found in container '

but then i passed below parameters to the FM - 'SO_DOCUMENT_SEND_API1'

sender_address = sy-uname

sender_address_type = 'SMTP'

now i am getting below error .

'Activation settings not yet maintained'

please help me on that.

0 Kudos

Hi shweta,

i done this type of requirement by using the function module 'SO_NEW_DOCUMENT_ATT_SEND_API1'.

check the following code.I hope it is useful.

 SELECT SINGLE ADRNR FROM LFA1  INTO T_DATA-ADRNR WHERE LIFNR = T_DATA-LIFNR.
    SELECT SINGLE SMTP_ADDR FROM ADR6 INTO T_DATA-email WHERE ADDRNUMBER = T_DATA-ADRNR.
      CLEAR: c_current_date, c_current_time.
      c_current_date = sy-datum.
      c_current_time = sy-uzeit.
      l_dd = c_current_date+6(2).
      l_mm = c_current_date+4(2).
      l_yyyy = c_current_date+0(4).
      CONCATENATE l_dd l_mm l_yyyy INTO l_date.

*   /*------------Attachment--------------------/
      REFRESH: i_reclist,
      i_objtxt,
      i_objbin,
      i_objpack.
      i_objbin[] = it_mess_att[]. "your pdf data or excel data

      CONCATENATE 'Shipping Notification Summary sent on' l_date l_time
               INTO c_title SEPARATED BY space.
      i_objtxt = c_title.
      APPEND i_objtxt.
      i_objtxt     = space.
      APPEND i_objtxt.
      CONCATENATE 'To:' t_data-email
                          INTO i_objtxt SEPARATED BY space.
      APPEND i_objtxt.
      i_objtxt     = space.
      APPEND i_objtxt.
      i_objtxt     = text-t01.
      APPEND i_objtxt.
      i_objtxt     = text-t02.
      APPEND i_objtxt.
      DESCRIBE TABLE i_objtxt LINES v_lines_txt.
      READ TABLE i_objtxt INDEX v_lines_txt.

      wa_doc_chng-obj_name = 'Shipping Notification Summary'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr = 'Shipping Notification Summary'.
      wa_doc_chng-sensitivty = 'F'.
      wa_doc_chng-doc_size = v_lines_txt * 255.
*   /*-----------------Main Text---------------/
      CLEAR i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_txt.
      i_objpack-doc_type = 'RAW'.
      APPEND i_objpack.
*   /*----------------Attachment (pdf-Attachment)-----------------/
      CLEAR: l_fname_ext.
      i_objpack-transf_bin = 'X'.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
      DESCRIBE TABLE i_objbin LINES v_lines_bin.
      READ TABLE i_objbin INDEX v_lines_bin.
      i_objpack-doc_size = v_lines_bin * 255 .
      i_objpack-body_num = v_lines_bin.
      i_objpack-doc_type = 'PDF'."your pdf or excel format
      i_objpack-obj_name = 'Shippin g Notification Summary'.

      CONCATENATE t_data-lifnr '_' l_date '_' c_current_time '.PDF'
                               INTO l_fname_ext.

      CONDENSE l_fname_ext NO-GAPS.
      CONCATENATE 'Shipping Notification Summary_' l_fname_ext INTO l_fname_ext.
      i_objpack-obj_descr = l_fname_ext.
      APPEND i_objpack.

      CLEAR i_reclist.
      i_reclist-receiver = t_data-email.
      i_reclist-rec_type = 'U'.
      i_reclist-com_type = 'INT'.
      i_reclist-notif_del = 'X'.
      i_reclist-notif_ndel = 'X'.
      APPEND i_reclist.

* calling function module to send email
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = wa_doc_chng
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = i_objpack
          contents_bin               = i_objbin
          contents_txt               = i_objtxt
          receivers                  = i_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.

Regards

Arjun

frank_bork
Participant
0 Kudos

Dear all,

I have the same problem: 'Element NOAUTHORITYCHECK is not available in the container'

Itried both FM´s 'SO_NEW_DOCUMENT_ATT_SEND_API1' and 'SO_DOCUMENT_SEND_API1' with all the parameters mentioned above. I started report RSSOUSCO(result below). The document is sent but the message is always in the protocol and is looking strange for the user. Any idea how I can solve the issue and prevent this strange message?

If I change the adress type to 'B' (see post from Karthik above) in the receiver list then the message is gone. But I have no idea if I get other problems if I change from 'U' to 'B'.

Thanks in advance.

Frank

New Office users: 0

Office users with new delete flags: 0

Records deleted in SOUD: 0

Records deleted in SOUC: 0

Records changed in SOUC: 0

New records in SOUC: 0

Number of users w/o address assignment ( SOUD w/o SO_KEY ) 0

Number of users for which SO_KEY could be generated 0

Number of users for which no SO_KEY could be generated subsequently 0

Number of users for which no entry exists in table USR21 0

No. of users with address assignment (SOUD with SO_KEY) 2.173

Number of users for which no entry exists in table USR21 (user administration) 0

Number of users for which person group <> BC01 is in address 0

Number of users with address reference which is no longer in CAM 0

Number of users with SOUD-USADR<>SPACE / SO_KEY in ADCP=SPACE and no subseq.generation possible 0

Number of users for which SO_KEY was generated subsequently 0

Number of users with SO_KEY to which a more recent object is assigned 0

Number of users for which no change in address assignment was required 0

Number of users for which no where-used list could be created subsequently 0