SAP MDG · DATA MODEL UI
How do I automatically derive and populate the Cost Element / Controlling Data UIBB during SAP MDG G/L Account creation for a Profit and Loss account?
Enhance CL_MDGF_GUIBB_FI_ACCT_CTRAREAS~IF_FPM_GUIBB_LIST~GET_DATA with an implicit enhancement that calls the standard Generate Controlling Data event only when the account is a P&L account, the short text exists, no controlling-data row is already present, the standard action is enabled, and the current change request has not yet been processed in this session.
Enhance CL_MDGF_GUIBB_FI_ACCT_CTRAREAS~IF_FPM_GUIBB_LIST~GET_DATA with an implicit enhancement that calls the standard Generate Controlling Data event only when the account is a P&L account, the short text exists, no controlling-data row is already present, the standard action is enabled, and the current change request has not yet been processed in this session.
Enhance the standard feeder `CL_MDGF_GUIBB_FI_ACCT_CTRAREAS` in `IF_FPM_GUIBB_LIST~GET_DATA` with an implicit enhancement at the end of the method. Reuse the standard action-usage decision for `IF_USMDZ10_CONSTANTS=>GC_ACT_CTRAREAS_GENERATE`, check that the G/L account is a Profit and Loss account (`S4ACCTYP = 'P'`), ensure the short text exists, skip if `CT_DATA` already contains a controlling-data row, and prevent duplicate execution for the same change request in the current internal session.
Process flow
- Enhance `CL_MDGF_GUIBB_FI_ACCT_CTRAREAS->IF_FPM_GUIBB_LIST~GET_DATA` at the end of the standard method.
- Read the MDG runtime context using `CL_USMD_APP_CONTEXT=>GET_CONTEXT` and extract the change request ID.
- Reuse the feeder-populated values for `MV_S4ACCOUNT_TYPE` and `MV_ACCOUNT_NAME`.
- Exit unless `S4ACCTYP = 'P'`, the short text exists, and `CT_DATA` is initial.
- Check `CT_ACTION_USAGE` for `IF_USMDZ10_CONSTANTS=>GC_ACT_CTRAREAS_GENERATE` and confirm it is enabled.
- Use a local `STATICS` guard to avoid duplicate generation for the same change request in one internal session.
- Create the standard FPM event with `CL_FPM_EVENT=>CREATE_BY_ID` and call `ME->ON_GENERATE_CTRAREAS`.
- Set `EV_DATA_CHANGED = ABAP_TRUE` after generation.
Referenced tables
| Object | Purpose |
|---|---|
CT_DATA | Runtime list table in the feeder; the enhancement checks that no controlling-data row already exists before generating. |
CT_ACTION_USAGE | Runtime action-usage table; the enhancement checks the enabled status of `IF_USMDZ10_CONSTANTS=>GC_ACT_CTRAREAS_GENERATE`. |
The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I trigger the standard Generate Controlling Data action automatically in MDG G/L Account maintenance?
- Which feeder class and method should I enhance to auto-populate controlling data in SAP MDG?
- How do I run the same logic as the Generate Controlling Data button in G/L Account creation?
Possible questions
- Which class and method are used for automatic controlling-data generation in SAP MDG?
- What guard conditions should I check before auto-generating controlling data?
- Can I use an implicit enhancement in GET_DATA for CL_MDGF_GUIBB_FI_ACCT_CTRAREAS?
- How do I avoid duplicate generation in the same change request session?
- What standard event is used for generating controlling data?