SAP MDG · DATA MODEL & UI
Why does copying a Business Partner in MDG raise USMD_GOV_API 010 'Entity BP_HEADER is not locked' for a custom child entity, and how do I fix it?
BP copy fails with 'Entity BP_HEADER is not locked' for custom (Z) entities
When you copy a Business Partner, a custom (Z) child entity can fail with USMD_GOV_API 010 "Entity BP_HEADER is not locked". This happens when the entity's GenIL attribute structure contains BP_HEADER. The standard cloner copies the source BP number into the new row, so the governance API checks for a lock on the source BP. Clear BP_HEADER on the clone with a post-exit on CL_BS_BOL_ENTITY_CLONER->SET_CLONED_ATTRIBUT…
Short answer
When you copy a Business Partner, a custom (Z) child entity can fail with USMD_GOV_API 010 "Entity BP_HEADER is not locked". This happens when the entity's GenIL attribute structure contains BP_HEADER. The standard cloner copies the source BP number into the new row, so the governance API checks for a lock on the source BP. Clear BP_HEADER on the clone with a post-exit on CL_BS_BOL_ENTITY_CLONER->SET_CLONED_ATTRIBUTES.
What is happening
- Copy flow:
CL_BS_BP_QUERY_RESULT->CREATE_BP_ROOT→CL_BS_BOL_ENTITY_CLONER->CLONE_ENTITY→CLONE_OF_ENTITY/CLONE_OF_RELATED_ENTITY. - The cloner creates each child under the new parent with
create_related_entity. - It then calls
SET_CLONED_ATTRIBUTES, which is simplyio_clone->set_properties( is_attributes ). This copies every attribute of the source child. - Where it fails: if your custom entity's attribute structure includes the key field
BP_HEADER, the source BP number is copied with everything else. - On create,
CL_MDG_BS_GENIL->OBJECT_CREATE→CL_MDG_BS_BP_FRU→CL_USMD_CONV_SOM_GOV→CL_USMD_GOV_API->IF_USMD_GOV_API_ENTITY~WRITE_ENTITY. CHECK_ENTITY_MAINTAINABLEmaps the entity to its main entity (BP_HEADER).IS_ENTITY_ENQUEUEDthen checks the lock for the source BP number.- The change request has only locked the new BP (temporary
$key), so message 010 is raised. - The exception is caught in
CL_MDG_BS_GENIL->OBJECT_CREATE, and the custom rows are not written. - Standard entities don't carry
BP_HEADERas an attribute, which is why only the custom entity breaks. - Not the cause: your access-class handler's read mapping (for example
MAP_DATA_TO_STAGING_<entity>). It correctly fillsBP_HEADERwith the source BP while reading the source data.
Solution
Create a post-exit (not a redefinition) on CL_BS_BOL_ENTITY_CLONER->SET_CLONED_ATTRIBUTES.
- A post-exit runs after the standard
set_properties, but before the BOL modify executes. - The subclass
CL_BS_BP_BOL_ENTITY_CLONERdoes not redefine this method, so enhance the base class and guard it by entity name. - Make sure your custom entities are also allowed for cloning. Use a post-exit on
CL_BS_BP_BOL_ENTITY_CLONER->IS_ENTITY_SUPPORTEDthat returnsabap_trueforZZ*entities.
1METHOD ipo_zz_bol_cloner_key~set_cloned_attributes.
2* BP copy: custom entity attributes carry BP_HEADER of the SOURCE BP.
3* Clear it so the framework derives the key from the new parent.
4 CHECK io_clone IS BOUND.
5 CHECK io_clone->get_name( ) CP 'ZZ*'.
6
7 ASSIGN COMPONENT 'BP_HEADER' OF STRUCTURE is_attributes
8 TO FIELD-SYMBOL(<lv_bp_header>).
9 IF sy-subrc = 0 AND <lv_bp_header> IS NOT INITIAL.
10 io_clone->set_property( iv_attr_name = 'BP_HEADER'
11 iv_value = space ).
12 ENDIF.
13ENDMETHOD.After activation, check that the enhancement implementation is Active with no inactive version, then retest the copy.
Debug points
- Message breakpoint USMD_GOV_API 010: go up the stack to
CL_USMD_GOV_API->CHECK_ENTITY_MAINTAINABLE. WatchIV_ENTITY_NAME,IS_DATA-BP_HEADERandLR_KEY_STRUC. CL_MDG_BS_GENIL->OBJECT_CREATE: watch the object name, the key (BP_GUID) and the attributes reference. Check whetherBP_HEADERholds the source BP.CL_BS_BOL_ENTITY_CLONER->CLONE_OF_ENTITY/SET_CLONED_ATTRIBUTES: checkIS_ATTRIBUTESfor the copied key fields.- External breakpoints are client-specific: set them while logged on to the client where you run the Fiori or Web UI test.
Alternate options
- Remove
BP_HEADER(and similar key-like fields such as an assignment ID) from the custom entity's GenIL attribute structure, and keep them only in the key or staging structure. This is cleaner, but it touches the data model, the UI configuration and the mapping. - Exclude the custom entity from copy, using
IS_ENTITY_SUPPORTED= false, and accept that the data isn't copied.
References
CL_BS_BOL_ENTITY_CLONER,CL_BS_BP_BOL_ENTITY_CLONER,CL_MDG_BS_GENIL,CL_MDG_BS_BP_FRU,CL_USMD_GOV_API.- Message class
USMD_GOV_API, message 010.
The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- MDG BP copy custom entity not copied, BP_HEADER not locked error
- How to clear copied key fields in CL_BS_BOL_ENTITY_CLONER during BP copy?
USMD_GOV_API010 during Business Partner copy with Z entity
Possible questions
- MDG BP copy custom entity not copied, BP_HEADER not locked error
- How to clear copied key fields in CL_BS_BOL_ENTITY_CLONER during BP copy?
USMD_GOV_API010 during Business Partner copy with Z entity- What configuration is required for BP copy fails with 'Entity BP_HEADER is not locked' for custom (Z) entities?
- How can this SAP MDG scenario be tested?