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_NEW_DOCUMENT_SEND_API1 not working

Former Member
0 Kudos

Hi,

I am using FM SO_NEW_DOCUMENT_SEND_API1 to send mail to the external user but it is showing in waiting state in my outbox.When i execute the FM sy-subrc is 0, suggesting FM executed correctly and i can see the mail in my outbox as well in waiting status showing message Wait for communications service but i am not able to see the mail in SOST in queue.I tried with program rsconn01 with following code.

SUBMIT rsconn01 USING SELECTION-SET 'INTERNET-EMAIL' AND RETURN.

*

*CALL FUNCTION 'SO_DEQUEUE_UPDATE_LOCKS'.

but still its not working.

Regards,

Rushikesh

15 REPLIES 15

Former Member
0 Kudos

hi

excute the program rsconn01 and then excute your program.

Edited by: venu gopal on Oct 8, 2008 6:55 AM

Former Member
0 Kudos

Looks like basis issue, pls contact your basis team

Regards

Madhan

former_member188685
Active Contributor
0 Kudos
*"     VALUE(COMMIT_WORK) LIKE  SONV-FLAG DEFAULT SPACE

are you using the commit_work option.

call function 'SO_NEW_DOCUMENT_SEND_API1'
...
..
commit_work  = 'X' "<-----add this

0 Kudos

Vijay,

I tried using the commit but it is giving me SHORT DUMP giving error analysis...

++The call of a COMMIT WORK in a FORM, that will not be executed until++
++the commit or rollback point of the caller using the variant++
++PERFORM ... ON COMMIT or PERFORM ... ON ROLLBACK is not permitted.+

+

0 Kudos

what is the program/include name which causing the dump.

show your function call related code.?

0 Kudos

Vijay,

There is an exit ZXCO1U01 inwhich i am calling FM Z_PP_POCHNGE_EMAIL_NOTIFY which contain

subroutine where FM to send external mail is getting called...

*--Send Mail To Sales Associate
    PERFORM send_mail TABLES lt_mailbody
                             lt_receiver_tab
                       USING lf_doc_data
                    CHANGING lf_subrc.

In This subroutine i am calling SO_NEW_DOCUMENT_SEND_API1

FORM send_mail  TABLES   lt_mailbody
                         lt_receiver_tab
                USING    lf_doc_data     TYPE sodocchgi1
                Changing lf_subrc  type SYSUBRC.

  DATA:      lf_doc TYPE so_obj_tp.

  CONSTANTS: c_x TYPE so_text001 VALUE 'X'.

  lf_doc = 'RAW'.

*-

Send External Mail To Sales Associate{

code} CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = lf_doc_data

document_type = lf_doc

  • COMMIT_WORK = c_x

put_in_outbox = c_x

TABLES

object_content = lt_mailbody

receivers = lt_receiver_tab

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.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

I tried using commit at all possible places like in FM,exit even after the routine but still it is giving me DUMP.

Thanks and Regards,

Rushikesh

0 Kudos

hi,

in the below code commit_work is commented. remove the comment pass 'X' to commit_work.

Send External Mail To Sales Associate{{code}code} CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = lf_doc_data

document_type = lf_doc

    • COMMIT_WORK = c_x*

put_in_outbox = c_x

TABLES

object_content = lt_mailbody

receivers = lt_receiver_tab

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.

Former Member
0 Kudos

Dear

Venu Gopal's Answer is totally correct. run that program (rsconn01)

Gopal Thanks

0 Kudos

Hi,

I am having the same issue,

i even tried doing it through se37 test ..

It worked even there..!

But not in my ABAP CODE.

If I get the answer I will reply with it ASAP..

0 Kudos

It is basis issue, receiver destination is not defind. I also faced this issue like I have to send mail externally. Once basis person has made change, it is working well.

0 Kudos

Hi,

Did you check the status in t code SOST?

Is it yellow or green or red?

If it is yellow then select it and send it from SOST.

Change ur code like this.

SUBMIT rsconn01 USING SELECTION-SET 'INTERNET-EMAIL' AND RETURN.

SUBMIT rsconn01 USING SELECTION-SET 'INT' AND RETURN.

CALL FUNCTION 'SO_DEQUEUE_UPDATE_LOCKS'.

Instead of INTERNET-EMAI use INT.

Also after calling Mail FM issue explicit COMMIT WORK if sy-subrc IS ZERO

Thanks,

Vinod.

Edited by: Vinod Reddy Vemuru on Dec 24, 2008 3:49 PM

Former Member
0 Kudos

Hi,

Couple of questions for clarification.

1. Is there a entry is SOST for your mail?

If yes,

then either the mail server id for your SAP box is not defined or the system couldn't resolve the e-mail id to be used.

Check the setting for the Internet mail sever in transaction SCOT under the node SMTP. If a sever is not existing there then ask you Basis team to configure that for you.

