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

FM SO_DOCUMENT_SEND_API1 in background task

former_member227595
Active Participant
0 Likes
1,117

Hi

I'm using the FM SO_DOCUMENT_SEND_API1 in backgroud task and is not working fine, It is not sending email in background task but it does in online mode. Does anybody know which could be the problem or is this a way to call this FM in background mode.

Thanks !

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
791

Hi ,

Ask your basis person

so enable scot settings for your batch user

as ur back ground user will be sending mail

ask him to check the mail settings for background user

and u also go to su01d and give the background user and check his email id is there or not

cheers

S.Janagar

4 REPLIES 4
Read only

vinod_vemuru2
Active Contributor
0 Likes
791

Hi,

Can you post your code? Just by removing the background task addition is it working fine?

You can try with FM SO_NEW_DOCUMENT_SEND_API1 which more frequently used.

Thanks,

Vinod.

Read only

0 Likes
791

Hi Vinod Vemuru, yes my code is this

FORM send_email TABLES it_message

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

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,

li_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,

w_cnt TYPE i,

w_sent_all(1) TYPE c,

w_doc_data LIKE sodocchgi1.

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.

CLEAR w_doc_data.

w_doc_data-doc_size = 1.

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'.

DESCRIBE TABLE it_message LINES w_cnt.

READ TABLE it_message INDEX w_cnt.

w_doc_data-doc_size = ( w_cnt - 1 ) * 255 + STRLEN( it_message ).

  • w_doc_data-proc_name = 'Pdf'.

  • w_doc_data-PROC_SYST =

  • w_doc_data-proc_clint = sy-mandt.

  • w_doc_data-to_do_out = 'X'.

  • 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_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.

t_packing_list-body_num = w_cnt.

t_packing_list-doc_type = 'RAW'.

APPEND t_packing_list.

CLEAR t_attachment.

REFRESH t_attachment.

t_attachment[] = it_attach[].

DESCRIBE TABLE t_attachment LINES w_cnt.

t_packing_list-transf_bin = 'X'.

t_packing_list-head_start = 1.

t_packing_list-head_num = 1.

t_packing_list-body_start = 1.

t_packing_list-body_num = w_cnt.

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.

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.

li_object_header = 'File .pdf'.

APPEND li_object_header.

  • DATA parch2(60) TYPE c VALUE '/tmp/diego_end.txt'.

*

  • OPEN DATASET parch2 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

*

  • IF sy-subrc EQ 0.

*

*

  • TRANSFER sy-uzeit TO parch2.

  • spool_idc = spool_id.

  • TRANSFER spool_idc TO parch2.

  • TRANSFER w_sent_all TO parch2.

  • TRANSFER sub TO parch2.

  • CLOSE DATASET parch2.

*

*

  • ENDIF .

  • WAIT UP TO 1 SECONDS.

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

object_header = li_object_header

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.

  • COMMIT WORK AND WAIT .

sub = sy-subrc .

ld_error = sy-subrc.

CALL FUNCTION 'SO_DEQUEUE_UPDATE_LOCKS'.

  • LOOP AT t_receivers.

  • ld_receiver = t_receivers-retrn_code.

  • ENDLOOP.

  • parch2 = '/tmp/diego_end2.txt'.

  • OPEN DATASET parch2 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .

"OUTPUT

*

  • IF sy-subrc EQ 0.

*

*

  • TRANSFER sy-uzeit TO parch2.

  • spool_idc = spool_id.

  • TRANSFER spool_idc TO parch2.

  • TRANSFER w_sent_all TO parch2.

  • TRANSFER sub TO parch2.

  • CLOSE DATASET parch2.

*

*

  • ENDIF .

ENDFORM. " SEND_EMAIL

Read only

Abhijit74
Active Contributor
0 Likes
791

Hi,

1. if you are executing it in the background generally it will not l be in your outbox, So here the sender will be WF-BATCH. please checking in WF-BATCH user's outbox.2.Are you using the doctype RAW a linebreak is automatically inserted after each line (or 255 character) ?

3. If you want to add lines which are longer than 255 characters you must use a doctype other than RAW. If you use TXT no line breaks are inserted after 255 characters. For TXT documents you are responsible for the line breaks.

4. Generally when you will execute the program in background it will create a spool. Please check whether spool is generated correctly or not means without truncating the columns.

5. Have you provide the Sender Name & Sender Address? If not please check.

Thanks,

Abhijit

Read only

Former Member
0 Likes
792

Hi ,

Ask your basis person

so enable scot settings for your batch user

as ur back ground user will be sending mail

ask him to check the mail settings for background user

and u also go to su01d and give the background user and check his email id is there or not

cheers

S.Janagar