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: 

How to Attach Document in SAP Mail

Former Member
0 Kudos
79

hi

I want to attach a document in the SAP mail, but it should open in the SAP itself.like ALV grid FOrmat.

Thanks in advance.

2 REPLIES 2

Former Member
0 Kudos
44

Hi,

Try this m not very sure this is wht u reqd or not???

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:\ Vikalp Solutions'.

  • Can be any file from your pc....either xls or word or ppt etc...

g_user-sapname = sy-uname.

CALL FUNCTION 'SO_USER_READ_API1'

EXPORTING

user = g_user

  • PREPARE_FOR_FOLDER_ACCESS = ' '

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 = 'testing by program'.

g_document-folrg = 'O'.

*g_document-okcode = 'CHNG'.

g_document-objlen = '0'.

g_document-file_ext = 'TXT'.

g_header-objdes = 'testing by program'.

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

  • FOLMEM_DATA =

  • RECEIVE_DATA =

.

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

method1 = 'SEND'.

g_receipients-recnam = 'MK085'.

g_receipients-recesc = 'B'.

g_receipients-sndex = '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.

Hope this helps u.

Thanks.

Seema.

former_member188685
Active Contributor
0 Kudos
44