SAP MDG · VALIDATION DERIVATION

How do I implement vendor classification derivation in SAP MDG BP-to-vendor conversion?

Use the derivation logic in the BP-to-vendor conversion exit to read BP header and custom BP data from the MDG change request, then default BP_VENCLA and BP_VENVAL only when the classification characteristics are initial. The sample uses BP_HEADER, ZBP_BUDET, KLAH, and CABN to derive vendor class and characteristic values, and writes them back with i_io_write_data.

Use the derivation logic in the BP-to-vendor conversion exit to read BP header and custom BP data from the MDG change request, then default BP_VENCLA and BP_VENVAL only when the classification characteristics are initial. The sample uses BP_HEADER, ZBP_BUDET, KLAH, and CABN to derive vendor class and characteristic values, and writes them back with i_io_write_data.

The sample derivation method reads the current MDG change request context, loads BP header and related entity data, and then defaults vendor classification data for BP_VENCLA and BP_VENVAL. It derives the vendor class from class `VENDOR_SELECTION`, and characteristic values such as `VENDOR_MATERIAL_GROUP` and `VENDOR_CAPABILITY` from custom BP data (`ZBP_BUDET`) before calling `i_io_write_data` to persist the derived entities.

Process flow

  1. Read the current change request context from `cl_usmd_app_context`.
  2. Load `BP_HEADER` and related entity data with `i_io_model->read_entity_data_all`.
  3. Filter the header records to BP records using `BU_TYPE = 2`.
  4. Read custom data from `ZBP_BUDET` and map it to `ls_ztecustom`.
  5. Derive `BP_VENCLA` from class `VENDOR_SELECTION` and `BP_VENVAL` from characteristics `VENDOR_MATERIAL_GROUP` and `VENDOR_CAPABILITY`.
  6. Write derived rows back with `i_io_write_data->write_data`.
  7. If process `SUP2` is active, update company and purchasing-org fields from the custom business-unit and purchasing-department values.

Referenced tables

