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

Not able to send mail using FM SO_NEW_DOCUMENT_SEND_API1

Former Member
0 Likes
1,122

hello friends,

The mail needs to be sent to an internet user ,this is the code i am using.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = lx_docu_data

document_type = 'RAW'

commit_work = lc_checked

TABLES

object_content = li_docu_content

receivers = li_receiver

Am able to send mail directly from SE37 to Transaction SCOT and here i need to start the send process and mail is sent sucessfully. But from the code its not working.

li_receiver -> lw_receiver-receiver = user[at]domain.com

lw_receiver-rec_type = 'U'.

hello friends,

The mail needs to be sent to an internet user ,this is the code i am using.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = lx_docu_data

document_type = 'RAW'

commit_work = lc_checked

TABLES

object_content = li_docu_content

receivers = li_receiver

Am able to send mail directly from SE37 to Transaction SCOT and here i need to start the send process and mail is sent sucessfully. But from the code its not working.

li_receiver -> lw_receiver-receiver = user[at]domain.com

lw_receiver-rec_type = 'U'.

6 REPLIES 6
Read only

Former Member
0 Likes
931

below u have 2 option for doing this..

1.bdc program of scot

2.submit standard report

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = doc_chng

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = objpack

contents_txt = objtxt[]

contents_bin = so_ali[]

*contents_hex = so_ali[]

receivers = reclist[]

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.

PERFORM mail.---1 option

MESSAGE 'Mail sent successfully' TYPE 'S'.

or

SUBMIT RSCONN01 WITH MODE = INT.----or 2option

ENDIF.

FORM mail .

PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=PDIA'.

PERFORM bdc_dynpro USING 'SAPLSX10' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

'SXJOBDATA-ADDR_TYPE'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ADRTP'.

PERFORM bdc_field USING 'SXJOBDATA-ADDR_TYPE'

'INT'.

PERFORM bdc_field USING 'SXJOBDATA-MAXJOBS'

'1'.

PERFORM bdc_dynpro USING 'SAPLSX10' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

'SXJOBDATA-ADDR_TYPE'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=OK12'.

PERFORM bdc_field USING 'SXJOBDATA-ADDR_TYPE'

'INT'.

PERFORM bdc_field USING 'SXJOBDATA-MAXJOBS'

'1'.

PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

'02/03'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BACK'.

CALL TRANSACTION 'SCOT' USING bdcdata

MODE 'N'

UPDATE 'S'.

ENDFORM.

Read only

Former Member
0 Likes
931

You need to use COMMIT WORK.


  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data              = wa_docdata
      put_in_outbox              = c_x
      commit_work                = c_x
    TABLES
      packing_list               = t_objpack
      object_header              = t_objhead
      contents_bin               = t_objbin
      contents_txt               = t_objtxt
      receivers                  = t_reclist
    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 EQ 0.                                  
    COMMIT WORK AND WAIT.

  ENDIF.

Read only

Former Member
0 Likes
931

you can put your mailid SCOT code and try it.

in my case aslo , not working in 100 and itworking in 210

Read only

Former Member
0 Likes
931

HI,

Refer to this link...

https://www.sdn.sap.com/irj/scn/forums.

MOVE: l_email TO l_reclist-receiver,

'U' TO l_reclist-rec_type.

APPEND l_reclist TO li_reclist.

DESCRIBE TABLE li_objtxt LINES l_lines.

READ TABLE li_objtxt INTO l_objtxt INDEX l_lines.

l_docdata-doc_size = ( l_lines - 1 ) * 255 + STRLEN( l_objtxt ).

CLEAR l_objpack-transf_bin.

l_objpack-head_start = 1.

l_objpack-head_num = 0.

l_objpack-body_start = 1.

l_objpack-body_num = l_lines.

l_objpack-doc_type = 'RAW'.

APPEND l_objpack TO li_objpack.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = l_docdata

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = li_objpack

contents_txt = li_objtxt

receivers = li_reclist

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 EQ 0.

SUBMIT rsconn01

WITH mode = 'INT'

WITH output = ''

AND RETURN.

ELSE.

l_errflag = 'X'.

ENDIF.

ENDIF.

Read only

0 Likes
931

I have tried the above solutions but none of them seems to be working , the sy-subrc is 0 but mail is not sent not even to SCOT transaction.

Read only

0 Likes
931

The same code is working for reports and mail is sent but it is not working for BADI.

Can any one help me?