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

Former Member
0 Likes
2,009

i cannot send an email using this code.

there's an error message that will appear in the status of my workplace.

The error is "The following status was received for the document <Example .xls documnet attachment> sent by you to the recipient <manuel.j.gonzaga.iii@accenture.com>:

<Definately cannot transfer message to node IMGW due to connection error>."

What does this mean?

How will I troubleshoot this?

&----


*& 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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,233

Hi Manuel ...

please tell to your Basis to coinfigure the mail server to your sap server ....

so that all mails from sap will be outbound to web .....

the Configuration means not only adding the mail server details in the SCOT ... before that ... your basis has to check the connective between the oubound of the sap mail server.

by defualt all the connectivity program in sap are blocked .... only basis can unlock ... so that you mails will be send/received .

<b>see the steps ;</b>

<b>How to Configure the Unix SAP Internet Mail Gateway?

Configuring SAP 4.6x Internet mail Gateway</b>

SAP can be configured to send and receive emails from different sources.This section explains how to integrate SAPOffice with an external emailsystem. Your Internet email must be configured and running prior to this.Email from SAP is forwarded to the users external email system..

You can configure inbound and outbound forwarding. Outbound flow forwardsa SAP message (eg: update termination) via UNIX sendmail to the intended recepient. Inbound accepts a message from sendmail and places it in the users SAPOffice inbox. Many companies prefer to configure outbound only.

<b>Configuring outbound forwarding</b>

<b>SAP configuration</b>

1. <b>Create your RFC destination for outbound email using transaction SM59</b>

RFC Destination : SAP_INTERNET_GATEWAY

Connection Type : T

Description : SAP internet mail gateway

Click on 'Explicit Host' if you wanton demand gateway dameon invocation.

Program : /sapmnt/SID/exe/mlunxsnd

Target Host : Enter hostname that runs your central instance.

Click 'Test Connection' and you should seea successfull message.

2. <b>Shared Office Settings transaction SO16-> Send -> Settings or

directly via transaction SCOT- SAPconnect Administation</b>

Nodes - Create

Node : IMAIL

Description : SAP internet mail gateway

RFC Destination : SAP_INTERNET_GATEWAY

Tick : Internet

Address Area : *

Tick : All formats

Dev. type : Choose an approciate Printer Device

Set further addresstype : N

Maximum waiting timefor repeat send attempt procedure : Blank or decide for yourself

Tick : Node is ready for use

Setting

- DefaultDomain : <your company domain>.com

- Conversionrule : require if your communication device only support one format.

e.g. if you email system only support the format RAW (ASCII text format)

Format To Format Ranking Function module

ALI RAW 1 SX_OBJECT_CONVERT_ALI_RAW (convert APAP List)

Referto note 171698 - SAPconnect: Formats, conversion, device type

<b>UNIX configuration</b>

1 .. cd /sapmnt/SID/exe

2 ..csh

..mlsomadm mailgw.ini

System Name [C11] :

Client [000] :

Username : MAILADM

Password : MAILADM

Language : E

Load Balancing :

Hostname : <hostname>

System number : <instance_number>

Gateway hostname: <central_instance_hostname>

Gateway Service : <instance number>

Use SAP Router :

Trace level :

Sendmail Command [/usr/lib/sendmail -i -f<SENDER_ADDRESS>]:

Codepage [ISO-8859-1] :

Trace Level (Outbound) [0] :

Update file sapmailsid.cfg? [Y]

<b>Testing whether your configuration is successful</b>

1. Logon to SAP

2. Execute transaction SO01

3. Write a message and send it to <your_internet_email_address>

4. If you don't see the mail in your internet mailbox, go back and review steps 1-12

Schedule the SAP Internet Mail Gateway Jobs to start every 5 minutes

1. Create

2. Position your cursor at INT

3. Click Schedule and supply the date and time

4. Click Schedule periodically and tick Minutes and type in 5

5. Click Create and you are done

6. Click Show Scheduling to check

<b>Problems that you might encounter :-</b>

If you have set up a node in SCOT and it tests out well but recieve the reply.

"Cannot process message in node, parameterscannot be converted".

Make sure the RFC connection is working, and that SapConnect has been installed on the Unix Server or the Microsoft Exchange Server. Originally, I had the same error, and found that nothing had been installed on Unixor Exchange, to support SapConnect.

In <b>SCOT</b> (View -> System Status), your mail remains at the<b> Intransit</b> column.

Check you <b>sendmail.cf</b> files (e.g.Sun Solaris /etc/mail/sendmail.cf). Try using the sendmail command to send a test file at the Unix level. You must be able to send mail at theUnix level before you can send mail at the SAP level.

Another way of connecting to the SAPOffice without setting up the SAPconnectis to use the

<b>please see the link for general settings also :</b>

<a href="http://">http://help.sap.com/search/highlightContent.jsp</a>

reward points if it is usefull ....

Girish

6 REPLIES 6
Read only

Former Member
0 Likes
1,233

hi ,

as u know that for sending mails u have to configure STMP node in SCOT , so please check ur scot settings.

Regards

Peram

Read only

Former Member
0 Likes
1,233

