SAP MDG · UTILITIES
How do I add a note to an SAP MDG Change Request programmatically?
To add a note to an SAP MDG Change Request in model BP, read and validate the CR with CL_USMD_CREQUEST_API, build a USMD1210 row, fill MANDT, USMD_CREQUEST, USMD_NCREATED_AT, USMD_NCREATED_BY, and USMD_NOTE, then insert the record. The provided example uses user SAP_WFRT and a short WAIT before the insert.
To add a note to an SAP MDG Change Request in model BP, read and validate the CR with CL_USMD_CREQUEST_API, build a USMD1210 row, fill MANDT, USMD_CREQUEST, USMD_NCREATED_AT, USMD_NCREATED_BY, and USMD_NOTE, then insert the record. The provided example uses user SAP_WFRT and a short WAIT before the insert.
In SAP MDG, a programmatic Change Request note can be written by validating the CR through CL_USMD_CREQUEST_API and then inserting a record into USMD1210. The example for model BP fills the CR number, timestamp, creator SAP_WFRT, and note text, then writes the row to the note table.
Process flow
- Get the Change Request instance with CL_USMD_CREQUEST_API=>get_instance.
- Read the Change Request with read_crequest to confirm it exists.
- Prepare a USMD1210 work area.
- Fill MANDT,
USMD_CREQUEST,USMD_NCREATED_AT,USMD_NCREATED_BY, andUSMD_NOTE. - Insert the row into USMD1210.
- Handle CX_USMD_GOV_API for API-related errors.
Referenced tables
| Object | Purpose |
|---|---|
USMD1210 | Stores Change Request notes / audit comments. |
ILLUSTRATIVE ABAP SAMPLE
Source ABAP example
Exact relevant implementation excerpt from the knowledge document.
1METHOD add_crequest_note.
2
3 DATA:
4 lv_ts TYPE timestamp,
5 ls_creq_note TYPE usmd1210,
6 ls_crequest TYPE usmd_s_crequest.
7
8 TRY.
9 CALL METHOD cl_usmd_crequest_api=>get_instance
10 EXPORTING
11 iv_crequest = iv_crequest_id
12 iv_model_name = 'BP'
13 IMPORTING
14 re_inst_crequest_api = DATA(lo_crequest).
15
16 IF lo_crequest IS BOUND.
17 CALL METHOD lo_crequest->read_crequest
18 IMPORTING
19 es_crequest = ls_crequest. " Change Request
20* lo_crequest->add_note(
21* EXPORTING
22* iv_note = iv_note
23* ).
24
25 GET TIME STAMP FIELD lv_ts.
26
27 ls_creq_note-mandt = sy-mandt.
28 ls_creq_note-usmd_crequest = iv_crequest_id.
29 ls_creq_note-usmd_ncreated_at = lv_ts.
30 ls_creq_note-usmd_ncreated_by = 'SAP_WFRT'.
31 ls_creq_note-usmd_note = iv_note.
32
33 WAIT UP TO 1 SECONDS.
34 INSERT INTO usmd1210 VALUES ls_creq_note. "#EC CI_SUBRC
35
36 ENDIF.
37 CATCH cx_usmd_gov_api.
38
39 ENDTRY.
40
41ENDMETHOD.The remaining configuration, implementation details, and testing guidance continue from this answer more…
Related questions and keywords
Alternative questions
- How can I insert a CR note in SAP MDG using ABAP?
- Which API or table can be used to write an MDG Change Request note?
- How do I add an audit note to a BP model Change Request?
Possible questions
- How do I add a note to an SAP MDG Change Request programmatically?
- How can I insert a CR note in SAP MDG using ABAP?
- Which API or table can be used to write an MDG Change Request note?
- How do I add an audit note to a BP model Change Request?
- What fields must be filled in USMD1210 for a note entry?