If server address exists trace the message in SOST and see if it can find the e-mail ID.

If No (no entry in SOST),

this FM requires a commit work to get triggered and sent a mail to SOST. If there are no entries in SOST then the you need to commit the transaction. But, as are coding inside a User Exit, you can't use the 'commit' parameter or the statement 'COMMIT WORK' there. It is bound to give you a dump.

Now usually if you are using a user exit, the LUW gets executed with the main transaction commit. So, please check that you can execute the transaction without a dump or error message (so that commit work is triggered).

Regards

Barada

0 Kudos

Hi,

In addition to above replies, If u r calling this in USER EXIT it is not advisable to use commit work.

So only option i can thing of is place ur code in an UPDATE FM(Create one FM and place ur code in the FM) (In tributes of FM select UPDATE FM)and call this FM in UPDATE TASK. So do COMMIT WORK in side this FM. It won't affect the functionality in any way. But only difference is Ur commit happens only if every thing in the transaction goes well.

Thanks,

Vinod.

Former Member
0 Kudos

REPORT zsendemail .

PARAMETERS: psubject(40) type c default 'Hello',

p_email(40) type c default 'WRITE MAIL ID' .

data: it_packing_list like sopcklsti1 occurs 0 with header line,

it_contents like solisti1 occurs 0 with header line,

it_receivers like somlreci1 occurs 0 with header line,

it_attachment like solisti1 occurs 0 with header line,

gd_cnt type i,

gd_sent_all(1) type c,

gd_doc_data like sodocchgi1,

gd_error type sy-subrc.

data: it_message type standard table of SOLISTI1 initial size 0

with header line.

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

*START-OF-SELECTION.

START-OF-SELECTION.

Perform populate_message_table.

*Send email message, although is not sent from SAP until mail send

*program has been executed(rsconn01)

PERFORM send_email_message.

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

perform initiate_mail_execute_program.

&----


*& Form POPULATE_MESSAGE_TABLE

&----


  • Adds text to email text table

----


form populate_message_table.

Append 'Email line 1' to it_message.

Append 'Email line 2' to it_message.

Append 'Email line 3' to it_message.

Append 'Email line 4' to it_message.

endform. " POPULATE_MESSAGE_TABLE

&----


*& Form SEND_EMAIL_MESSAGE

&----


  • Send email message

----


form send_email_message.

  • Fill the document data.

gd_doc_data-doc_size = 1.

  • Populate the subject/generic message attributes

gd_doc_data-obj_langu = sy-langu.

gd_doc_data-obj_name = 'SAPRPT'.

gd_doc_data-obj_descr = psubject.

gd_doc_data-sensitivty = 'F'.

  • Describe the body of the message

clear it_packing_list.

refresh it_packing_list.

it_packing_list-transf_bin = space.

it_packing_list-head_start = 1.

it_packing_list-head_num = 0.

it_packing_list-body_start = 1.

describe table it_message lines it_packing_list-body_num.

it_packing_list-doc_type = 'RAW'.

append it_packing_list.

  • Add the recipients email address

clear it_receivers.

refresh it_receivers.

it_receivers-receiver = p_email.

it_receivers-rec_type = 'U'.

it_receivers-com_type = 'INT'.

it_receivers-notif_del = 'X'.

it_receivers-notif_ndel = 'X'.

append it_receivers.

  • Call the FM to post the message to SAPMAIL

call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

exporting

document_data = gd_doc_data

put_in_outbox = 'X'

importing

sent_to_all = gd_sent_all

tables

packing_list = it_packing_list

contents_txt = it_message

receivers = it_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.

  • Store function module return code

gd_error = sy-subrc.

  • Get it_receivers return code

loop at it_receivers.

endloop.

endform. " SEND_EMAIL_MESSAGE

&----


*& Form INITIATE_MAIL_EXECUTE_PROGRAM

&----


  • Instructs mail send program for SAPCONNECT to send email.

----


form initiate_mail_execute_program.

wait up to 2 seconds.

if gd_error eq 0.

submit rsconn01 with mode = 'INT'

with output = 'X'

and return.

endif.

endform.

Former Member
0 Kudos

This is exactly my case and i just solved it. thanks to those who mentioned the solution although this thread is still tagged as "not anwered".

What I did was:

  • create a Z-FM to send the email.

  • Make the attribute of the FM to Update Module

  • Did not put X in the Commit_Work in FM SO_NEW_DOCUMENT_SEND_API1 .

  • Add "IN UPDATE TASK" when the Z-FM is called.

I think the reason is that, when the original Z-FM is in normal mode, the sending of email does NOT get included in the UPDATE task of the ON COMMIT process that triggered the user-exit. So, the mail is not sending out (not in queue).

When the FM is changed to the UPDATE MODULE and with IN UPDATE TASK, the required work of sending the email is included in the UPDATE task (LUW) of the main program that triggered the user-exit.