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

SAP MDG Hierarchy assignments through program


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.


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


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
  12. Start the workflow using method start_workflow
  13. Once new change request is completed, hierarchy assignment will be done in MDG system


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

      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

      Author's profile photo upasana gupta
      upasana gupta


      I am following similar steps to delete assignment of FSI nodes but delete assignment method is giving error - ' Hierarchy ranges or hierarchy fragments cannot be maintained'

      Here I am trying to un-assign childs and sub childs of a FSI node and able to un-assign the parent node from UI.

      Can you please help with this error.




      Author's profile photo CARLOS RODRIGUEZ VALENZUELA

      Is it possible to make the assignment through derivation when CC is being created ?