Hi,

Check in the SCOT transaction code whethere is there any message showing in error, if it is error then look at the settings and also in your program

<b> submit rsconn01 with mode = 'INT'

  • with output = 'X' " No Need thi

and return.</b>

Regards

Sudheer

Read only

Former Member
0 Likes
1,233

is it safe to configure the transaction SCOT or do i need to tell the basis to configure it?

Read only

Former Member
0 Likes
1,234

Hi Manuel ...

please tell to your Basis to coinfigure the mail server to your sap server ....

so that all mails from sap will be outbound to web .....

the Configuration means not only adding the mail server details in the SCOT ... before that ... your basis has to check the connective between the oubound of the sap mail server.

by defualt all the connectivity program in sap are blocked .... only basis can unlock ... so that you mails will be send/received .

<b>see the steps ;</b>

<b>How to Configure the Unix SAP Internet Mail Gateway?

Configuring SAP 4.6x Internet mail Gateway</b>

SAP can be configured to send and receive emails from different sources.This section explains how to integrate SAPOffice with an external emailsystem. Your Internet email must be configured and running prior to this.Email from SAP is forwarded to the users external email system..

You can configure inbound and outbound forwarding. Outbound flow forwardsa SAP message (eg: update termination) via UNIX sendmail to the intended recepient. Inbound accepts a message from sendmail and places it in the users SAPOffice inbox. Many companies prefer to configure outbound only.

<b>Configuring outbound forwarding</b>

<b>SAP configuration</b>

1. <b>Create your RFC destination for outbound email using transaction SM59</b>

RFC Destination : SAP_INTERNET_GATEWAY

Connection Type : T

Description : SAP internet mail gateway

Click on 'Explicit Host' if you wanton demand gateway dameon invocation.

Program : /sapmnt/SID/exe/mlunxsnd

Target Host : Enter hostname that runs your central instance.

Click 'Test Connection' and you should seea successfull message.

2. <b>Shared Office Settings transaction SO16-> Send -> Settings or

directly via transaction SCOT- SAPconnect Administation</b>

Nodes - Create

Node : IMAIL

Description : SAP internet mail gateway

RFC Destination : SAP_INTERNET_GATEWAY

Tick : Internet

Address Area : *

Tick : All formats

Dev. type : Choose an approciate Printer Device

Set further addresstype : N

Maximum waiting timefor repeat send attempt procedure : Blank or decide for yourself

Tick : Node is ready for use

Setting

- DefaultDomain : <your company domain>.com

- Conversionrule : require if your communication device only support one format.

e.g. if you email system only support the format RAW (ASCII text format)

Format To Format Ranking Function module

ALI RAW 1 SX_OBJECT_CONVERT_ALI_RAW (convert APAP List)

Referto note 171698 - SAPconnect: Formats, conversion, device type

<b>UNIX configuration</b>

1 .. cd /sapmnt/SID/exe

2 ..csh

..mlsomadm mailgw.ini

System Name [C11] :

Client [000] :

Username : MAILADM

Password : MAILADM

Language : E

Load Balancing :

Hostname : <hostname>

System number : <instance_number>

Gateway hostname: <central_instance_hostname>

Gateway Service : <instance number>

Use SAP Router :

Trace level :

Sendmail Command [/usr/lib/sendmail -i -f<SENDER_ADDRESS>]:

Codepage [ISO-8859-1] :

Trace Level (Outbound) [0] :

Update file sapmailsid.cfg? [Y]

<b>Testing whether your configuration is successful</b>

1. Logon to SAP

2. Execute transaction SO01

3. Write a message and send it to <your_internet_email_address>

4. If you don't see the mail in your internet mailbox, go back and review steps 1-12

Schedule the SAP Internet Mail Gateway Jobs to start every 5 minutes

1. Create

2. Position your cursor at INT

3. Click Schedule and supply the date and time

4. Click Schedule periodically and tick Minutes and type in 5

5. Click Create and you are done

6. Click Show Scheduling to check

<b>Problems that you might encounter :-</b>

If you have set up a node in SCOT and it tests out well but recieve the reply.

"Cannot process message in node, parameterscannot be converted".

Make sure the RFC connection is working, and that SapConnect has been installed on the Unix Server or the Microsoft Exchange Server. Originally, I had the same error, and found that nothing had been installed on Unixor Exchange, to support SapConnect.

In <b>SCOT</b> (View -> System Status), your mail remains at the<b> Intransit</b> column.

Check you <b>sendmail.cf</b> files (e.g.Sun Solaris /etc/mail/sendmail.cf). Try using the sendmail command to send a test file at the Unix level. You must be able to send mail at theUnix level before you can send mail at the SAP level.

Another way of connecting to the SAPOffice without setting up the SAPconnectis to use the

<b>please see the link for general settings also :</b>

<a href="http://">http://help.sap.com/search/highlightContent.jsp</a>

reward points if it is usefull ....

Girish

Read only

0 Likes
1,233

thank you very much Girish Kumar Loganathan. you did help me a lot with this problem.

Read only

Former Member
0 Likes
1,233

thanks also to Sudheer Junnuthula and Prabhu Peram for your help...