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: 

try to send mail , not working , why ?

Former Member
0 Kudos

hello ,

i try to use function SO_NEW_DOCUMENT_ATT_SEND_API1.

in my program it is not working so i found note ( 609696 ) with examle

also not working , i check in "scot" nothing show up .

what can be the reason ?

sap example

&----


*& Report ZSSO_DOCUMENT_SEND_API1

*&

&----


*& Send document with OTF/ALI attachment from spool to external reci-

*& pient. OTF/ALI document is converted to PDF/HTML format during the

*& SAPconnect send process.

*&

*& This report serves as example documentation for the function

*& modules SO_NEW_DOCUMENT_ATT_SEND_API1 and SO_DOCUMENT_SEND_API1.

*& Following this example you should be able to develop your own

*& report to send documents with all kinds of attachments.

*&

&----


REPORT ZSSO_DOCUMENT_SEND_API1.

  • Data Declaration

Data: docdata like sodocchgi1,

objpack like sopcklsti1 occurs 1 with header line,

objhead like solisti1 occurs 1 with header line,

objtxt like solisti1 occurs 10 with header line,

objbin like solisti1 occurs 10 with header line,

reclist like somlreci1 occurs 1 with header line.

Data: listobject like abaplist occurs 1 with header line.

Data: tab_lines type i,

doc_size type i,

att_type like SOODK-OBJTP.

  • NOTE: Create ALI/OTF Document in Spool

  • ALI Document can be created by displaying a list and selecting

  • menue System -> List -> Print (only put to Spool).

  • OTF Document can be created running report SF_EXAMPLE_01 in system.

*

  • Example used here:

  • create list in memory

submit SHOWCOLO exporting list to memory and return.

  • and read list from memory into table

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = listobject

EXCEPTIONS

OTHERS = 1

.

IF sy-subrc <> 0.

message ID '61' TYPE 'E' NUMBER '731'

with 'LIST_FROM_MEMORY'.

ENDIF.

  • Because listobject is of size RAW(1000)

  • and objbin is of size CHAR(255) we make this table copy

CALL FUNCTION 'TABLE_COMPRESS'

  • IMPORTING

  • COMPRESSED_SIZE =

TABLES

IN = listobject

OUT = objbin

EXCEPTIONS

OTHERS = 1

.

if sy-subrc <> 0.

message ID '61' TYPE 'E' NUMBER '731'

with 'TABLE_COMPRESS'.

endif.

  • NOTE: Creation of attachment is finished yet.

  • For your report, the attachment should be placed into table

  • objtxt for plain text or

  • objbin for binary content.

  • Now create the message and send the document.

  • Create Message Body

  • Title and Description

docdata-obj_name = 'TEST_ALI'.

docdata-obj_descr = 'Test including ALI/HTML Attachment'.

  • Main Text

objtxt = 'Test Document.'.

append objtxt.

objtxt = 'You will find an ALI/HTML attachment in this message.'.

append objtxt.

objtxt = 'Have a nice day.'.

append objtxt.

  • Write Packing List (Main)

describe table objtxt lines tab_lines.

read table objtxt index tab_lines.

docdata-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ).

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.

  • Create Message Attachment

  • Write Packing List (Attachment)

att_type = 'ALI'.

describe table objbin lines tab_lines.

read table objbin index tab_lines.

objpack-doc_size = ( tab_lines - 1 ) * 255 + strlen( objbin ).

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = att_type.

objpack-obj_name = 'ATTACHMENT'.

objpack-obj_descr = 'Attached Document'.

append objpack.

  • Create receiver list

reclist-receiver = 'testuser@COMPANY.COM'. "<-- change address

reclist-rec_type = 'U'.

append reclist.

reclist-receiver = sy-uname. "<-- change internal user

reclist-rec_type = 'B'.

append reclist.

  • Send Message

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = docdata

PUT_IN_OUTBOX = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

tables

packing_list = objpack

OBJECT_HEADER = objhead

CONTENTS_BIN = objbin

CONTENTS_TXT = objtxt

  • OBJECT_PARA =

  • OBJECT_PARB =

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.

message ID 'SO' TYPE 'S' NUMBER '023'

with docdata-obj_name.

ENDIF.

write: / 'End of Program'.

1 ACCEPTED SOLUTION

amit_khare
Active Contributor
0 Kudos

Hi,

your program has problem in creating the reciever list.

check the Amit's Code in this thread. It is perfect.you can update accordingly.

Regards,

Amit

Reward all helpful replies.

5 REPLIES 5

Former Member
0 Kudos

Hi,

Look at the below blog, this is well explained with scrren shots and an example

/people/thomas.jung3/blog/2004/09/07/sending-e-mail-from-abap--version-46d-and-lower--api-interface

Regards

Sudheer

former_member184619
Active Contributor
0 Kudos

check this link

Regards

Sachin

amit_khare
Active Contributor
0 Kudos

Hi,

your program has problem in creating the reciever list.

check the Amit's Code in this thread. It is perfect.you can update accordingly.

Regards,

Amit

Reward all helpful replies.

0 Kudos

your program working fine , but what is the difrance ?

four lines , "u" and "mail adress" , what is the problem ?

reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.

CLEAR reclist.

reclist-receiver = preceiver. = my mail

reclist-rec_type = prec_type. = 'u'

APPEND reclist.

i can't understand what to change ?

0 Kudos

ok found it

put_in_outbox = 'X'

commit_work = 'X'

working .

thanks thanks thanks .