SAP MDG · UTILITIES

How do I read Business Partner change request entity data from SAP MDG using CL_USMD_MODEL_EXT in an ABAP utility method?

Use CL_USMD_MODEL_EXT to get the BP model instance, read the change request entities with USMD0_CS_FLD-CREQUEST, derive the BP partner from BP_HEADER, and then read the required BP sub-entities into dynamic tables created with CREATE_DATA_REFERENCE.

Use CL_USMD_MODEL_EXT to get the BP model instance, read the change request entities with USMD0_CS_FLD-CREQUEST, derive the BP partner from BP_HEADER, and then read the required BP sub-entities into dynamic tables created with CREATE_DATA_REFERENCE.

In SAP MDG Business Partner processing, the standard pattern is to obtain the BP model instance, determine the partner from BP_HEADER, and then read each required entity with read_char_value. The utility method shown below follows that pattern for BP_CENTRL, BP_CUSGEN, BP_SALES, BP_CUS_CC, BP_VENGEN, BP_PORG, and BP_COMPNY, using CREATE_DATA_REFERENCE to fill typed internal tables dynamically.

Process flow

  1. Get the BP model instance with cl_usmd_model_ext=>get_instance( ) and i_usmd_model = 'BP'.
  2. Call read_char_value for usmd0_cs_fld-crequest to get the CR entity list.
  3. Loop at the returned entities where usmd_entity_obj = 'BP_HEADER' and store the partner number.
  4. For each target entity, clear the data reference, call create_data_reference with i_fieldname set to the entity name and i_struct = 'KATTR'.
  5. Assign the returned reference to a field-symbol typed as ANY TABLE.
  6. Call read_char_value again for the entity using a selection table with the partner and BP_HEADER.
  7. Move the populated dynamic table to the corresponding exporting parameter.
  8. Repeat the same read pattern for each required BP entity.

Referenced tables

