Skip to Content
author's profile photo Former Member
Former Member

SAP email sending functionality at GR return

Hi All,

User has a request that when warehouse do the GR/GI, purchasing could be informed by system automatically.

The user have once created the simple mail output ZMGR (copied from standard one MLGR) in Inventory Management, which looks like an short notification "Hi, this is an Goods Return Notification".

This mail is triggerd at the MIGO when saving the respective material document. However, this is just SAP simple email functionality, user are not satisfied, they need the information about the PO number and something else.

The output type for SAP mail is ZMGR, which was copied from standard one MLGR

PROGRAM for this is RSNASTSO

FORM routine for this is SAPOFFICE_AUFRUF

The above 2 are SAP standard one, and I just guess they only do the sending job.

Does anyone have an idea as to where the mail content is defined?

I just wonder whether if we can copy and change RSNASTSO / SAPOFFICE_AUFRUF to see if we can change the content of Mail Notes into a dynamic/logic words including PO number, Vendor number, etc

Can anyone give some suggestions regarding this?

Thanks & Regards,

Rajesh

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 11:00 AM

    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.

    ENDFORM. " DOCU_SEND_EMAIL

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.