send mail with attached objects
Daniel Fernández
wfdfl1975 at yahoo.es
Tue Feb 26 03:45:03 EST 2002
Hi Govind,Raskin, Hi all,
I have investigated the API functions for to send mail
with attached objects (like a invoice or a purchase
order) and I have a problem.
I I try to add a sap office mail in the private
folder, all works Ok, but if I try to add it in the
inbox folder an error of authoritation is showed.
I4m the SAP_ALL and SAP_NEW in development system
The code (it works for de private folder) is:
data: S_MESSAGE type SODOCCHGI1,
S_LIST_OBJ type SOLISTI1 occurs 0,
S_USER_DATS type SOUDATAI1,
S_USER type SOUDNAMEI1,
S_DOCUMENT type SOFOLENTI1,
S_TASK_DESCR TYPE TLINE OCCURS 0,
S_TASK_DESCR_C TYPE SOLISTI1 OCCURS 0,
S_OBJECT type soxobj,
S_DESCR_ATTACH type SOATTCHGI1 occurs 0 with
header line.
* SAP folders of user that receive the mail.
S_USER-SAPNAME = 'DFERNANDEZ'. "(User)
CALL FUNCTION 'SO_USER_READ_API1'
EXPORTING
USER = S_USER
IMPORTING
USER_DATA = S_USER_DATS
EXCEPTIONS
USER_NOT_EXIST = 1
PARAMETER_ERROR = 2
X_ERROR = 3
OTHERS = 4.
* Obtain Task description
CALL FUNCTION 'SWU_GET_TASK_TEXTLINES'
EXPORTING
TASK = 'TS99900015' "(Your
task)
* WI_ID =
* WIHEADER =
USAGE = 'W'
LINEWIDTH = 75
LANGUAGE = SY-LANGU
TABLES
ASCII_TEXT_LINES = S_TASK_DESCR
* CONTAINER =
* HTML_TEXT_LINES =
EXCEPTIONS
WRONG_USAGE = 1
TEXT_NOT_FOUND = 2
TEXT_SYSTEM_ERROR = 3
OTHERS = 4.
* obtain the subject message
S_MESSAGE-OBJ_DESCR = 'message Subject'.
* We will create the 'text' message with the task
description and the
* subject
* If The field S_USER_DATS-INBOXFOL is changed for
* S_USER_DATS-PRIVATFOL the message is correctly
sended to the user
S_TASK_DESCR_C[] = S_TASK_DESCR[].
CALL FUNCTION 'SO_DOCUMENT_INSERT_API1'
EXPORTING
FOLDER_ID =
S_USER_DATS-INBOXFOL
DOCUMENT_DATA = S_MESSAGE
DOCUMENT_TYPE = 'RAW'
IMPORTING
DOCUMENT_INFO = S_DOCUMENT
TABLES
OBJECT_HEADER = S_TASK_DESCR_C
OBJECT_CONTENT = S_TASK_DESCR_C
EXCEPTIONS
FOLDER_NOT_EXIST = 1
DOCUMENT_TYPE_NOT_EXIST = 2
OPERATION_NO_AUTHORIZATION = 3
PARAMETER_ERROR = 4
X_ERROR = 5
ENQUEUE_ERROR = 6
OTHERS = 7.
* object dats
S_OBJECT-LOGSYS = 'SAPI'. "(your logic system)
S_OBJECT-OBJTYPE = 'BKPF'.
S_OBJECT-OBJKEY = 'ES0100190000012002'. "(Object key)
S_OBJECT-DESCRIBE = 'Description'.
S_OBJECT-METHOD = 'DISPLAY'.
append S_OBJECT to S_LIST_OBJ.
* We write de object description
S_DESCR_ATTACH-OBJ_DESCR = 'Factura'.
* Add the object to the mail.
CALL FUNCTION 'SO_ATTACHMENT_INSERT_API1'
EXPORTING
DOCUMENT_ID =
S_DOCUMENT-DOC_ID
ATTACHMENT_DATA = S_DESCR_ATTACH
ATTACHMENT_TYPE = 'OBJ'
* IMPORTING
* ATTACHMENT_INFO =
TABLES
ATTACHMENT_HEADER = S_LIST_OBJ
ATTACHMENT_CONTENT = S_LIST_OBJ
* CONTENTS_HEX =
EXCEPTIONS
DOCUMENT_NOT_EXIST = 1
ATTACHMENT_TYPE_NOT_EXIST = 2
OPERATION_NO_AUTHORIZATION = 3
PARAMETER_ERROR = 4
X_ERROR = 5
ENQUEUE_ERROR = 6
OTHERS = 7.
Regards,
Daniel.
--- "Raskin, Alon (Soliance)" <ARaskin at cps-satx.com>
escribis: > Hi Daviel,
>
> Here is an old email that Jocelyn Dart (thanks
> Jocelyn!) sent me a while
> back regarding this issue.
>
> Regards,
>
> Alon Raskin
>
>
> Hi Alon,
> There are a series of API function modules for
> SAPOffice that you can
> use to do this. e.g. SO_DOCUMENT_INSERT_API.
>
> You need as a minimum a folder, the document type
> and the document data.
>
> For an object the document type is OBJ.
>
> Fill the document_data parameter, field description
> with the title of the
> document.
>
> Fill the object_header table, add a row with object
> type and object key
> using structure SOXOBJ. (You can specify a method
> - if you don't it will
> use the default method, usually "display").
>
> You need to put the document in a folder, if you use
> fm SO_USER_READ_API1
> with user-sapname = their R/3 userid, it will return
> the folders (inbox,
> outbox, private) for that user in the correct
> format. I'd suggest putting
> it in their private folder.
>
> To use it in workflow you'll need to include it in a
> method
> - I'd suggest creating a subtype of SOFM and
> delegating it.
>
> Then you can return the resulting document id as a
> SOFM object, and pass it
> to
> your sendtaskdescription step.
>
> Regards,
> Jocelyn Dart
> Consultant (EBP, BBP, Ecommerce, Internet
> Transaction Server, Workflow)
> SAP Australia
> Email jocelyn.dart at sap.com
> <mailto:jocelyn.dart at sap.com>
> Tel: +61 412 390 267
> Fax: +61 2 9935 4880
>
>
>
>
> -----Original Message-----
>> From: Raskin, Alon (Soliance)
> [mailto:ARaskin at cps-satx.com]
> Sent: Thursday, 20 December 2001 4:45 AM
> To: SAP-WUG at MITVMA.MIT.EDU
> Subject: SELFITEM.SENDTASKDESCRIPTION
>
>
> Hi Everyone,
>
> I am trying to attach a business object to a mail
> which I am generating from
> a workflow. I am binding the object to the
> ADHOC_OBJECTS but when the mail
> is received no attachment is found. I tried binding
> the business object to
> the ATTACHMENTS element but ATTACHMENTS must be of
> type SOFM. I tried
> somehow attaching my buiness object to a SOFM object
> but still no luck
> there.
>
> If I change the method from SENDTASKDESCRIPTION to
> DISPLAYTASKDESCRIPTION
> and bind through my object into the ADHOC_OJBECT
> then this works. However,
> the workflow will not COMPLETE until the user
> executes the task if I use
> DISPLAYTASKDESCRIPTION. I would much prefer to use
> SENDTASKDESCRIPTION.
>
> Your assistance is appreciated.
>
> Regards,
>
> Alon Raskin
> Workflow Advisor - Soliance
> (xtn. 3183)
>
> Alon Raskin
> Workflow Advisor - Soliance
> (xtn. 3183)
>
> -----Original Message-----
>> From: Daniel Fernandez [mailto:wfdfl1975 at yahoo.es]
>
> Sent: February 18 2002 10:30
> To: SAP-WUG at MITVMA.MIT.EDU
> Subject: send mail with attached objects
>
> Hello All,
>
> My name is Daniel, and I have a problem with the
> method SendTaskDescription of object SELFITEM.
>
> I can send a mail with this method but I can4t
> attach
> a object in this mail (a invoice or a purchase
> order,
> for example)
>
> How can I attach a object in a simple mail ( no a
> workitem)??????
>
>
> Thaks a lot for yuor help,
>
> Regards,
>
>
> Daniel
>
>
>
>
_______________________________________________________________
> Do You Yahoo!?
> Yahoo! Messenger
> Comunicacisn instantanea gratis con tu gente.
> http://messenger.yahoo.es
_______________________________________________________________
Do You Yahoo!?
Yahoo! Messenger
Comunicacisn instantanea gratis con tu gente.
http://messenger.yahoo.es
More information about the SAP-WUG
mailing list