ObjectPurpose
USMD_T_CREQUEST_ENTITYHolds the entities returned for the change request before filtering BP_HEADER
USMD_TS_SELSelection table used to read CR and entity data with READ_CHAR_VALUE
USMD_S_SELSingle selection line type used in the related utility pattern
USMD1210Change request notes table used in the related utility method ADD_CREQUEST_NOTE

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1METHOD get_cr_data. 2 CONSTANTS: lc_model TYPE usmd_model VALUE 'BP'. 3 DATA: 4 lt_entities TYPE usmd_t_crequest_entity, 5 lo_model_ext TYPE REF TO if_usmd_model_ext, 6 lv_entity TYPE usmd_entity, 7 lv_entity_name TYPE usmd_fieldname, "#EC NOTEXT 8 lv_partner TYPE bu_partner, 9 lo_data TYPE REF TO data. 10 FIELD-SYMBOLS: <fs_t_centrl> TYPE ANY TABLE, 11 <fs_t_cusgen> TYPE ANY TABLE, 12 <fs_t_sales> TYPE ANY TABLE, 13 <fs_t_cus_company> TYPE ANY TABLE, 14 <fs_t_vengen> TYPE ANY TABLE, 15 <fs_t_porg> TYPE ANY TABLE, 16 <fs_t_company> TYPE ANY TABLE. 17 18 IF lo_model_ext IS NOT BOUND. 19 CALL METHOD cl_usmd_model_ext=>get_instance 20 EXPORTING 21 i_usmd_model = lc_model 22 IMPORTING 23 eo_instance = lo_model_ext. 24 ENDIF. 25 26 CALL METHOD lo_model_ext->read_char_value 27 EXPORTING 28 i_fieldname = usmd0_cs_fld-crequest 29 it_sel = VALUE usmd_ts_sel( ( sign = 'I' option = 'EQ' fieldname = usmd0_cs_fld-crequest low = iv_cr_number ) ) 30 IMPORTING 31 et_data = lt_entities. 32 LOOP AT lt_entities ASSIGNING FIELD-SYMBOL(<fs_entity>) 33 WHERE usmd_entity_obj = 'BP_HEADER'. "#EC CI_SORTSEQ 34 lv_partner = <fs_entity>-usmd_value. 35 ENDLOOP. 36* "Check the supplier detail need to export 37* "Get BP_CENTRL entity details 38 CLEAR: lo_data. 39 lv_entity = 'BP_CENTRL'. 40 lv_entity_name = lv_entity. 41 "GET data reference for bp_centrl 42 lo_model_ext->create_data_reference( 43 EXPORTING 44 i_fieldname = 'BP_CENTRL' " Field Name 45 i_struct = 'KATTR' " Structure 46 IMPORTING 47 er_data = lo_data 48 ). 49 ASSIGN lo_data->* TO <fs_t_centrl>. 50 "get bp_centrl entity value 51 CALL METHOD lo_model_ext->read_char_value 52 EXPORTING 53 i_fieldname = lv_entity_name 54 it_sel = VALUE usmd_ts_sel( ( sign = 'I' option = 'EQ' fieldname = lv_entity low = lv_partner ) 55 ( sign = 'I' option = 'EQ' fieldname = 'BP_HEADER' low = lv_partner ) ) 56 i_readmode = iv_read_mode 57 IMPORTING 58 et_data = <fs_t_centrl>. 59 et_bp_central = <fs_t_centrl>. 60 "get BP_CUSGEN entity details 61 CLEAR: lo_data. 62 lv_entity = 'BP_CUSGEN'. 63 lv_entity_name = lv_entity. 64 "GET data reference for bp_vengen 65 lo_model_ext->create_data_reference( 66 EXPORTING 67 i_fieldname = 'BP_CUSGEN' " Field Name 68 i_struct = 'KATTR' " Structure 69 IMPORTING 70 er_data = lo_data 71 ). 72 ASSIGN lo_data->* TO <fs_t_cusgen>. 73 "get BP_CUSGEN entity value 74 CALL METHOD lo_model_ext->read_char_value 75 EXPORTING 76 i_fieldname = lv_entity_name 77 it_sel = VALUE usmd_ts_sel( ( sign = 'I' option = 'EQ' fieldname = lv_entity low = lv_partner ) 78 ( sign = 'I' option = 'EQ' fieldname = 'BP_HEADER' low = lv_partner ) ) 79 i_readmode = iv_read_mode 80 IMPORTING 81 et_data = <fs_t_cusgen>. 82 et_bp_cusgen = <fs_t_cusgen>. 83 84 "get BP_SALES entity details 85 CLEAR: lo_data. 86 lv_entity = 'BP_SALES'. 87 lv_entity_name = lv_entity. 88 "GET data reference for bp_SALES 89 lo_model_ext->create_data_reference( 90 EXPORTING 91 i_fieldname = 'BP_SALES' " Field Name 92 i_struct = 'KATTR' " Structure 93 IMPORTING 94 er_data = lo_data 95 ). 96 ASSIGN lo_data->* TO <fs_t_sales>. 97 "get BP_SALES entity value 98 CALL METHOD lo_model_ext->read_char_value 99 EXPORTING 100 i_fieldname = lv_entity_name 101 it_sel = VALUE usmd_ts_sel( ( sign = 'I' option = 'EQ' fieldname = lv_entity low = lv_partner ) 102 ( sign = 'I' option = 'EQ' fieldname = 'BP_HEADER' low = lv_partner ) ) 103 i_readmode = iv_read_mode 104 IMPORTING 105 et_data = <fs_t_sales>. 106 et_bp_sales = <fs_t_sales>. 107 "get BP_CUS_CC entity details 108 CLEAR: lo_data. 109 lv_entity = 'BP_CUS_CC'. 110 lv_entity_name = lv_entity. 111 "GET data reference for bp_CUS_CC 112 lo_model_ext->create_data_reference( 113 EXPORTING 114 i_fieldname = 'BP_CUS_CC' " Field Name 115 i_struct = 'KATTR' " Structure 116 IMPORTING 117 er_data = lo_data 118 ). 119 ASSIGN lo_data->* TO <fs_t_cus_company>. 120 "get BP_CUS_CC entity value

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

Related questions and keywords

Alternative questions

  • How can I fetch BP_HEADER, BP_CENTRL, BP_CUSGEN, BP_SALES, BP_CUS_CC, BP_VENGEN, BP_PORG, and BP_COMPNY data from a change request?
  • What is the ABAP pattern to read MDG Business Partner change request entities by CR number?
  • How do I build a reusable get_cr_data method for SAP MDG Business Partner workflow data?

Possible questions

  • How do I read BP MDG CR data by change request number?
  • What is the ABAP code to extract BP entity data from a change request?
  • How do I use cl_usmd_model_ext=>get_instance and read_char_value for MDG BP entities?
  • How can I populate custom structures from MDG Business Partner CR entities?
  • How do I adapt the BP change request data reader for workflow or approval logic?

Keywords

SAP MDGBusiness PartnerCL_USMD_MODEL_EXTREAD_CHAR_VALUECREATE_DATA_REFERENCEUSMD_T_CREQUEST_ENTITYUSMD0_CS_FLD-CREQUESTBP_HEADERBP_CENTRLBP_CUSGENBP_SALESBP_CUS_CCBP_VENGENBP_PORGBP_COMPNYABAP