Triggering IDOC using BTE when Material is changed in MM02 Transaction


8.    Now we have created a  Z function module “ZSAMPLE_INTERFACE_00001250” where we can write our custom code for triggering IDOC as followed :

FUNCTION zsample_interface_00001250.
*"*"Local Interface:
DATA : gt_idoc_data TYPE STANDARD TABLE OF edidd,
TYPE edidd,
LIKE edidc,

DATA: wa_e1maram LIKE e1maram,
LIKE e1maktm,
LIKE e1marcm,
LIKE e1mardm,
LIKE e1marmm,
LIKE e1mbewm,
LIKE e1mvkem,
LIKE e1mlanm.

*Filling IDOC Control records
  wa_idoc_control-mestyp = 
  wa_idoc_control-idoctp = 
  wa_idoc_control-rcvpor = 
  wa_idoc_control-rcvprt = 
  wa_idoc_control-rcvprn = 

  wa_idoc_data-segnam = 
MOVE-CORRESPONDING i_mara_new TO wa_e1maram.
MOVE wa_e1maram TO wa_idoc_data-sdata.
APPEND wa_idoc_data TO gt_idoc_data.

CLEAR wa_idoc_data.
  wa_idoc_data-segnam = 
MOVE-CORRESPONDING t_makt_new TO wa_e1maktm.
MOVE wa_e1maktm TO wa_idoc_data-sdata.
APPEND wa_idoc_data TO gt_idoc_data.

CLEAR wa_idoc_data.
  wa_idoc_data-segnam = 
MOVE-CORRESPONDING i_marc_new TO wa_e1marcm.
MOVE wa_e1marcm TO wa_idoc_data-sdata.
APPEND wa_idoc_data TO gt_idoc_data.

CLEAR wa_idoc_data.
  wa_idoc_data-segnam = 
MOVE-CORRESPONDING i_mard_new TO wa_e1mardm.
MOVE wa_e1mardm TO wa_idoc_data-sdata.
APPEND wa_idoc_data TO gt_idoc_data.

CLEAR wa_idoc_data.
  wa_idoc_data-segnam = 
MOVE-CORRESPONDING t_marm_new TO wa_e1mardm.
MOVE wa_e1mardm TO wa_idoc_data-sdata.
APPEND wa_idoc_data TO gt_idoc_data.

CLEAR wa_idoc_data.
  wa_idoc_data-segnam = 
MOVE-CORRESPONDING i_mbew_new TO wa_e1mardm.
MOVE wa_e1mardm TO wa_idoc_data-sdata.
APPEND wa_idoc_data TO gt_idoc_data.

CLEAR wa_idoc_data.
  wa_idoc_data-segnam = 
MOVE-CORRESPONDING i_mvke_new TO wa_e1mvkem.
MOVE wa_e1mvkem TO wa_idoc_data-sdata.
APPEND wa_idoc_data TO gt_idoc_data.

CLEAR wa_idoc_data.
  wa_idoc_data-segnam = 
MOVE-CORRESPONDING i_mvke_new TO wa_e1mlanm.
MOVE wa_e1mlanm TO wa_idoc_data-sdata.
APPEND wa_idoc_data TO gt_idoc_data.

CLEAR wa_idoc_data.
  wa_idoc_data-segnam = 
MOVE-CORRESPONDING i_mvke_new TO wa_e1mlanm.
MOVE wa_e1mlanm TO wa_idoc_data-sdata.
APPEND wa_idoc_data TO gt_idoc_data.

*Generating IDOC
      master_idoc_control                  = wa_idoc_control
*   OBJ_TYPE                             = ''
*   CHNUM                                = ''
      communication_idoc_control           = gt_comm_idocs
      master_idoc_data                     = gt_idoc_data
   error_in_idoc_control                = 
   error_writing_idoc_status            = 
   error_in_idoc_data                   = 
   sending_logical_system_unknown       = 
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.


Now we need to do some configuration to activate the BTE so that it will only trigger when SAVE button would be pressed while changing the material in MM02. Steps as follows:

9.   Go to FIBF transaction -> Settings -> P/S Modules -> then select ….Of a customer.

The below screen will appear

Then SELECT new entries and add 1 row of information by giving BTE event name (00001250), Product name (ZTEST), and the newly created Z function module (ZSAMPLE_INTERFACE_00001250) where we have coded for triggering IDOCs. SAVE the entry.

10.     Now go to FIBF transaction->Settings->Products-> Select ….Of a customer.

 Then the below screen will come. Here create a new entry by giving Product name (ZTEST), Short text, and Select the check box in activation column. Save it.  


Now the scenario is completed. The BTE will trigger the IDOC when ever material is changed in MM02 transaction by clicking SAVE button.

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image