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: 

mail issue

Former Member
0 Kudos

Guy's

i suppose these question has been asked lot of time

in this forum, i am able to send mail using FM

SO_NEW_DOCUMENT_SEND_API1 ,BUT NOT USING SO_OBJECT_SEND,

we are currently working on creating a print program

which is copy of standard program,hence modifiying

code for FM SO_NEW_DOCUMENT_SEND_API1 is tiring ,pls

send me a working simple report that is sending mail using

FM SO_OBJECT_SEND

8 REPLIES 8

Former Member
0 Kudos

check this link :

http://www.sapgenie.com/abap/code/abap15.htm

this too

http://www.sapgenie.com/abap/code/abap25.htm

regards

srikanth

Message was edited by: Srikanth Kidambi

Former Member
0 Kudos

Hai Sanju

Try with the following Link

http://www.sapgenie.com/abap/code/abap15.htm

Try with the following Code

DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.

DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.

DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

DATA: DOC_CHNG LIKE SODOCCHGI1.

DATA: TAB_LINES LIKE SY-TABIX.

DATA L_NUM(3).

  • Creation of the document to be sent

  • File Name

DOC_CHNG-OBJ_NAME = 'SENDFILE'.

  • Mail Subject

DOC_CHNG-OBJ_DESCR = 'Delivered Mail'.

  • Mail Contents

OBJTXT = 'Object text'.

APPEND OBJTXT.

DESCRIBE TABLE OBJTXT LINES TAB_LINES.

READ TABLE OBJTXT INDEX TAB_LINES.

DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).

  • Creation of the entry for the compressed document

CLEAR OBJPACK-TRANSF_BIN.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 0.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'RAW'.

APPEND OBJPACK.

  • Creation of the document attachment

LOOP AT ITAB_DATA.

CONCATENATE ITAB_DATA-PRODUCTOR

ITAB_DATA-VBELN

ITAB_DATA-POSNR

ITAB_DATA-MATNR INTO OBJBIN.

APPEND OBJBIN.

ENDLOOP.

DESCRIBE TABLE OBJBIN LINES TAB_LINES.

OBJHEAD = 'ORDERS'.

APPEND OBJHEAD.

    • Creation of the entry for the compressed attachment

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 1.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'TXT'.

OBJPACK-OBJ_NAME = 'WEBSITE'.

OBJPACK-OBJ_DESCR = 'ORDERS.TXT'.

OBJPACK-DOC_SIZE = TAB_LINES * 255.

APPEND OBJPACK.

  • Completing the recipient list

  • target recipent

clear RECLIST.

RECLIST-RECEIVER = 'test@here.com'.

RECLIST-EXPRESS = 'X'.

RECLIST-REC_TYPE = 'U'.

APPEND RECLIST.

  • copy recipents

clear RECLIST.

RECLIST-RECEIVER = 'secondtest@here.com'.

RECLIST-EXPRESS = 'X'.

RECLIST-REC_TYPE = 'U'.

RECLIST-COPY = 'X'.

APPEND RECLIST.

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

TABLES

PACKING_LIST = OBJPACK

OBJECT_HEADER = OBJHEAD

CONTENTS_BIN = OBJBIN

CONTENTS_TXT = OBJTXT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

Thanks & Regards

Sreenivasulu P

0 Kudos

HI Sreenivas

i suppose u have gone through my mail

Thanks

sanju joseph

Former Member
0 Kudos

Hi sanju,

<b>The code is as under</b>

REPORT ZTSAPMAIL.

DATA: X_OBJECT_TYPE LIKE SOOD-OBJTP.

DATA: BEGIN OF X_OBJECT_HD_CHANGE.

INCLUDE STRUCTURE SOOD1.

DATA: END OF X_OBJECT_HD_CHANGE.

DATA: BEGIN OF X_OBJCONT OCCURS 10.

INCLUDE STRUCTURE SOLI.

DATA: END OF X_OBJCONT.

DATA: BEGIN OF X_OBJHEAD OCCURS 0.

INCLUDE STRUCTURE SOLI.

DATA: END OF X_OBJHEAD.

DATA: BEGIN OF RAW_HEAD.

INCLUDE STRUCTURE SORH.

DATA: END OF RAW_HEAD.

DATA: BEGIN OF X_RECEIVERS OCCURS 0.

INCLUDE STRUCTURE SOOS1.

DATA: END OF X_RECEIVERS.

PARAMETERS: RECEIVER LIKE X_RECEIVERS-RECNAM. " Name

*BUILD MESSAGE HEADER

MOVE 'Sort field goes here' TO X_OBJECT_HD_CHANGE-OBJSRT. " Sort field

MOVE 'Name of the object goes here' TO X_OBJECT_HD_CHANGE-OBJNAM. " Name

