As per standard SAP process, workflow doesn’t trigger for purchase requisitions created through MRP process.
Reason:
Usually, there is a possibility that the PR’s created through MRP can get deleted again by materials planning and due to this, there will be inconsistencies created between PR’s created through MRP and work items.
Solution:
One of the solutions to fix this problem is by using BADI MD_PURREQ_POST.
Step 1:
Go to T-code SE19.
Enter MD_PURREQ_POST in the classic BADI name which is present under create implementation section.
Step 2:
Click on create implementation and then you’ll get a pop-up like this.
Step 3: Enter implementation name and click enter.
Step 4:
In the next screen, enter short text and save and activate it.
You can see a class has been automatically created by the system and runtime behavior has been changed to implementation will be called.
Step 5:
Double click on the name of the class and add the below code in the method.
Code:
DATA: key TYPE sweinstcou-objkey,
rel_code TYPE t16fc-frgco,
event_container TYPE TABLE OF swcont,
lt_rel_final TYPE TABLE OF bapirlcorq.
key = im_eban-banfn.
DEFINE swc_set_element.
CALL FUNCTION 'SWC_ELEMENT_SET'
EXPORTING
element = &2
field = &3
TABLES
container = &1
EXCEPTIONS OTHERS = 1.
END-OF-DEFINITION.
"get the release group
CALL FUNCTION 'ME_REL_INFO'
EXPORTING
i_frgkz = im_eban-frgkz
i_frggr = im_eban-frggr
i_frgst = im_eban-frgst
i_frgot = '1'
i_no_dialog = 'X'
TABLES
rel_final = lt_rel_final
EXCEPTIONS
not_active = 1
OTHERS = 2.
IF sy-subrc = 0.
READ TABLE lt_rel_final INTO DATA(ls_rel_final) INDEX 1.
IF sy-subrc = 0.
IF ls_rel_final-rel_code1 IS NOT INITIAL.
swc_set_element event_container 'ReleaseCode' ls_rel_final-rel_code1.
CALL FUNCTION 'SWE_EVENT_CREATE_IN_UPD_TASK' IN UPDATE TASK
EXPORTING
objtype = 'BUS2105'
objkey = key
event = 'RELEASESTEPCREATED'
TABLES
event_container = event_container.
* EXCEPTIONS
* objtype_not_found = 1
* OTHERS = 2.
* IF sy-subrc = 1.
* MESSAGE text-001 TYPE 'E'.
* ENDIF.
ENDIF.
ENDIF.
ENDIF.
Step 6:
Now, save and activate your class.
Whenever purchase requisition is created through MRP, your workflow will automatically trigger, and you’ll receive work item in SBWP.