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: 

Email program

vallamuthu_madheswaran2
Active Contributor
0 Kudos

hi,

i am copying one Email program in SAP documentation in se37. if i execute the program, it's execute fine the mail is not send the particular mailid but i used SBWP in the same mail id it'll send, the program is given below.

thanks & regards.

DATA: OBJCONT LIKE SOLISTI1 OCCURS 5 WITH HEADER LINE.

DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

DATA: DOC_CHNG LIKE SODOCCHGI1.

DATA: ENTRIES LIKE SY-TABIX.

DATA: NAME(15).

  • Fill the document

DOC_CHNG-OBJ_NAME = 'URGENT'.

DOC_CHNG-OBJ_DESCR = 'Read at once !'.

DOC_CHNG-SENSITIVTY = 'P'.

OBJCONT = 'Hey guys, time for lunch !!!'.

APPEND OBJCONT.

OBJCONT = 'Lets get going !'.

APPEND OBJCONT.

DESCRIBE TABLE OBJCONT LINES ENTRIES.

READ TABLE OBJCONT INDEX ENTRIES.

DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ).

  • Fill the receiver list

CLEAR RECLIST.

RECLIST-RECEIVER = 'SAPUSER'. " replace with <login name>

RECLIST-REC_TYPE = 'B'.

RECLIST-EXPRESS = 'X'.

APPEND RECLIST.

CLEAR RECLIST.

RECLIST-RECEIVER = 'vallamuthu.madheswaran@unisoftinfotech.com'.

RECLIST-REC_TYPE = 'U'.

APPEND RECLIST.

  • Send the document

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_TYPE = 'RAW'

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

TABLES

OBJECT_CONTENT = OBJCONT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

CASE SY-SUBRC.

WHEN 0.

LOOP AT RECLIST.

IF RECLIST-RECEIVER = SPACE.

NAME = RECLIST-REC_ID.

ELSE.

NAME = RECLIST-RECEIVER.

ENDIF.

IF RECLIST-RETRN_CODE = 0.

WRITE: / NAME, ': succesfully sent'.

ELSE.

WRITE: / NAME, ': error occured'.

ENDIF.

ENDLOOP.

WHEN 1.

WRITE: / 'Too many receivers specified !'.

WHEN 2.

WRITE: / 'No receiver got the document !'.

WHEN 4.

WRITE: / 'Missing send authority !'.

WHEN OTHERS.

WRITE: / 'Unexpected error occurred !'.

ENDCASE.

4 REPLIES 4

naimesh_patel
Active Contributor
0 Kudos

Hello,

For internet mail you need to make settings in the transaction SCOT.

For the message in the SAP Office, you can do like this:

<b>RECLIST-RECEIVER = sy-uname</b>. " replace with <login name>

RECLIST-REC_TYPE = 'B'.

RECLIST-EXPRESS = 'X'.

APPEND RECLIST.

Regards,

Naimesh

0 Kudos

i alreay gave SY-UNAME

former_member184619
Active Contributor
0 Kudos

Hi,

The problem might me 1 of these as under:-

1. In the exporting parameters of..FM use

commit_work = 'X'.

The mails are not sent automatically by this FM...They are gone to tcode SOST from where u can send them manually. menu path :- Utilities->Start send process.

the solution to above is

2. Check for Sy-subrc of FM..

if sy-subrc = 0.

SUBMIT rsconn01

WITH mode EQ 'INT'

AND RETURN.

      • this report program is used to automatically send the e-mails that are pending in the job queue in SCOT or SOST.

Check the following link:-

/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface

http://help.sap.com/saphelp_nw04/helpdata/en/2b/d925bf4b8a11d1894c0000e8323c4f/frameset.htm

these link will help u to config SCOT.

3. U may have some SMTP Config. problem.

If so u can ask me for details.

eward if helpful.

Regards

-


Sachin Dhingra

Former Member
0 Kudos

There is a parameter for COMMIT_WORK in the FM ...please set that to X and it should work fine.

Regards

Anurag