SAP MDG · DATA MODEL UI
How do I automatically populate the Profit Center key in the MDG copy popup when a create change request is opened?
Use an implicit enhancement at the end of `IF_FPM_GUIBB_FORM~GET_DATA` in `CL_USMD_COPY_ITEM_POPUP` to generate `PCTR` only for the configured create change request type, and only on the first popup call. Generate the number with `NUMBER_GET_NEXT`, prefix it as required, update `CS_DATA` and the feeder buffer, and set `EV_DATA_CHANGED = ABAP_TRUE` after assignment.
Use an implicit enhancement at the end of `IF_FPM_GUIBB_FORM~GET_DATA` in `CL_USMD_COPY_ITEM_POPUP` to generate `PCTR` only for the configured create change request type, and only on the first popup call. Generate the number with `NUMBER_GET_NEXT`, prefix it as required, update `CS_DATA` and the feeder buffer, and set `EV_DATA_CHANGED = ABAP_TRUE` after assignment.
Enhance `CL_USMD_COPY_ITEM_POPUP->IF_FPM_GUIBB_FORM~GET_DATA` with an implicit enhancement at the end of the standard implementation. The documented pattern is to generate the Profit Center key only when the popup opens for the configured create change request type, then fill `PCTR` from `NUMBER_GET_NEXT` using SNRO object `ZMDG_PCTR`, interval `01`, and prefix `P`. After assignment, synchronize the feeder data and raise `EV_DATA_CHANGED` so the UI shows the generated key.
Process flow
- Open the active implementation of `CL_USMD_COPY_ITEM_POPUP->IF_FPM_GUIBB_FORM~GET_DATA`.
- Add an implicit enhancement at the end of the standard method implementation.
- Guard the code with a first-time check so it runs only once.
- Get the MDG runtime context with `CL_USMD_APP_CONTEXT=>GET_CONTEXT`.
- Read the change request type with `GET_ATTRIBUTES` and compare it to `ZPCT1P2`.
- Call `NUMBER_GET_NEXT` for object `ZMDG_PCTR`, interval `01`.
- Build the final key using prefix `P` and the returned number.
- Update `CS_DATA` and any local feeder buffer structures.
Referenced tables
| Object | Purpose |
|---|---|
ZMDG_PCTR | SNRO number range object used to generate the Profit Center key. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1CONSTANTS gc_create_cr_type TYPE usmd_crequest_type VALUE 'ZPCT1P2'.
2CONSTANTS gc_nr_object TYPE inri-object VALUE 'ZMDG_PCTR'.
3CONSTANTS gc_nr_interval TYPE inri-nrrangenr VALUE '01'.
4CONSTANTS gc_key_prefix TYPE char1 VALUE 'P'.
5
6DATA lo_context TYPE REF TO if_usmd_app_context.
7DATA lv_number TYPE char20.
8DATA lv_new_pctr TYPE prctr.
9
10IF lv_first_time <> abap_true.
11 RETURN.
12ENDIF.
13
14lo_context = cl_usmd_app_context=>get_context( ).
15IF lo_context IS NOT BOUND.
16 RETURN.
17ENDIF.
18
19lo_context->get_attributes(
20 IMPORTING
21 ev_crequest_type = DATA(lv_crequest_type) ).
22
23IF lv_crequest_type <> gc_create_cr_type.
24 RETURN.
25ENDIF.
26
27CALL FUNCTION 'NUMBER_GET_NEXT'
28 EXPORTING
29 nr_range_nr = gc_nr_interval
30 object = gc_nr_object
31 quantity = 1
32 IMPORTING
33 number = lv_number
34 EXCEPTIONS
35 interval_not_found = 1
36 number_range_not_intern = 2
37 object_not_found = 3
38 quantity_is_0 = 4
39 quantity_is_not_1 = 5
40 interval_overflow = 6
41 buffer_overflow = 7
42 OTHERS = 8.
43
44IF sy-subrc <> 0.
45 RETURN.
46ENDIF.
47
48CONDENSE lv_number NO-GAPS.
49lv_new_pctr = |{ gc_key_prefix }{ lv_number }|.
50
51CLEAR cs_data.
52LOOP AT me->mt_key_field ASSIGNING <ls_key_field>
53 WHERE prefill_value = abap_true OR int_key = abap_true.
54 ASSIGN COMPONENT <ls_key_field>-fieldname OF STRUCTURE cs_data TO <lv_data>.
55 IF sy-subrc <> 0.
56 CONTINUE.
57 ENDIF.
58
59 IF <ls_key_field>-prefill_value = abap_true AND <ls_key_field>-fieldname = 'PCTR'.
60 <lv_data> = lv_new_pctr.
61 ELSEIF <ls_key_field>-prefill_value = abap_true.
62 ASSIGN COMPONENT <ls_key_field>-fieldname OF STRUCTURE <ls_data_from> TO <lv_data_from>.
63 IF sy-subrc = 0.
64 <lv_data> = <lv_data_from>.
65 ENDIF.
66 ELSE.
67 <lv_data> = text-002.
68 ENDIF.
69ENDLOOP.
70
71IF <ls_data_int> IS ASSIGNED.
72 MOVE-CORRESPONDING cs_data TO <ls_data_int>.
73ENDIF.
74
75ev_data_changed = abap_true.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I auto-generate PCTR in SAP MDG copy popup?
- Which feeder class and enhancement are used for Profit Center key auto-population in MDG?
- How do I implement implicit GET_DATA logic for Profit Center copy popup in SAP MDG?
Possible questions
- How do I automatically populate the Profit Center key in the MDG copy popup when a create change request is opened?
- Which feeder class and enhancement are used for Profit Center key auto-population in MDG?
- How do I implement implicit GET_DATA logic for Profit Center copy popup in SAP MDG?
- How do I generate a Profit Center number from SNRO in MDG copy popup?
- How do I keep the copied Profit Center data editable while auto-generating the key?