Application Development and Automation 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: 
Read only

Mail from dialog program

Former Member
0 Likes
530

Hi,

I have to send a mail from a dialog program.The mail should contain 2 buttons(Approve, Reject). The receiver can press any of the buttons.Please suggest the function module which can be used.I have tried SO_NEW_DOCUMENT_SEND_API1 but dont know how to send the buttons in the mail using this function.Please suggest the solution.

4 REPLIES 4
Read only

Former Member
0 Likes
506

Hi,

to send mails use this:

FORM docu_send_email USING pv_otfdata TYPE tsfotf

pv_emailid TYPE any

pv_formname TYPE any.

DATA: lv_filesize TYPE i,

lv_buffer TYPE string,

lv_attachment TYPE i,

lv_testo TYPE i.

DATA: li_pdfdata TYPE STANDARD TABLE OF tline,

li_mess_att TYPE STANDARD TABLE OF solisti1,

li_mtab_pdf TYPE STANDARD TABLE OF tline,

li_objpack TYPE STANDARD TABLE OF sopcklsti1,

li_objtxt TYPE STANDARD TABLE OF solisti1,

li_objbin TYPE STANDARD TABLE OF solisti1,

li_reclist TYPE STANDARD TABLE OF somlreci1,

li_objhead TYPE soli_tab.

DATA: lwa_pdfdata TYPE tline,

lwa_objpack TYPE sopcklsti1,

lwa_mess_att TYPE solisti1,

lwa_objtxt TYPE solisti1,

lwa_objbin TYPE solisti1,

lwa_reclist TYPE somlreci1,

lwa_doc_chng TYPE sodocchgi1.

CONSTANTS: lc_u TYPE char1 VALUE 'U',

lc_0 TYPE char1 VALUE '0',

lc_1 TYPE char1 VALUE '1',

lc_pdf TYPE char3 VALUE 'PDF',

lc_raw TYPE char3 VALUE 'RAW',

lc_ordform TYPE char15 VALUE 'ZORDCONFIRM_01',

lc_attachment TYPE char10 VALUE 'ATTACHMENT'.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = lc_pdf

max_linewidth = 132

IMPORTING

bin_filesize = lv_filesize

TABLES

otf = pv_otfdata

lines = li_pdfdata

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

OTHERS = 5.

IF sy-subrc 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT li_pdfdata INTO lwa_pdfdata.

TRANSLATE lwa_pdfdata USING ' ~'.

CONCATENATE lv_buffer lwa_pdfdata INTO lv_buffer.

CLEAR lwa_pdfdata.

ENDLOOP.

TRANSLATE lv_buffer USING '~ '.

DO.

lwa_mess_att = lv_buffer.

APPEND lwa_mess_att TO li_mess_att.

CLEAR lwa_mess_att.

SHIFT lv_buffer LEFT BY 255 PLACES.

IF lv_buffer IS INITIAL.

EXIT.

ENDIF.

ENDDO.

  • Object with PDF.

REFRESH li_objbin.

li_objbin] = li_mess_att[.

DESCRIBE TABLE li_objbin LINES lv_attachment.

  • Object with main text of the mail.

lwa_objtxt = space.

APPEND lwa_objtxt TO li_objtxt.

CLEAR lwa_objtxt.

DESCRIBE TABLE li_objtxt LINES lv_testo.

  • Create the document which is to be sent

lwa_doc_chng-obj_name = text-008.

lwa_doc_chng-obj_descr = text-008.

lwa_doc_chng-sensitivty = lc_0.

lwa_doc_chng-obj_prio = lc_1.

lwa_doc_chng-doc_size = lv_testo * 225.

  • Pack to main body.

CLEAR lwa_objpack-transf_bin.

  • header

lwa_objpack-head_start = 1.

  • The document needs no header (head_num = 0)

lwa_objpack-head_num = 0.

  • body

lwa_objpack-body_start = 1.

lwa_objpack-body_num = lv_testo.

lwa_objpack-doc_type = lc_raw.

APPEND lwa_objpack TO li_objpack.

CLEAR lwa_objpack.

  • Create the attachment.

  • Fill the fields of the packing_list for the attachment:

lwa_objpack-transf_bin = gc_x .

  • header

lwa_objpack-head_start = 1.

lwa_objpack-head_num = 1.

  • body

lwa_objpack-body_start = 1.

lwa_objpack-body_num = lv_attachment.

lwa_objpack-doc_type = lc_pdf.

lwa_objpack-obj_name = lc_attachment.

lwa_objpack-obj_descr = text-008.

lwa_objpack-doc_size = lv_attachment * 255.

APPEND lwa_objpack TO li_objpack.

CLEAR lwa_objpack.

lwa_reclist-receiver = pv_emailid.

lwa_reclist-rec_type = lc_u.

lwa_reclist-notif_del = gc_x.

lwa_reclist-notif_ndel = gc_x.

APPEND lwa_reclist TO li_reclist.

IF li_reclist IS NOT INITIAL.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = lwa_doc_chng

put_in_outbox = gc_x

TABLES

packing_list = li_objpack

object_header = li_objhead

contents_bin = li_objbin

contents_txt = li_objtxt

receivers = li_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 sy-msgid TYPE 'I' NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

endif.

Read only

Former Member
0 Likes
506

Hi,

This can only be donw using workflow.Have a look at the tutorials @ SAPTECHNICAL.COM.

Hope this helps.

Thanks & Regards,

Rock.

Edited by: Rock on May 6, 2009 8:41 AM

Read only

Former Member
0 Likes
506

Hi,

Please check the program starting wioth BCS* in SE38.

These programs have expamples of how to send mails from a program.

Regards,

Ankur Parab

Read only

Former Member
0 Likes
506

hai

report

y_cr17_mail.

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.

*assign only the file path

parameters ws_file(4096) type c default 'c:\debugger.txt'.

  • Can send any file fromyour 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 = '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 = 'sap-img.com 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.

*-- End of Program

copy this code u can send any file using this code .

i think this may help u