ITPub博客

首页 > IT基础架构 > 网络安全 > Make E-mail Sender of PO the PO Creators Name

Make E-mail Sender of PO the PO Creators Name

原创 网络安全 作者:ultraluck 时间:2019-04-18 14:39:04 0 删除 编辑
Make E-mail Sender of PO the PO Creators Name

ABAP Code Needed to Make E-mail Sender of PO the PO Creators Name

1) Do the config and user email data setup as noted elsewhere this is supplemental ABAP help ONLY.

2) Apply OSS note 561593, this is a release independent note.

3) on SE37, edit function module RV_MESSAGES_MAINTENANCE, this is custom programming logic.

Look for this context block:

context begin
* Änderung prüfen 
------------------------------------------------------
  CLEAR MEX_UPDAT.
  READ TABLE WNAST INDEX 1.
  IF SY-TFILL = 0.
* emtpy WNAST -> no existing output in the database
    READ TABLE VNAST INDEX 1.
    IF SY-TFILL > 0.
* filled VNAST -> new output added
      MEX_UPDAT = 'X'.
    ELSE.
      READ TABLE XNAST INDEX 1.
      IF SY-TFILL > 0.
* filled XNAST -> new output added
        MEX_UPDAT = 'X'.
      ENDIF.
    ENDIF.
  ELSE.
context end
insert this logic:
insert begin
*if external e-mail get created by name
*note: vstat=0 means this item has not been sent yet, even if it is a 
repeat output
*      nacha=5 means that the medium is 5-external send
  tables: ekko.
  loop at vnast where vstat = 0 and nacha = '5'.
    select single * from ekko into ekko
     where ebeln eq vnast-objky.
    if sy-subrc = 0.
      vnast-usnam = ekko-ernam.
      modify vnast.
    endif.
  endloop.
insert end 
context begin
* non-empty WNAST -> output existed before
    LOOP AT VNAST.
      IF VNAST-UPDAT NE SPACE.
        MEX_UPDAT = 'X'.
        EXIT.
      ENDIF.
      NAST_KEY = VNAST.
      READ TABLE WNAST WITH KEY
        MANDT      =    NAST_KEY-MANDT ...
context end 
The PO being sent must use the SMTP communication strategy, a 1 in the Number of Messages field, and the Print immediately box checked on. *-- By DF

Enhancement for sending mail when the purchase order is releaed

When we release any object in me29n transaction then mail has to be send to vendor that the puchase order has been
released. The code that is to be written in the enhacement for the same is:

*&---------------------------------------------------------------------*
*&  Include           ZXM06U44
*&---------------------------------------------------------------------*
*Data Declaration
DATA : rel_ind LIKE i_ekko-frgke.
rel_ind = i_ekko-frgke.
*Release PO when final authorized person process PO
IF sy-tcode EQ 'ME29N' AND rel_ind EQ 2.

*Internal table to get vendor name and address number
  DATA : BEGIN OF it_vname OCCURS 0,
         name1 LIKE lfa1-name1,
         adrnr LIKE lfa1-adrnr,
         END OF it_vname.
*Internal table to get email_if with address number
  DATA : BEGIN OF it_vemail OCCURS 0,
         email LIKE adr6-smtp_addr,
         END OF it_vemail.
*Emiail subject
  DATA : psubject(40) TYPE c .

*Data declaration for mail FM
  DATA:   it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
          it_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
          it_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_cnt TYPE i,
          gd_sent_all(1) TYPE c,
          gd_doc_data LIKE sodocchgi1,
          gd_error TYPE sy-subrc.

*Internal table for message body
  DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                  WITH HEADER LINE,
          it_messagewa LIKE LINE OF it_message        .

  psubject = 'PO Regarding'.

*Accessing name and address number of a vendor
  SELECT SINGLE name1 adrnr FROM lfa1 INTO it_vname WHERE lifnr EQ 
i_ekko-lifnr.

*Accessing mail id of a vendor
  SELECT SINGLE smtp_addr FROM adr6 INTO it_vemail WHERE addrnumber EQ 
it_vname-adrnr.

* Mail Text
  clear it_message.
  REFRESH it_message.
  CONCATENATE 'Dear' it_vname-name1 ',' INTO it_messagewa SEPARATED BY 
space.
  APPEND  it_messagewa TO it_message.
  APPEND 'Please issue the items for the following PO Number .' TO 
it_message.
  CLEAR it_messagewa.
  CONCATENATE 'PO NUmber : ' i_ekko-ebeln  INTO it_messagewa SEPARATED 
BY space.
  APPEND it_messagewa TO it_message.
  APPEND 'you can view it at www.mindteck/sap/mm/login.' TO it_message.
  APPEND 'Regards,' TO it_message.
  APPEND 'Anand.' TO it_message.

* Fill the document data.
  gd_doc_data-doc_size = 1.

* Populate the subject/generic message attributes
  gd_doc_data-obj_langu = sy-langu.
  gd_doc_data-obj_name  = 'SAPRPT'.
  gd_doc_data-obj_descr = psubject.
  gd_doc_data-sensitivty = 'F'.

* Describe the body of the message
  CLEAR it_packing_list.
  REFRESH it_packing_list.
  it_packing_list-transf_bin = space.
  it_packing_list-head_start = 1.
  it_packing_list-head_num = 0.
  it_packing_list-body_start = 1.
  DESCRIBE TABLE it_message LINES it_packing_list-body_num.
  it_packing_list-doc_type = 'RAW'.
  APPEND it_packing_list.

* Add the recipients email address
  CLEAR it_receivers.
  REFRESH it_receivers.
  it_receivers-receiver = it_vemail-email.
  it_receivers-rec_type = 'U'.
  it_receivers-com_type = 'INT'.
  it_receivers-notif_del = 'X'.
  it_receivers-notif_ndel = 'X'.
  APPEND it_receivers.

* Call the FM to post the message to SAPMAIL
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data                    = gd_doc_data
      put_in_outbox                    = 'X'
      commit_work                      = 'X'
   IMPORTING
     sent_to_all                      = gd_sent_all
*   NEW_OBJECT_ID                    =
    TABLES
      packing_list                     = it_packing_list
*   OBJECT_HEADER                    =
*   CONTENTS_BIN                     =
      contents_txt                     = it_message
*   CONTENTS_HEX                     =
*   OBJECT_PARA                      =
*   OBJECT_PARB                      =
      receivers                        = it_receivers
   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 SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

* Store function module return code
  gd_error = sy-subrc.

* Get it_receivers return code
  LOOP AT it_receivers.
  ENDLOOP.
ENDIF.
This we need to write in the mm06e005. In this enhacement in this enhacement there is a function exit exit_sapmm06e_013 in this I had wrote the code for the same enhacement.
*-- Praveen Kumar (praveen417@gmail.com)[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/190059/viewspace-1012768/,如需转载,请注明出处,否则将追究法律责任。

上一篇: send a mail via sap
请登录后发表评论 登录
全部评论

注册时间:2004-12-03

  • 博文量
    111
  • 访问量
    78912