Skip to Content
avatar image
Former Member

Auto generation of mail on change of vendor master data in fk02

Hi experts,

Please help me in this issue,

As mentioned in the subject line, I need to auto generate a mail to respective recepient whenever the vendor master record is being changed using FK02.

For this I used the user exit 'SAPMF02K' and function module 'EXIT_SAPMF02K_001'.

Inside the include I have posted the following code.

TYPES: BEGIN OF ty_lfbk,

         lifnr TYPE lfbk-lifnr,

         banks TYPE lfbk-banks,

         bankl TYPE lfbk-bankl,

         bankn TYPE lfbk-bankn,

         bkont TYPE lfbk-bkont,

         bvtyp TYPE lfbk-bvtyp,

         xezer TYPE lfbk-xezer,

         bkref TYPE lfbk-bkref,

         koinh TYPE lfbk-koinh,

         ebpp_accname TYPE lfbk-ebpp_accname,

         ebpp_bvstatus TYPE lfbk-ebpp_bvstatus,

         kovon TYPE lfbk-kovon,

         kobis TYPE lfbk-kobis,

       END OF ty_lfbk.

TYPES: BEGIN OF ty_j_1imovend,

         lifnr TYPE j_1imovend-lifnr,

         j_1icstno TYPE j_1imovend-j_1icstno,

         j_1ilstno TYPE j_1imovend-j_1ilstno,

       END OF ty_j_1imovend.

TYPES: BEGIN OF ty_zvend_user_mail,

         lifnr TYPE zvend_user_mail-lifnr,

         bukrs TYPE zvend_user_mail-bukrs,

         user_name TYPE zvend_user_mail-user_name,

         mailid TYPE zvend_user_mail-mailid,

         mailid_cc1 TYPE zvend_user_mail-mailid_cc1,

         mailid_cc2 TYPE zvend_user_mail-mailid_cc2,

       END OF ty_zvend_user_mail.

DATA: it_lfbk TYPE STANDARD TABLE OF ty_lfbk WITH HEADER LINE,

       wa_lfbk TYPE ty_lfbk.

DATA: it_j_1imovend TYPE STANDARD TABLE OF ty_j_1imovend,

       wa_j_1imovend TYPE ty_j_1imovend.

DATA: it_zvend_user_mail TYPE STANDARD TABLE OF ty_zvend_user_mail WITH HEADER LINE,

       wa_zvend_user_mail TYPE ty_zvend_user_mail.

DATA: t_packing_list TYPE TABLE OF  sopcklsti1,

       w_packing_list TYPE TABLE OF  sopcklsti1,

       new_object_id TYPE sofolenti1-object_id,

       t_message TYPE TABLE OF solisti1,

       w_message TYPE solisti1,

       t_receivers TYPE TABLE OF somlreci1,

       w_receivers TYPE somlreci1,

       w_doc_data TYPE sodocchgi1 ,

       w_sent_all(1) TYPE c    .

SELECT * FROM lfbk

   INTO CORRESPONDING FIELDS OF TABLE it_lfbk

   WHERE lifnr = wa_lfbk-lifnr.

SELECT * FROM j_1imovend

   INTO CORRESPONDING FIELDS OF TABLE it_j_1imovend

     FOR ALL ENTRIES IN it_lfbk

     WHERE lifnr = it_lfbk-lifnr.

SELECT * FROM

   zvend_user_mail INTO CORRESPONDING FIELDS OF TABLE it_zvend_user_mail

    FOR ALL ENTRIES IN it_lfbk

   WHERE lifnr = it_lfbk-lifnr.

IF sy-subrc = 0.

   LOOP AT  it_zvend_user_mail INTO wa_zvend_user_mail.

     CLEAR w_receivers.

     CONDENSE : wa_zvend_user_mail-mailid,wa_zvend_user_mail-mailid_cc1,

                wa_zvend_user_mail-mailid_cc2 NO-GAPS .

     TRANSLATE :wa_zvend_user_mail-mailid  TO LOWER CASE ,

                wa_zvend_user_mail-mailid_cc1 TO LOWER CASE ,

                wa_zvend_user_mail-mailid_cc2 TO LOWER CASE .

     w_receivers-receiver   = wa_zvend_user_mail-mailid.

     w_receivers-rec_type   = 'U'    .

     w_receivers-com_type   = 'INT'  .

     w_receivers-notif_del  = 'X'    .

     w_receivers-express    = 'X'    .

     w_receivers-notif_ndel = 'X'    .

     APPEND w_receivers TO t_receivers. CLEAR w_receivers.

     w_receivers-receiver   = wa_zvend_user_mail-mailid_cc1.

     w_receivers-rec_type   = 'U'    .

     w_receivers-com_type   = 'INT'  .

     w_receivers-notif_del  = 'X'    .

     w_receivers-copy       = 'X'    .

     w_receivers-notif_ndel = 'X'    .

     APPEND w_receivers TO t_receivers. CLEAR w_receivers.

     w_receivers-receiver   = wa_zvend_user_mail-mailid_cc2.

     w_receivers-rec_type   = 'U'    .

     w_receivers-com_type   = 'INT'  .

     w_receivers-notif_del  = 'X'    .

     w_receivers-copy       = 'X'    .

     w_receivers-notif_ndel = 'X'    .

     APPEND w_receivers TO t_receivers. CLEAR w_receivers.

   ENDLOOP.

ENDIF.

APPEND w_message TO t_message. CLEAR : w_message .

READ TABLE it_zvend_user_mail INTO wa_zvend_user_mail INDEX 1 .

CONCATENATE 'Hi' wa_zvend_user_mail-user_name ',' INTO w_message-line

SEPARATED BY space .

APPEND w_message TO t_message. CLEAR : w_message .

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

   EXPORTING

     document_data              = w_doc_data

     put_in_outbox              = 'X'

*                SENDER_ADDRESS             = LD_SENDER_ADDRESS

*                SENDER_ADDRESS_TYPE        = LD_SENDER_ADDRESS_TYPE

   commit_work                = 'X'

   IMPORTING

     sent_to_all                = w_sent_all

      new_object_id              = new_object_id  "Added on 20/10/2015

   TABLES

     packing_list               = t_packing_list

     contents_txt               = t_message

     receivers                  = t_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.

   WAIT UP TO 4 SECONDS.

   SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.


But even on creating Breakpoint on very first line the pointer doesn't enter into this code, while changing the vendor master data with tcode fk02.


So please suggest your points.


Thanks in advance.


Sanjeev

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Oct 21, 2015 at 11:37 AM

    You could try

    • BAdI : VENDOR_ADD_DATA - method SAVE_DATA
    • Customer exit : enhancement SAPMF02K - exit FM EXIT_SAPMF02K_001
    • BTE : 00001420
    • Change pointers, etc.

    In every case don't break the current transaction (no forbidden statement, read documentation of each enhancement) easier is to execute some FM IN BACKGROUND TASK.

    For testing don't forget to activate project, enhancement implementation or application.

    Regards,

    Raymond

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 21, 2015 at 11:16 AM

    Hi Sanjeev,

    It seems that user exit is not getting called while changing the vendor.

    try BADI "VENDOR_ADD_DATA"  and try to implement the same code inside method 'CHECK_ALL_DATA' or 'SAVE_DATA'.

    Regards

    Chudamani

    Add comment
    10|10000 characters needed characters exceeded