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

Send mail in background with SO_DOCUMENT_SEND_API1

Former Member
0 Likes
2,304

Can I send a mail with fm SO_DOCUMENT_SEND_API1 in background mode?

How do it?

Thanks a lot.

cv

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,778

I execute the function but this commited a very long time...

I need execute the function and immediatly return in the abap program...

It's possible?

Can I send a mail with fm SO_DOCUMENT_SEND_API1 in background mode?

How do it?

Thanks a lot.

cv

12 REPLIES 12
Read only

Former Member
0 Likes
1,778

have u tried calling this function module via background task ? I guess it will work.

Read only

Rocky1
Product and Topic Expert
Product and Topic Expert
0 Likes
1,778

Hi,

You don't need to do anything additional to make it function in back ground. Just use it and run in background, there will be no problem.

Thanks & Regards

Rocky

Read only

Former Member
0 Likes
1,779

I execute the function but this commited a very long time...

I need execute the function and immediatly return in the abap program...

It's possible?

Read only

0 Likes
1,778

Yes....that you can do by calling the function module in your code by using the statement VIA BACKGROUND TASK, so that it will execute in background task, and control will return to your ABAP program.

Read only

0 Likes
1,778

What took so long? Probably not the email send...probably the code that builds what you're sending? My memory is that the API is quick...takes a lot more time to build the tables and structure.

Read only

Former Member
0 Likes
1,778

ok kumar, but with CALL FUNCTION 'SO_DOCUMENT_SEND_API1' in background task the mail is not sent...

Read only

Former Member
0 Likes
1,778

It should work.

Problem lies somewhere else I guess.

Just check ur code.

Regards,

Raveesh

Read only

0 Likes
1,778

You can also check in the transaction SOST, send the mails manually from there.

Regards,

Raveesh

Read only

Former Member
0 Likes
1,778

If I execute the function without "in background task" the mail send successfully...

Read only

Former Member
0 Likes
1,778

Solved... The function in background task must be followed by COMMIT WORK (SAP 6.0).

Read only

0 Likes
1,778

would you like to share code via blog/document ?

Read only

0 Likes
1,778

......   

sender_address = 'WF-BATCH'.

    put_in_outbox = 'X'.

    wfl_commit_work = 'X'.

    clear wsender_address_type.

    CALL FUNCTION 'SO_DOCUMENT_SEND_API1' in background task "parte dopo il commit work

         EXPORTING

              document_data              = document_data

              put_in_outbox              = put_in_outbox

              sender_address             = sender_address

              sender_address_type        = wsender_address_type

              commit_work                = wfl_commit_work

*         IMPORTING

*              sent_to_all                = sent_to_all

*              new_object_id              = new_object_id

*              sender_id                  = sender_id

         TABLES

              packing_list               = packing_list

              OBJECT_HEADER              = OBJECT_HEADER

              CONTENTS_BIN               = CONTENTS_BIN

              contents_txt               = contents_txt

              OBJECT_PARA                = OBJECT_PARA

              OBJECT_PARB                = OBJECT_PARB

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

    commit work.

....