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

run in background

former_member445510
Active Participant
0 Likes
7,069

Hello,

This program works good in Foreground, can some one help me to execute it in Background?

I tried via sm37 - sm36 (job wizar) - right button execute in Background, but it doesn't succeed.

It's work perfect in Foreground...

<irrelevant code is removed>


Message was edited by: Suhas Saha

Thank u,

How can i correct that ?

54 REPLIES 54
Read only

0 Likes
5,906

Hi

You need to send a mail to your address

Max

Read only

0 Likes
5,906

Hi ouail roukbi,

lets discuss this in our post "

send email in background to outlook"

Read only

0 Likes
5,906

yes, i need to send itab data to my email address in outlook in background.

i need a abap code not configuration in SCOT or SOST....

Do you know?

Read only

0 Likes
5,906

Hi

Yes I know but as I said before

To send a mail via ABAP is easy, one sample is in link posted by Stefan, but there are many samples in SCN:

Have you tried to look for it?

Max

Read only

0 Likes
5,906

i tried already this code in Fore and background,

constants:
     gc_subject type so_obj_des value 'ABAP Email with CL_BCS',
     gc_raw     type char03 value 'RAW'.

   data:
     gv_mlrec         type so_obj_nam,
     gv_sent_to_all   type os_boolean,
     gv_email         type adr6-smtp_addr,
     gv_subject       type so_obj_des,
     gv_text          type bcsy_text,
     gr_send_request  type ref to cl_bcs,
     gr_bcs_exception type ref to cx_bcs,
     gr_recipient     type ref to if_recipient_bcs,
     gr_sender        type ref to cl_sapuser_bcs,
     gr_document      type ref to cl_document_bcs.



   try.
       "Create send request
       gr_send_request = cl_bcs=>create_persistent( ).


       "Email FROM...
       gr_sender = cl_sapuser_bcs=>create( sy-uname ).
       "Add sender to send request
       call method gr_send_request->set_sender
         exporting
           i_sender = gr_sender.


       "Email TO...
       gv_email = '[email protected]'.
       gr_recipient = cl_cam_address_bcs=>create_internet_address( gv_email ).
       "Add recipient to send request
       call method gr_send_request->add_recipient
         exporting
           i_recipient = gr_recipient
           i_express   = 'X'.


       "Email BODY
       append 'Hello world! My first ABAP email!' to gv_text.
       gr_document = cl_document_bcs=>create_document(
                       i_type    = gc_raw
                       i_text    = gv_text
                       i_length  = '12'
                       i_subject = gc_subject ).
       "Add document to send request
       call method gr_send_request->set_document( gr_document ).


       "Send email
       call method gr_send_request->send(
         exporting
           i_with_error_screen = 'X'
         receiving
           result              = gv_sent_to_all ).
       if gv_sent_to_all = 'X'.
         write 'Email sent!'.
       endif.

       "Commit to send email
       commit work.


       "Exception handling
     catch cx_bcs into gr_bcs_exception.
       write:
         'Error!',
         'Error type:',
         gr_bcs_exception->error_type.
   endtry.


i receive no mail, when i check in SOST, i find "Message cannot be transferred to node SMTP due to connection error (final)"

Read only

0 Likes
5,906

this shows that somehow your scot configuration is wrong since mail got created correctly.

unfortunately i cant help you with scot configuration

regards

Stefan Seeburger

Read only

0 Likes
5,906

Hi

Try to check the setting by SCOT transaction

Read only

0 Likes
5,906

i did all of those step my SCOT,

Scot Configuration &amp;amp; Troubleshooting

but still have the error connection !!

Read only

0 Likes
5,906

Probably you should ask an help to your basis, I suppose there's a reason if SCOT is not set in your system

Max

Read only

0 Likes
5,906

i'm the only one used SAP 🙂

Read only

0 Likes
5,906

Are you one man band?

Max

Read only

0 Likes
5,906

We are a small company, and i'm the only one for sap.

Read only

0 Likes
5,906

Wow

I've never set SCOT but if you've changed the system parameter as shown in the first step of the link you've posted I believe you need to restart the system

Max

Read only

0 Likes
5,906

ok Max,

i don't want to send email :-), there is any way in background to use it to send me information via pop up or message or any thing that help me to say "aah there is some thing wrong, i get signal ".... ?

Read only

0 Likes
5,905

Hi

try this code:


data objcont  type standard table of soli      with header line.

data receiver type standard table of somlreci1 with header line.

data doc_data type sodocchgi1.

* insert receiver (sap name)

refresh receiver.

clear receiver.

move: sy-uname to receiver-receiver,

       'X'      to receiver-express,

       'B'      to receiver-rec_type.

append receiver.

* insert mail description

write 'My express message' to doc_data-obj_descr.

objcont-line = 'Hello! This is my message sent by program &'.

replace '&' with sy-repid into objcont-line.

append objcont.

call function 'SO_NEW_DOCUMENT_SEND_API1'

   exporting

     document_data              = doc_data

   tables

     object_content             = objcont

     receivers                  = receiver

   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.

You'll receive a popup message as soon as you log on or do something (if you're log in)

Max