ABAP顾问
分类:
2007-11-12 21:23:35
*&---------------------------------------------------------------------*
*& Report ZRS08094 *
*& *
*&---------------------------------------------------------------------*
*& mail 本地文件做为附件发送 *
*& *
*&---------------------------------------------------------------------*
REPORT zrs08094 .
DATA method1 LIKE sy-ucomm.
DATA g_user LIKE soudnamei1.
DATA g_user_data LIKE soudatai1.
DATA g_owner LIKE soud-usrnam.
DATA g_receipients LIKE soos1 OCCURS 0 WITH HEADER LINE.
DATA g_document LIKE sood4 .
DATA g_header LIKE sood2.
DATA g_folmam LIKE sofm2.
DATA g_objcnt LIKE soli OCCURS 0 WITH HEADER LINE.
DATA g_objhead LIKE soli OCCURS 0 WITH HEADER LINE.
DATA g_objpara LIKE selc OCCURS 0 WITH HEADER LINE.
DATA g_objparb LIKE soop1 OCCURS 0 WITH HEADER LINE.
DATA g_attachments LIKE sood5 OCCURS 0 WITH HEADER LINE.
DATA g_references LIKE soxrl OCCURS 0 WITH HEADER LINE.
DATA g_authority LIKE sofa-usracc.
DATA g_ref_document LIKE sood4.
DATA g_new_parent LIKE soodk.
DATA: BEGIN OF g_files OCCURS 10 ,
text(4096) TYPE c,
END OF g_files.
DATA : fold_number(12) TYPE c,
fold_yr(2) TYPE c,
fold_type(3) TYPE c.
PARAMETERS ws_file(4096) TYPE c DEFAULT 'c:\AAA.txt'.
g_user-sapname = sy-uname.
CALL FUNCTION 'SO_USER_READ_API1'
EXPORTING
user = g_user
IMPORTING
user_data = g_user_data
EXCEPTIONS
user_not_exist = 1
parameter_error = 2
x_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
fold_type = g_user_data-outboxfol+0(3).
fold_yr = g_user_data-outboxfol+3(2).
fold_number = g_user_data-outboxfol+5(12).
CLEAR g_files.
REFRESH : g_objcnt,
g_objhead,
g_objpara,
g_objparb,
g_receipients,
g_attachments,
g_references,
g_files.
method1 = 'SAVE'.
g_document-foltp = fold_type.
g_document-folyr = fold_yr.
g_document-folno = fold_number.
g_document-objtp = g_user_data-object_typ.
*g_document-OBJYR = '27'.
*g_document-OBJNO = '000000002365'.
*g_document-OBJNAM = 'MESSAGE'.
g_document-objdes = 'sap-img.com testing by program'.
g_document-folrg = 'O'.
*g_document-okcode = 'CHNG'.
g_document-objlen = '0'.
g_document-file_ext = 'TXT'.
g_header-objdes = '邮件标题'.
g_header-file_ext = 'TXT'.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
EXPORTING
method = method1
office_user = sy-uname
ref_document = g_ref_document
new_parent = g_new_parent
IMPORTING
authority = g_authority
TABLES
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
CHANGING
document = g_document
header_data = g_header.
* File from the pc to send...
method1 = 'ATTCREATEFROMPC'.
g_files-text = ws_file.
APPEND g_files.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
EXPORTING
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
IMPORTING
authority = g_authority
TABLES
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
CHANGING
document = g_document
header_data = g_header.
*Send the mail..
method1 = 'SEND'.
g_receipients-recnam = 'BAITZ'.
*g_receipients-recesc = 'B'.
g_receipients-sndex = 'X'.
*g_receipients-att_fix ='X' .
APPEND g_receipients.
*g_receipients-recnam = 'ZHENGLL'.
**g_receipients-recesc = 'B'.
*g_receipients-sndex = 'X'.
*g_receipients-att_fix ='X' .
*APPEND g_receipients.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
EXPORTING
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
IMPORTING
authority = g_authority
TABLES
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
CHANGING
document = g_document
header_data = g_header.
*write 'aa'.