Skip to Content
Technical Articles
Author's profile photo Omkar Surve

SAP MDG Hierarchy assignments through program

Overview:

This blog will help to create/change the hierarchy assignment to respective MDG objects. Here we will be focussing on how to create the  assignment of cost center to cost center group and cost center hierarchy through a program in MDG.

Prerequisite:

  • Cost center hierarchy assignment change request type should be configured.
  • Necessary authorizations should be provided to background user (SAP_WFRT) to create/change assignment

Process:

We will be creating a follow-up change request for cost center hierarchy assignment which will be triggered once main cost center change request is completed in the MDG system. Once main change request is completed use below logic in badi implementation USMD_SSW_SYSTEM_METHOD_CALLER. Get the required cost center, cost center group and cost center hierarchy to be assigned.

  1. Create a dummy change request using governance API (if_usmd_gov_api)
  2. Pass relevant edition using method set_crequest_edition
  3. Enqueue the change request using method enqueue_entity
  4. Check if cost center is already assigned to any cost center group using Hierarchy API (if_usmd_hry_api).  If required delete the assignment using method delete_assignment
  5. Pass hierarchy key (Cost center hierarchy), parent key (Cost center group) and node key (Cost center)
  6. Enqueue the assignment using method enqueue_assignment
  7. Create the assignment using method write_assignment
  8. Check for errors using method check_crequest_data
  9. If no errors then dequeue the assignment using method dequeue_assignment
  10. Dequeue the change request using method dequeue_entity
  11. Perform COMMIT WORK AND WAIT.
  12. Start the workflow using method start_workflow
  13. Once new change request is completed, hierarchy assignment will be done in MDG system

Summary:

By following above steps you can create/change the hierarchy assignments using MDG APIs for your standard MDG objects like profit center hierarchy assignment, cost element hierarchy assignment etc. and also for custom MDG objects

Hope you will find this information useful.

Please like, share and comment.
If you have anything else please feel free to ask any question or add points.

Happy Learning!

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Priyanka saha
      Priyanka saha

      Please can you provide the code...... I am getting error for the other costcenter that are not assigned