MOVE 'Document title goes here' TO X_OBJECT_HD_CHANGE-OBJDES. " Title

MOVE 'F' TO X_OBJECT_HD_CHANGE-OBJSNS. " Functional OBJECT

MOVE 'E' TO X_OBJECT_HD_CHANGE-OBJLA. " Language

  • Object type of the new document

MOVE 'RAW' TO X_OBJECT_TYPE.

CLEAR X_OBJCONT.

MOVE 'Contents of mail' TO X_OBJCONT-LINE.

APPEND X_OBJCONT.

CLEAR X_OBJCONT-LINE. APPEND X_OBJCONT.

MOVE 'More contents' TO X_OBJCONT-LINE.

APPEND X_OBJCONT.

MOVE 'Still more contents'

to x_objcont-line.

APPEND X_OBJCONT.

MOVE ' ' TO X_OBJCONT-LINE.

APPEND X_OBJCONT.

  • Specific header (Dependent on the object type, here RAW)

REFRESH X_OBJHEAD.

DESCRIBE TABLE X_OBJCONT LINES RAW_HEAD-RAWSIZ.

MOVE RAW_HEAD TO X_OBJHEAD.

APPEND X_OBJHEAD.

*RECEIVERS table

CLEAR X_RECEIVERS.

REFRESH X_RECEIVERS.

MOVE RECEIVER TO X_RECEIVERS-RECNAM. " Name

MOVE 'B' TO X_RECEIVERS-RECESC. " Receiver type

MOVE 'X' TO X_RECEIVERS-SNDCP. " Send as a copy

MOVE 'X' TO X_RECEIVERS-SNDEX. " EXPRESS DOCUMENT

APPEND X_RECEIVERS.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

  • folder_id = 'OUTBOX'

  • forwarder = x_forwarder

  • object_fl_change = x_object_fl_change

OBJECT_HD_CHANGE = X_OBJECT_HD_CHANGE

  • object_id = x_object_id

OBJECT_TYPE = X_OBJECT_TYPE

OUTBOX_FLAG = 'X'

OWNER = SY-UNAME

  • store_flag = x_store_flag

  • importing

  • object_id_new = x_object_id_new

  • sent_to_all = x_sent_to_all "May need to use

TABLES

OBJCONT = X_OBJCONT

OBJHEAD = X_OBJHEAD

  • objpara = x_objpara

  • objparb = x_objparb

RECEIVERS = X_RECEIVERS.

Check the following link for complete details of the function module SO_OBJECT_SEND

<b>http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp</b>

I suppose your problem should be solved by this.

Thanks & Regards,

Pawan P. Khilari

<b>*Mark useful answers and close the query if ur problem is solved.</b>

0 Kudos

Hi Pawan

code is working fine,but i am not able to send mail

to exetenal id ,for example sanjujoseph@gmail.com

,i am reveing mail in sbwp tcode but not getting

reflected in sost tcode

0 Kudos

Hello,

I would suggest not to use the FM: 'SO_OBJECT_SEND'. SAP will not support this for you. All the supported methods of sending mail is described (with example) in SAP note:

#190669

Regards,

Dezso

0 Kudos

Hai Sanju

Try with the following Code

REPORT Z_SENDITAB_EMAIL_SREE_13424 .

tables : mara.

DATA IT_MAIL(200) TYPE C OCCURS 0 WITH HEADER LINE.

  • message body:

IT_MAIL = '1st line.'. APPEND IT_MAIL.

IT_MAIL = '2nd line.'. APPEND IT_MAIL.

IT_MAIL = '3rd line.'. APPEND IT_MAIL.

IT_MAIL = '4th line.'. APPEND IT_MAIL.

  • to view the following function (cannot be viewed in se37):

  • go to sm59, select 'TCP/IP connections',

  • select and open 'SERVER_EXEC' or 'LOCAL_EXEC',

  • look on the pull down menu SYSTEM INFORMATION->FUNCTION LIST

data : begin of itab occurs 0,

matnr like mara-matnr,

mtart like mara-mtart,

mbrsh like mara-mbrsh,

meins like mara-meins,

end of itab.

select

matnr

mtart

mbrsh

meins

from mara

into table itab.

if sy-subrc = 0.

CALL FUNCTION 'RFC_MAIL' DESTINATION 'LOCAL_EXEC'

EXPORTING USER = 'sanjujoseph@gmail.com'

  • TABLES MAIL = IT_MAIL.

TABLES MAIL = ITAB.

endif.

CASE SY-SUBRC.

WHEN 0. WRITE 'E-mail sent successfully.'.

WHEN OTHERS. WRITE 'Error sending E-mail!'.

ENDCASE.

************************************************************************

Thanks & regards

Sreenivasulu P