ObjectPurpose
KLAHRead class internal number `CLINT` for class `VENDOR_SELECTION`.
CABNRead characteristic internal number `ATINN` for `VENDOR_MATERIAL_GROUP` and `VENDOR_CAPABILITY`.
ZMDG_SUP_CR_ACGRMap CR type and BP grouping to partner type.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1* Purpose: Derive vendor classification-related defaults for the BP to vendor conversion. 2 3 METHOD derive_vendor_class. 4 CONSTANTS: 5 lc_headr TYPE usmd_entity VALUE 'BP_HEADER', 6 lc_header TYPE usmd_fieldname VALUE 'BP_HEADER', 7 lc_centrl TYPE usmd_entity VALUE 'BP_CENTRL', 8 lc_compny TYPE usmd_entity VALUE 'BP_COMPNY', 9 lc_bpporg TYPE usmd_entity VALUE 'BP_PORG', 10 lc_postal TYPE usmd_entity VALUE 'AD_POSTAL', 11 lc_vengen TYPE usmd_entity VALUE 'BP_VENGEN', 12 lc_identity TYPE usmd_entity VALUE 'BP_IDNUM', 13 lc_ztecus TYPE usmd_entity VALUE 'ZBP_BUDET', 14 lc_venval TYPE usmd_entity VALUE 'BP_VENVAL', 15 lc_vencla TYPE usmd_entity VALUE 'BP_VENCLA', 16 lc_address TYPE usmd_entity VALUE 'ADDRESS'. 17 18 DATA: 19 lo_app_context TYPE REF TO if_usmd_app_context, 20 lo_data_r TYPE REF TO data, 21 lv_crequest TYPE usmd_crequest, 22 lt_data_entity TYPE usmd_ts_data_entity, 23 ls_data_entity TYPE usmd_sx_data_entity, 24 ls_bpheader TYPE /mdgbp/_s_bp_es_bp_header, 25 lt_bpcompny TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_compny, 26 ls_bpcompny TYPE /mdgbpx/_s_bp_es_bp_compny, 27 lt_bpporg TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_porg, 28 lt_bpporg1 TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_porg, 29 lt_centrl TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_centrl, 30 ls_centrl TYPE /mdgbpx/_s_bp_es_bp_centrl, 31 ls_bpporg TYPE /mdgbpx/_s_bp_es_bp_porg, 32 ls_bpporg1 TYPE /mdgbpx/_s_bp_es_bp_porg, 33 ls_bpporg2 TYPE /mdgbpx/_s_bp_es_bp_porg, 34 lt_adpostal TYPE STANDARD TABLE OF /mdgbp/_s_bp_pp_ad_postal, 35 ls_adpostal TYPE /mdgbp/_s_bp_pp_ad_postal, 36 lt_identity TYPE STANDARD TABLE OF /mdgbp/_s_bp_es_bp_idnum, 37 ls_identity TYPE /mdgbp/_s_bp_es_bp_idnum, 38 ls_bp_centrl TYPE /mdgbp/_s_bp_pp_bp_centrl, 39 lt_bp_centrl LIKE TABLE OF ls_bp_centrl, 40 ls_bp_vengen TYPE /mdgbpx/_s_bp_pp_bp_vengen, 41 lt_bp_vengen LIKE TABLE OF ls_bp_vengen, 42 ls_bp_porg TYPE /mdgbpx/_s_bp_pp_bp_porg, 43 lt_bp_porg LIKE TABLE OF ls_bp_porg, 44 lt_ztecustom TYPE STANDARD TABLE OF zmdgbp_s_bp_pp_zbp_budet, 45 ls_ztecustom TYPE zmdgbp_s_bp_pp_zbp_budet, 46 lt_bpvenval TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_venval, 47 ls_bpvenval TYPE /mdgbpx/_s_bp_es_bp_venval, 48 lt_bpvencla TYPE STANDARD TABLE OF /mdgbpx/_s_bp_es_bp_vencla, 49 ls_bpvencla TYPE /mdgbpx/_s_bp_es_bp_vencla, 50 lt_address TYPE STANDARD TABLE OF /mdgbp/_s_bp_es_address, 51 ls_address TYPE /mdgbp/_s_bp_es_address, 52 lt_filter TYPE usmd_t_entity, 53 wa_filter LIKE LINE OF lt_filter, 54 lo_att_data TYPE REF TO data, 55 lo_att TYPE REF TO cl_abap_structdescr, 56 lr_write_error TYPE REF TO cx_usmd_write_error, 57 lt_attribute TYPE usmd_ts_fieldname, 58 lv_land1 TYPE land1, 59 lv_ekorg TYPE ekorg, 60 lv_atinn_char TYPE string. 61 62 FIELD-SYMBOLS: <fs_lt_data> TYPE SORTED TABLE, 63 <fs_ls_data> TYPE any, 64 <fs_t_data_bp_compny> TYPE ANY TABLE, 65 <fs_t_data_bp_porg> TYPE ANY TABLE, 66 <fs_component> TYPE abap_compdescr. 67*================================================* 68 lo_app_context = cl_usmd_app_context=>get_context( ). 69 CHECK lo_app_context IS BOUND. 70 lv_crequest = lo_app_context->mv_crequest_id. 71 DATA(lv_crtype) = lo_app_context->mv_crequest_type. 72 DATA(lv_step) = lo_app_context->mv_crequest_step. 73 74 75 i_io_model->read_entity_data_all( EXPORTING i_fieldname = 'BP_HEADER' 76 if_active = abap_false 77 i_crequest = lv_crequest 78 IMPORTING et_data_entity = lt_data_entity ). 79 CHECK lt_data_entity IS NOT INITIAL. 80 81 READ TABLE lt_data_entity INTO ls_data_entity WITH KEY usmd_entity = lc_headr 82 usmd_entity_cont = space 83 struct = 'KATTR'. 84 IF sy-subrc = 0. 85 CLEAR lo_data_r. 86 lo_data_r = ls_data_entity-r_t_data. 87 ASSIGN lo_data_r->* TO <fs_lt_data>. 88 LOOP AT <fs_lt_data> ASSIGNING <fs_ls_data>. 89 ASSIGN COMPONENT 'BU_TYPE' OF STRUCTURE <fs_ls_data> TO FIELD-SYMBOL(<fs_bu_type>). 90 IF <fs_bu_type> IS ASSIGNED AND <fs_bu_type> = 2. " Insert by SAMAR - 25/07/2024 -> Check and update classification only for BP. 91 MOVE-CORRESPONDING <fs_ls_data> TO ls_bpheader. 92 ENDIF. 93 ENDLOOP. 94 ENDIF. 95 96 97 READ TABLE lt_data_entity INTO ls_data_entity WITH KEY usmd_entity = lc_headr 98 usmd_entity_cont = lc_vengen. 99 IF sy-subrc = 0. 100 CLEAR lo_data_r. 101 lo_data_r = ls_data_entity-r_t_data. 102 ASSIGN lo_data_r->* TO <fs_lt_data>. 103 LOOP AT <fs_lt_data> ASSIGNING <fs_ls_data>. 104 MOVE-CORRESPONDING <fs_ls_data> TO ls_bp_vengen. 105 APPEND ls_bp_vengen TO lt_bp_vengen. 106 CLEAR: ls_bp_vengen. 107 ENDLOOP. 108 ENDIF. 109 110 IF lt_bp_vengen IS NOT INITIAL. 111*** Change and Insert by Samar. 112* Defaulting of Characteristics value with Commodity code 113******* READ TABLE lt_data_entity INTO ls_data_entity WITH KEY usmd_entity = lc_headr 114******* usmd_entity_cont = lc_ztecus. 115******* IF sy-subrc = 0. 116******* CLEAR lo_data_r. 117******* lo_data_r = ls_data_entity-r_t_data. 118******* ASSIGN lo_data_r->* TO <fs_lt_data>. 119******* LOOP AT <fs_lt_data> ASSIGNING <fs_ls_data>. 120******* MOVE-CORRESPONDING <fs_ls_data> TO ls_ztecustom.

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

Related questions and keywords

Alternative questions

  • How is vendor classification defaulted during BP to vendor conversion in MDG?
  • Which BAdI or method should I use to derive BP_VENCLA and BP_VENVAL in MDG?
  • How do I populate vendor classification characteristics from BP custom data in MDG?

Possible questions

  • How do I implement vendor classification derivation in SAP MDG BP-to-vendor conversion?
  • How do I populate BP_VENCLA and BP_VENVAL during BP conversion to vendor?
  • Which method derives vendor classification defaults from custom BP data in MDG?
  • How do I update vendor classification and characteristics based on ZBP_BUDET?
  • How do I default vendor material group and capability values in MDG?

Keywords

SAP MDGBP to vendor conversionDERIVE_ENTITYvendor classificationBP_VENCLABP_VENVALBP_HEADERBP_CENTRLBP_COMPNYBP_PORGZBP_BUDETCABNKLAHUSMD_RULE_SERVICEIF_USMD_APP_CONTEXT