SAP MDG · DATA MODEL & UI
Why doesn't SAP MDG Business Partner Copy / Create with Reference copy my custom (Z) entities, and how do I fix it?
SAP MDG BP Copy / Create with Reference does not copy custom (Z) entities – root cause and fix
Short answer: the BOL Entity Cloner silently skips custom entities. Fix it with a post-exit (implicit enhancement), not a redefinition.
SAP MDG BP Copy does not copy custom (Z) entities
Short answer: the BOL Entity Cloner silently skips custom entities. Fix it with a post-exit (implicit enhancement), not a redefinition.
What is happening
- Copy / Create with Reference runs
CL_BS_BOL_ENTITY_CLONER=>CLONE_ENTITY. For BP the runtime cloner isCL_BS_CUSP_BOL_ENTITY_CLONER, which inherits fromCL_BS_BP_BOL_ENTITY_CLONER. - Your custom relations are in the relation list, the cloning pattern does not refuse them, and your handler's
GET_OBJECT_DATA_<entity>does read the source BP's data. - But for each entity,
CLONE_OF_ENTITYcallsCL_BS_BP_BOL_ENTITY_CLONER->IS_ENTITY_SUPPORTED:
1rv_entity_supported = super->is_entity_supported( iv_entity_name ).
2IF cl_bs_genil_bupa=>gc_object_name CS iv_entity_name.
3 rv_entity_supported = abap_true.
4ENDIF.Only standard BUPA object names pass. A Z entity returns space, so it is skipped and the new BP has no custom data. No error is shown.
Solution: post-exit, not a redefinition
A Z subclass won't help. The cloner is instantiated dynamically by SAP, so your subclass would never be used without modifying standard code.
Create an implicit enhancement: a post-method on CL_BS_BP_BOL_ENTITY_CLONER->IS_ENTITY_SUPPORTED. Answer Yes to "access private/protected components".
1" Allow custom entities in BP copy - use your own prefix or an explicit list
2IF iv_entity_name CP 'ZZ*'.
3 rv_entity_supported = abap_true.
4ENDIF.Activate it and check that no inactive version is left. Enhancements are client-independent.
Result: Copy now carries the custom entity data. In testing, a 7-row custom address entity and the custom general data copied fully.
If some custom attributes must not be copied (keys, numbers, dates), add elide/disinherit rules in a post-exit on PATTERN_ESSENTIALS.
Debug points
CL_BS_BOL_ENTITY_CLONER=>CLONE_ENTITY: checkLR_NAMES_OF_RELATIONS(is your relation there?) andIO_ENTITY(the source BP).CL_BS_BOL_ENTITY_CLONER->CLONE_OF_ENTITY: therefused_entitycheck (pattern) and theIS_ENTITY_SUPPORTEDcall.CL_BS_BP_BOL_ENTITY_CLONER->IS_ENTITY_SUPPORTED: watchrv_entity_supportedfor your entity.- Your handler's
GET_OBJECT_DATA_<entity>:IV_PARTNERis the source BP during copy. - Trigger the copy from Fiori with external breakpoints, then cancel the CR without saving.
Alternate option: static variable plus cross-entity derivation
The source BP reference is IO_ENTITY (the source BP root, CL_CRM_BOL_ENTITY) in CLONE_ENTITY / CLONE_OF_ENTITY. In a post-exit there, store the source partner in a static attribute of a Z helper class. Then, in your cross-entity derivation (or handler), read the custom data for that source BP and fill it into the new BP's custom entities. Use this when you need custom mapping logic instead of a straight 1:1 copy.
References
- SAP Notes 2020896 and 2714704 (BOL Entity Cloner)
- Message class
BS_BOL_ENTITY_CLONER(004 = "Pattern declines this entity").
The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- Why does BP Copy in MDG not copy Z fields or Z tables?
Possible questions
- Why does BP Copy in MDG not copy Z fields or Z tables?
- What configuration is required for SAP MDG BP Copy / Create with Reference does not copy custom (Z) entities – root cause and fix?
- How can this SAP MDG scenario be tested?