Skip to Content
0
Former Member
Feb 14, 2007 at 02:47 PM

try to send mail , not working , why ?

33 Views

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