SAP MDG · DATA MODEL UI

How do I auto-populate Cost Center keys and controlling area in SAP MDG during create change requests?

Enhance the Cost Center feeder class GET_DATA logic to detect the create change request, then fill COAREA with the configured controlling area and CCTR with TEMP plus the change request number. Update both CS_DATA and the feeder access attribute, and set EV_DATA_CHANGED only after assignment.

Enhance the Cost Center feeder class GET_DATA logic to detect the create change request, then fill COAREA with the configured controlling area and CCTR with TEMP plus the change request number. Update both CS_DATA and the feeder access attribute, and set EV_DATA_CHANGED only after assignment.

Enhance the Cost Center feeder logic at the end of `GET_DATA`. Read the change request context with `CL_USMD_APP_CONTEXT=>GET_CONTEXT`, exit unless the create request type matches `ZCCT1P2`, then assign the controlling area to `COAREA` and derive the temporary key for `CCTR` from the change request number.

Process flow

  1. Open the Cost Center feeder class used in your MDG UI.
  2. Add an implicit enhancement at the end of GET_DATA.
  3. Read the application context with CL_USMD_APP_CONTEXT=>GET_CONTEXT.
  4. Check that the change request type is ZCCT1P2.
  5. Trim leading zeros from the change request ID.
  6. Fill COAREA only if it is initial.
  7. Fill CCTR only if it is initial.
  8. Call me->set_access_attribute for each populated field.

No SPRO path was retrieved in the source; the sample uses coded values for the create request type, controlling area, and key prefix.

Referenced tables

ObjectPurpose
— No configuration table was retrieved from the source.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1CONSTANTS gc_create_cr_type TYPE usmd_crequest_type VALUE 'ZCCT1P2'. 2CONSTANTS gc_controlling_area TYPE kokrs VALUE '0001'. 3CONSTANTS gc_key_prefix TYPE char4 VALUE 'TEMP'. 4 5DATA lo_context TYPE REF TO if_usmd_app_context. 6DATA lv_crequest_text TYPE string. 7 8FIELD-SYMBOLS <lv_coarea> TYPE any. 9FIELD-SYMBOLS <lv_cctr> TYPE any. 10 11lo_context = cl_usmd_app_context=>get_context( ). 12IF lo_context IS NOT BOUND. 13 RETURN. 14ENDIF. 15 16lo_context->get_attributes( 17 IMPORTING 18 ev_crequest_type = DATA(lv_crequest_type) 19 ev_crequest_id = DATA(lv_crequest) ). 20 21IF lv_crequest IS INITIAL OR lv_crequest_type <> gc_create_cr_type. 22 RETURN. 23ENDIF. 24 25lv_crequest_text = lv_crequest. 26SHIFT lv_crequest_text LEFT DELETING LEADING '0'. 27 28ASSIGN COMPONENT 'COAREA' OF STRUCTURE cs_data TO <lv_coarea>. 29IF sy-subrc = 0 AND <lv_coarea> IS ASSIGNED AND <lv_coarea> IS INITIAL. 30 <lv_coarea> = gc_controlling_area. 31**Very Important** 32 me->set_access_attribute( 33 io_access = me->mo_entity 34 iv_attr_name = 'COAREA' 35 iv_value = <lv_coarea> ). 36 ev_data_changed = abap_true. 37ENDIF. 38 39ASSIGN COMPONENT 'CCTR' OF STRUCTURE cs_data TO <lv_cctr>. 40IF sy-subrc = 0 AND <lv_cctr> IS ASSIGNED AND <lv_cctr> IS INITIAL. 41 <lv_cctr> = |{ gc_key_prefix }{ lv_crequest_text }|. 42 me->set_access_attribute( 43 io_access = me->mo_entity 44 iv_attr_name = 'CCTR' 45 iv_value = <lv_cctr> ). 46 ev_data_changed = abap_true. 47ENDIF.

The remaining configuration, implementation details, and testing guidance continue from this answer more…

Related questions and keywords

Alternative questions

  • How do I fill COAREA and CCTR automatically in the Cost Center feeder class?
  • How do I derive a temporary Cost Center key from the change request number in MDG?
  • Which GET_DATA enhancement pattern is used for Cost Center auto-key population?

Possible questions

  • How do I auto-populate Cost Center keys and controlling area in SAP MDG during create change requests?
  • How do I fill COAREA and CCTR automatically in the Cost Center feeder class?
  • How do I derive a temporary Cost Center key from the change request number in MDG?
  • Which GET_DATA enhancement pattern is used for Cost Center auto-key population?
  • How do I prevent overwriting a manually entered Cost Center key?

Keywords

SAP MDGCost CenterCCTRCOAREAIF_FPM_GUIBB_FORM~GET_DATACL_MDGF_GUIBB_CCTRCL_USMD_APP_CONTEXTset_access_attributechange requesttemporary key