SAP MDG · DATA MODEL UI
How do I automatically populate SAP MDG object keys during create request processing in the feeder class GET_DATA?
Use an implicit enhancement at the end of the feeder class GET_DATA method, generate the key only when the MDG create request context and target CR type match, update CS_DATA plus the feeder buffer, and then set EV_DATA_CHANGED. For Material, read staged MATKL; for G/L Account and Cost Center, use temporary keys; for Profit Center, use SNRO-based generation with a prefix.
Use an implicit enhancement at the end of the feeder class GET_DATA method, generate the key only when the MDG create request context and target CR type match, update CS_DATA plus the feeder buffer, and then set EV_DATA_CHANGED. For Material, read staged MATKL; for G/L Account and Cost Center, use temporary keys; for Profit Center, use SNRO-based generation with a prefix.
SAP MDG main-key auto-population is implemented in the feeder class `IF_FPM_GUIBB_FORM~GET_DATA` using an implicit enhancement at the end of the standard method. The pattern is simple: let standard processing fill `CS_DATA`, read the change-request context, generate the object key only when the create request matches, synchronize the feeder state, and finally flag the data as changed.
Process flow
- Let the standard feeder populate CS_DATA.
- Read the MDG application context with CL_USMD_APP_CONTEXT=>GET_CONTEXT.
- Check CR ID and CR type via GET_ATTRIBUTES.
- Exit unless the create CR type matches your configured scenario.
- Preserve an already populated key.
- For Material, read staged data with CL_USMD_MODEL_EXT=>GET_INSTANCE and READ_ENTITY_DATA_ALL, then extract MATKL dynamically.
- Generate or derive the key according to the object-specific strategy.
- Synchronize CS_DATA and the feeder buffer using SET_ACCESS_ATTRIBUTE, SET_ATTRIBUTE, or the popup’s MR_DATA-related structure as applicable.
General guidance — verify in your SAP release and implementation: configure the number-range object and interval used by NUMBER_GET_NEXT for final keys such as Profit Center and any object that uses SNRO-backed generation.
Number range setup for final key generation.
Referenced tables
| Object | Purpose |
|---|---|
SAP_MDG_AUTO_POPULATE_OBJECT_KEYS.md enhancement location table | Lists the source-supported feeder class, key field, method, and generation strategy for Material, G/L Account, Profit Center, copy popup, and Cost Center. |
SAP_MDG_AUTO_POPULATE_OBJECT_KEYS.md custom dependency replacement table | Shows which custom dependencies are replaced by standard MDG APIs and a method-local STATICS guard. |
The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I auto-fill MATNR, ACCOUNT, PCTR, or CCTR in SAP MDG?
- Where do I implement automatic main-key assignment in SAP MDG create requests?
- How do I generate a temporary or final key in an MDG FPM feeder?
Possible questions
- How do I automatically populate SAP MDG object keys during create request processing in the feeder class GET_DATA?
- What is the standard enhancement pattern for auto-generating main keys in SAP MDG?
- How do I use CL_USMD_APP_CONTEXT and NUMBER_GET_NEXT in an MDG feeder enhancement?
- How do I fill CS_DATA and the feeder buffer correctly so the MDG field is not only displayed but also saved?
- How do I adapt the auto-population pattern for Material, G/L Account, Profit Center, or Cost Center?