Enterprise Resource Planning Blog Posts by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Çınar
Explorer
3,098

This article outlines our process of reading BRF+ decision tables of DQM derivation scenarios and using them in MDG cross-entity BAdI to apply derivation scenarios in the initial step of MDG workflows.

Background

Data Quality Management (DQM) is an alternative approach to classical BAdI’s. It enables users to create derivation and validation rules with less coding. Integrated with MDG, it operates within MDG rule-based workflows.

In our case, we aim to demonstrate a defaulting rule in MDG through a DQM derivation scenario.

Problem

Unfortunately, DQM doesn’t trigger its derivation logic at step ‘00’ since it setup in a way that an MDG background step triggers it by BAdI USMD_SSW_SYSTEM_METHOD_CALLER. Therefore, those rules can only be applied after submitting the change request only. However, we wanted to make use of DQM also in the initial step of the MDG workflow, i.e., by the time a new change request is created. 

Introduction

This blog presents a potential solution for implementing defaulting/derivation rules configured within DQM rules' decision tables. Leveraging DQM derivation rules, we'll adopt an alternate approach by utilizing these decision tables to enforce derivation scenarios within BAdI: USMD_RULE_SERVICE_CROSS_ET, which is typically triggered during the initial change request Step '00'.

It's essential to note that while this blog offers guidance on implementation, it doesn't delve into the design aspect of DQM derivation rules.

Scenario and Summary of the Solution

 

For the MDG-M CR-type, our aim is to activate defaulting rules and manage them through DQM. To initiate these rules at the outset of the CR process, we'll employ a function module to access the decision tables associated with these rules created in DQM. This step is crucial because while the BRF+ functions generated by DQM produce Boolean outcomes, we require data for populating the CR. Hence, we can't rely solely on these automated BRF+ functions.

Our approach involves extracting insights from the BRF+ decision tables to enact derivations and populate fields within the MDG UI during the initial CR phase. We'll achieve this by writing the data retrieved from the decision tables during the invocation of the MDG cross-entity BAdI USMD_RULE_SERVICE_CROSS_ET.

 

Step 1: Create the DQM rules.

DQM Derivation Scenario scope


Picture1.jpg
Figure 1 – DQM Derivation Scenario Scope

Picture2.png
Figure 2 – DQM Derivation Scenario Rules

1.1 The First rule 

Picture3.png
Figure 3 Condition and Result Fields of Rule ID: DEFAULT_MEINS_MAKTL

The decision table of the first rule
Picture4.png
Figure 4 – Decision Table of Rule ID: DEFAULT_MEINS_MAKTL

 

1.2 The second rule

Picture5.png
Figure 5 - Condition and Result Fields of Rule ID: DEFAULT_SALES_DATA

Decision Table of the second rule

Picture6.png
Figure 6 - Decision Table of Rule ID: DEFAULT_SALES_DATA

 

Step 2: Create Function Module

This function module will play a crucial role in retrieving the result tables generated by BRF+ decision tables, which are crafted through DQM rules. With this function module, we will read decision tables so we can apply defaulting rules formulated in those DQM Rules.

The Function Module is called in cross-entity BAdI Implementing Class and consumes BRF+ API classes. It constructs the result table of the decision tables.

For instance, consider Figure 7, illustrating the result table of the DQM rule: DEFAULT_SALES_DATA, as depicted in Figure 6.  We will use this table data in cross-entity BAdI where desired fields in MDG-UI get populated.

The code is provided in Step 4, and explanatory comments exist in the code.

Picture7.png
Figure 7 – An example of the exporting parameter ET_DECISION_TABLE. See Figure 6.

Imports

 

Picture8.png
Figure 8 – Importing Parameters of the Function Module: ZFM_READ_DT_RESULT

iv_brf_app_id: BRF+ Application ID of DQM Derivation Rule
iv_brf_dt_id: Decision Table ID of DQM Derivation Rule

Exports

Picture9.png
Figure 9 – Exporting Parameters of the Function Module: ZFM_READ_DT_RESULT

et_decision_table: Decision Table
ev_column_count: Number of columns
et_comp_tab: Data Elements of columns

 

Step 3: Create a BRF+ Application

We will centrally control all the DQM defaulting scenarios in this BRF+ App. Specifically this app stores and gets all the key information such as BRF+ IDs and Decision Table IDs which are importing parameters of the Function Module: ZFM_READ_DT_RESULT.

Additionally, we will maintain the mapping information that correlates MDG Data Model attributes with the fields used in DQM Rules. This mapping is crucial because, although DQM Rules work using ERP Table fields, it is necessary to identify corresponding MDG attributes to derive these fields accurately.

There are two decision tables in this BRF+ app, DQM_ID_DT (See Figure 9 – 10 - 11) and DQM_ATTR_MAPPING (see Figure 12 – 13). The former table is responsible for controlling the defaulting rules, while the latter holds the mappings information between staging area attributes and fields of ERP Tables.

Using these two decision tables, with the help of the above function module, we will be able to implement defaulting rules dynamically without hard coding.

Necessary technical details for columns of decision tables will be provided in subsections.

3.1 Usage and fields of the decision table: DQM_ID_DT

This decision table is used for getting BRF+ ID’s and data model entity types. BRF+ ID’s will be inputs of the function and we will use entity types to create data reference structures in cross-entity BAdI to populate CR. Also, we have created a scope of Derivation Scenarios concerning Change Request Types, so we filter the IDs considering CR Types.

DDIC Types of Columns

Condtion Columns

data_model type usmd_model           

cr_type type usmd_crequest_type

Result Columns

entity_type type usmd_entity

sqnr_number type usmd_seqnr

brf_app_id type fdt_uuid

brf_dt_id type fdt_uuid

is_active type abap_boolean

Picture10.png
Figure 10 – Table Settings for the Decision Table: DQM_ID_DT

Picture11.png
Figure 11 – Data of the Decision Table DQM_ID_DT (continuing)

Picture12.png
Figure 12 - Data of the Decision Table DQM_ID_DT

3.2 BRF+ Function GET_IDS_FUNC

Function for processing the decision table: DQM_ID_DT

Picture13.png
Figure 13 - Function for processing the decision table: DQM_ID_DT

3.3 Usage and fields of the decision table DQM_ATTR_MAPPING

This decision table will provide the necessary mappings between data model attributes and fields used in rules. Here, attribute stands for data model attribute, and fieldname stands for data element types of fields.

We will use this mapping information to dynamically match the components of the data structures in cross-entity BAdI. In other words, first, we will read the data we want to derive. Then we will write it to the respective component of the buffer structure using the corresponding attribute name.

Picture14.png
Figure 14 Decision Table DQM_ATTR_MAPPING

Picture20.png
Figure 15 A part of the code explaining mapping between data model attributes and fields used in rules.

DDIC Types of Columns

Condition Column

data_model type usmd_model

Result Columns

entity_type type usmd_entity

attribute type usmd_attribute

fieldname type fieldname

Picture15.png
Figure 16 Table Settings for Decision Table: DQM_ATTR_MAPPING

3.4 BRF+  Function GET_ATTR_MAPPING

Function for processing the decision table: DQM_ATTR_MAPPING

Picture16.png
Figure 17 Function Context for processing the decision table: DQM_ATTR_MAPPING

Step 4: The Codes

There are two code blocks here. One of them is the source code of the implementing class of the cross-entity BAdI. The other one is Function Module: ZFM_READ_DT_RESULT.

Create a function module and a BAdI implementation using BAdI Definition: USMD_RULE_SERVICE_CROSS_ET. Copy and paste the implementing class code. Do not forget to adjust data declarations and variables according to yourself.

Note that explanations of necessary steps in codes are provided in comment lines.

 

 

 

CLASS zcl_mm_dqm_defaulting DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.

    INTERFACES if_badi_interface .
    INTERFACES if_ex_usmd_rule_service2 .


  PROTECTED SECTION.

    TYPES:
      BEGIN OF ty_s_result,
        sqnr_number TYPE usmd_seqnr,
        entity_type TYPE usmd_entity,
        brf_app_id  TYPE fdt_uuid,
        brf_dt_id   TYPE fdt_uuid,
        is_active   TYPE abap_boolean,
      END OF ty_s_result .
    TYPES:
      ty_t_result TYPE TABLE OF ty_s_result .
    TYPES:
      BEGIN OF ty_s_attr_map,
        entity_type TYPE usmd_entity,
        attribute   TYPE usmd_attribute,
        fieldname   TYPE fieldname,
      END OF ty_s_attr_map .
    TYPES:
      ty_t_attr_map TYPE STANDARD TABLE OF ty_s_attr_map WITH NON-UNIQUE KEY entity_type fieldname .

    CONSTANTS gv_get_ids_func TYPE if_fdt_types=>id VALUE 'Insert ID of GET_IDS_FUNC here' ##NO_TEXT.
    CONSTANTS gv_get_attr_mapping TYPE if_fdt_types=>id VALUE 'Insert ID of GET_ATTR_MAPPING here' ##NO_TEXT.
    DATA gt_attr_mapping TYPE ty_t_attr_map .

    METHODS get_brf_ids
      IMPORTING
        !iv_data_model TYPE usmd_model
        !iv_cr_type    TYPE usmd_crequest_type
      EXPORTING
        !et_result_tab TYPE ty_t_result .
    METHODS get_attr_mapping
      IMPORTING
        !iv_data_model   TYPE usmd_model
      EXPORTING
        !et_attr_mapping TYPE ty_t_attr_map .
  PRIVATE SECTION.
ENDCLASS.



CLASS zcl_mm_dqm_defaulting IMPLEMENTATION.

  

  METHOD if_ex_usmd_rule_service2~derive.
    DATA: lo_context TYPE REF TO if_usmd_app_context.
    DATA: lt_decision_tab TYPE REF TO data.
    DATA: lt_data_ins TYPE REF TO data.
    DATA: lv_material TYPE matnr.
    DATA: lt_data_write TYPE REF TO data.
    DATA: ls_data_write TYPE REF TO data.
    DATA: lt_comp_tab TYPE cl_abap_structdescr=>component_table.
    DATA: ls_attr_map TYPE ty_s_attr_map.
    DATA: lt_attr_map TYPE TABLE OF ty_s_attr_map.
    DATA: ls_selopt TYPE selopt.
    DATA: lt_selopt TYPE TABLE OF selopt.
    DATA: lv_column_count TYPE i.
    DATA: lt_container TYPE cl_abap_structdescr=>component_table.
    DATA: lo_dqm_def TYPE REF TO zcl_mm_dqm_defaulting.

    FIELD-SYMBOLS: <fs_data_ins_tab> TYPE ANY TABLE.
    FIELD-SYMBOLS: <fs_data_ins_str> TYPE any.
    FIELD-SYMBOLS: <lv_any> TYPE any.
    FIELD-SYMBOLS: <fs_decision_tab> TYPE ANY TABLE.
    FIELD-SYMBOLS: <fs_write_tab> TYPE ANY TABLE.
    FIELD-SYMBOLS: <fs_any_de> TYPE any.



    "get app context.
    lo_context = cl_usmd_app_context=>get_context( ).
    CHECK lo_context->mv_crequest_step = '00'.
    "Get BRF+ and Decision Table ID's

    me->get_brf_ids(
                EXPORTING
                  iv_data_model = 'MM'
                  iv_cr_type    = lo_context->mv_crequest_type
                IMPORTING
                  et_result_tab = DATA(lt_fdt_ids) ).
    "If lt_fdt_ids is initial, there is no DQM Defaulting Rule to be implemented to current CR
    CHECK lt_fdt_ids IS NOT INITIAL.

    "Get mappings between staging attributes and ddic types and keep them in a global table
    me->get_attr_mapping(
                        EXPORTING
                          iv_data_model   = 'MM'
                        IMPORTING
                          et_attr_mapping = gt_attr_mapping  ).




    "get material key.
    io_changed_data->read_data(
                     EXPORTING
                       i_entity      = 'MATERIAL'
                       i_struct      = if_usmd_model_ext=>gc_struct_key_attr
                     IMPORTING
                       er_t_data_ins = lt_data_ins ).

    CHECK lt_data_ins IS NOT INITIAL.
    ASSIGN lt_data_ins->* TO <fs_data_ins_tab>.

    CHECK <fs_data_ins_tab> IS ASSIGNED.

    LOOP AT <fs_data_ins_tab> ASSIGNING <fs_data_ins_str>.
      ASSIGN COMPONENT 'MATERIAL' OF STRUCTURE <fs_data_ins_str> TO <lv_any>.
      lv_material = <lv_any>.
    ENDLOOP.

    LOOP AT lt_fdt_ids INTO DATA(ls_fdt_ids).

      "construct reference structure and table to write to buffer
      lt_data_write = io_write_data->create_data_reference( i_entity = ls_fdt_ids-entity_type i_struct = 'KATTR' ).
      ASSIGN lt_data_write->* TO <fs_write_tab>.
      CREATE DATA ls_data_write LIKE LINE OF <fs_write_tab>.
      ASSIGN ls_data_write->* TO FIELD-SYMBOL(<fs_write_str>).

      "Write key
      ASSIGN COMPONENT 'MATERIAL' OF STRUCTURE <fs_write_str> TO <lv_any>.
      <lv_any> = lv_material.


      "Read Decision Table Result of DQM Rule
      CALL FUNCTION 'ZFM_READ_DT_RESULT'
        EXPORTING
          iv_brf_app_id     = ls_fdt_ids-brf_app_id
          iv_brf_dt_id      = ls_fdt_ids-brf_dt_id
        IMPORTING
          et_decision_table = lt_decision_tab
          ev_column_count   = lv_column_count
          et_comp_tab       = lt_comp_tab.

      CHECK lt_decision_tab IS NOT INITIAL.
      ASSIGN lt_decision_tab->* TO <fs_decision_tab>.



      LOOP AT <fs_decision_tab> ASSIGNING FIELD-SYMBOL(<fs_defaulting_rule>).

        LOOP AT lt_comp_tab INTO DATA(ls_comp_str).
          "Get attribute mappings
          READ TABLE gt_attr_mapping INTO ls_attr_map WITH KEY entity_type = ls_fdt_ids-entity_type fieldname = ls_comp_str-name.
          "match staging area attributes and data element types of components of decision table
          ASSIGN COMPONENT ls_attr_map-fieldname OF STRUCTURE <fs_defaulting_rule> TO <fs_any_de>.
          ASSIGN COMPONENT ls_attr_map-attribute OF STRUCTURE <fs_write_str> TO <lv_any>.
          <lv_any> = <fs_any_de>.
        ENDLOOP.
        INSERT <fs_write_str> INTO TABLE <fs_write_tab>.
      ENDLOOP.
      "write to buffer
      TRY.
          io_write_data->write_data( i_entity = ls_fdt_ids-entity_type it_data = <fs_write_tab> ).
        CATCH cx_usmd_write_error INTO DATA(lcx_usmd_write_error).
      ENDTRY.
      CLEAR: lt_data_write, lt_attr_map.
    ENDLOOP.


    CLEAR gt_attr_mapping.
  ENDMETHOD.


  METHOD get_brf_ids.


    DATA:lv_timestamp  TYPE timestamp,
         lt_name_value TYPE abap_parmbind_tab,
         ls_name_value TYPE abap_parmbind,
         lr_data       TYPE REF TO data,
         lx_fdt        TYPE REF TO cx_fdt,
         la_data_model TYPE if_fdt_types=>element_text,
         la_cr_type    TYPE if_fdt_types=>element_text.
    FIELD-SYMBOLS <la_any> TYPE any.

    GET TIME STAMP FIELD lv_timestamp.

    ls_name_value-name = 'DATA_MODEL'.
    la_DATA_MODEL = iv_data_model.
    GET REFERENCE OF la_DATA_MODEL INTO lr_data.
    ls_name_value-value = lr_data.
    INSERT ls_name_value INTO TABLE lt_name_value.
    CLEAR ls_name_value.
****************************************************************************************************
    ls_name_value-name = 'CR_TYPE'.
    la_CR_TYPE = iv_cr_type.
    GET REFERENCE OF la_CR_TYPE INTO lr_data.
    ls_name_value-value = lr_data.
    INSERT ls_name_value INTO TABLE lt_name_value.
    CLEAR ls_name_value.

    cl_fdt_function_process=>get_data_object_reference( EXPORTING iv_function_id      = gv_GET_IDS_FUNC
                                                                  iv_data_object      = '_V_RESULT'
                                                                  iv_timestamp        = lv_timestamp
                                                                  iv_trace_generation = abap_false
                                                        IMPORTING er_data             = lr_data ).
    ASSIGN lr_data->* TO <la_any>.
    TRY.
        cl_fdt_function_process=>process( EXPORTING iv_function_id = gv_GET_IDS_FUNC
                                                    iv_timestamp   = lv_timestamp
                                          IMPORTING ea_result      = <la_any>
                                          CHANGING  ct_name_value  = lt_name_value ).
      CATCH cx_fdt INTO lx_fdt.

    ENDTRY.

    MOVE-CORRESPONDING <la_any> TO et_result_tab.
    SORT et_result_tab BY sqnr_number ASCENDING.
    DELETE et_result_tab WHERE is_active = ''.


  ENDMETHOD.


  METHOD get_attr_mapping.

    DATA:lv_timestamp   TYPE timestamp,
         lt_name_value  TYPE abap_parmbind_tab,
         ls_name_value  TYPE abap_parmbind,
         lr_data        TYPE REF TO data,
         lx_fdt         TYPE REF TO cx_fdt,
         la_data_model  TYPE if_fdt_types=>element_text,
         la_entity_type TYPE if_fdt_types=>element_text.
    FIELD-SYMBOLS <la_any> TYPE any.

    GET TIME STAMP FIELD lv_timestamp.

    ls_name_value-name = 'DATA_MODEL'.
    la_DATA_MODEL = iv_data_model.
    GET REFERENCE OF la_DATA_MODEL INTO lr_data.
    ls_name_value-value = lr_data.
    INSERT ls_name_value INTO TABLE lt_name_value.
    CLEAR ls_name_value.

    cl_fdt_function_process=>get_data_object_reference( EXPORTING iv_function_id      = gv_GET_ATTR_MAPPING
                                                                  iv_data_object      = '_V_RESULT'
                                                                  iv_timestamp        = lv_timestamp
                                                                  iv_trace_generation = abap_false
                                                        IMPORTING er_data             = lr_data ).
    ASSIGN lr_data->* TO <la_any>.
    TRY.
        cl_fdt_function_process=>process( EXPORTING iv_function_id = gv_GET_ATTR_MAPPING
                                                    iv_timestamp   = lv_timestamp
                                          IMPORTING ea_result      = <la_any>
                                          CHANGING  ct_name_value  = lt_name_value ).
      CATCH cx_fdt INTO lx_fdt.

    ENDTRY.
    MOVE-CORRESPONDING <la_any> TO et_attr_mapping.
    SORT et_attr_mapping ASCENDING BY entity_type fieldname.
  ENDMETHOD.



ENDCLASS.

 

 

 

 

 

 

 

FUNCTION zfm_process_dt
  IMPORTING
    iv_brf_app_id TYPE if_fdt_types=>id
    iv_brf_dt_id TYPE if_fdt_types=>id
  EXPORTING
    et_decision_table TYPE REF TO data
    ev_column_count TYPE i
    et_cond_tab TYPE cl_abap_structdescr=>component_table
    et_comp_tab TYPE cl_abap_structdescr=>component_table.







  DATA: lref_decision_table TYPE REF TO   cl_fdt_decision_table.
  DATA: lo_factory        TYPE REF TO  if_fdt_factory.
  DATA: gc_appl_id  TYPE if_fdt_types=>id.
  DATA: lo_decision_tab TYPE REF TO if_FDT_DECISION_TABLE.
  DATA: lo_data_object TYPE REF TO if_fdt_data_object.
  DATA: lt_decision_table TYPE REF TO data.
  DATA:lts_column TYPE if_FDT_DECISION_TABLE=>ts_column.
  DATA: lts_row TYPE if_FDT_DECISION_TABLE=>ts_row_data.
  DATA: ls_row_data TYPE if_FDT_DECISION_TABLE=>s_row_data.
  DATA: lts_data TYPE if_FDT_DECISION_TABLE=>ts_table_data.
  DATA: ls_data TYPE if_FDT_DECISION_TABLE=>s_table_data.
  DATA: lv_row_count TYPE i.
  DATA: lt_comp_tab TYPE cl_abap_structdescr=>component_table.
  DATA: lt_cond_tab TYPE cl_abap_structdescr=>component_table.
  DATA: lt_column_tab TYPE cl_abap_structdescr=>component_table.
  DATA: ls_comp TYPE LINE OF cl_abap_structdescr=>component_table .
  DATA: ls_comp_tab LIKE LINE OF lt_comp_tab.
  DATA: ls_cond_tab LIKE LINE OF lt_cond_tab.
  DATA: ls_structure TYPE REF TO data.
  DATA: lv_column_count TYPE i.
  DATA: ls_any TYPE REF TO data ##NEEDED.
  DATA: lv_column_count2 TYPE i.
  DATA: lv_index TYPE i.
  DATA: lv_col_index TYPE i.

  FIELD-SYMBOLS: <fs_lv_value>  TYPE any,
                 <lv_any>       TYPE any,
                 <ls_structure> TYPE any.
*************************************************************************************
  "Get BRF+ Application ID and Decision Table ID

  lo_factory = cl_fdt_factory=>if_fdt_factory~get_instance( iv_brf_app_id ).

  lo_decision_tab ?= lo_factory->get_expression(
                            iv_id                 = iv_brf_dt_id                 " Universal Unique Identifier
*                          iv_expression_type_id =                  " Expression Type ID
                          ).
**************************************************************************************
  "Get BRF+ Decision Table Columns
  TRY.
      lo_decision_tab->get_columns(
      IMPORTING
      ets_column   = lts_column                 " columns of the table
      ).
    CATCH cx_fdt_input INTO DATA(lcx_fdt_input). " FDT: Invalid Input

  ENDTRY.
**************************************************************************************
  "Create Decision Table Structure and Table Types
  lv_column_count = 0.
  LOOP AT lts_column INTO DATA(ls_column).              "#EC CI_SORTSEQ
    "Get DDIC bindings of data objects used in decision tables

    lo_data_object ?= lo_factory->get_data_object(
                        iv_id               = ls_column-object_id                 " Universal Unique Identifier
                      ).
    TRY.
        lo_data_object->get_ddic_binding(
                        RECEIVING
                         rv_ddic_typename = DATA(lv_ddic_typename)  ).               " Name of Dictionary Type

      CATCH cx_fdt_input into lcx_fdt_input. " FDT: Invalid Input
    ENDTRY.

    IF ls_column-is_result = abap_true.
      ls_comp_tab-name = lv_ddic_typename.
      ls_comp_tab-type ?= cl_abap_datadescr=>describe_by_name( p_name = lv_ddic_typename ).
      APPEND ls_comp_tab TO lt_comp_tab.
      APPEND ls_comp_tab TO lt_column_tab.
      lv_column_count = lv_column_count + 1.
    ELSEIF ls_column-is_result = abap_false.
      ls_cond_tab-name = lv_ddic_typename.
      ls_cond_tab-type ?= cl_abap_datadescr=>describe_by_name( p_name = lv_ddic_typename ).
      APPEND ls_cond_tab TO lt_cond_tab.
      APPEND ls_cond_tab TO lt_column_tab.
    ENDIF.
  ENDLOOP.
  "number of result columns in decision table
  IF ev_column_count IS REQUESTED.
    ev_column_count = lv_column_count.
  ENDIF.
  "ddic types of decision table columns
  IF et_comp_tab IS REQUESTED.
    et_comp_tab = lt_comp_tab.
  ENDIF.
    IF et_cond_tab IS REQUESTED.
    et_cond_tab = lt_cond_tab.
  ENDIF.
  "Create structure whose components are decision table's columns
  TRY.
      cl_abap_structdescr=>create(
                            EXPORTING
                                p_components = lt_column_tab               " Component Table
                            RECEIVING
                                p_result     = DATA(ls_dt_row_type)   ).                " Structure Type Object

    CATCH cx_sy_struct_creation INTO DATA(lcx_sy_struct_creation). " Exception when creating a structure description
  ENDTRY.

  CREATE DATA ls_structure TYPE HANDLE ls_dt_row_type.



  "Create table type using above structure
  TRY.
      cl_abap_tabledescr=>create(
                            EXPORTING
                              p_line_type  =  ls_dt_row_type                  " Line Type
                            RECEIVING
                              p_result     = DATA(lt_result)                   " Result Type
      ).
    CATCH cx_sy_table_creation INTO DATA(lcx_st_table_creation). " Exception when Creating a Table Type
  ENDTRY.

  CREATE DATA et_decision_table TYPE HANDLE lt_result .
  ASSIGN et_decision_table->* TO FIELD-SYMBOL(<fs_decision_table>).
  CREATE DATA lt_decision_table LIKE <fs_decision_table>.
*****************************************************************************************************
  "Get rows of decision table
  TRY.
      lo_decision_tab->get_rows(
        IMPORTING
          ets_data       = lts_data                 " Table data for the requested rows
          ev_row_count   = lv_row_count                 " Row Count (number of rows available)
          ets_row_data   = lts_row                 " Data of rows (all columns)
      ).
    CATCH cx_fdt_input INTO lcx_fdt_input . " FDT: Invalid Input
  ENDTRY.

  ASSIGN ls_structure->* TO <ls_structure>.
  ASSIGN ls_any->* TO <ls_structure>.


  ASSIGN lt_decision_table->* TO FIELD-SYMBOL(<fs_result_tab>).

  "Populate the table
  LOOP AT lts_row INTO ls_row_data.

    LOOP AT ls_row_data-ts_cell_data INTO DATA(ls_cell_data).

      IF ls_cell_data-ts_range IS NOT INITIAL.
        IF lines( ls_cell_data-ts_range ) = 1.
          READ TABLE ls_cell_data-ts_range INTO DATA(ls_range) INDEX 1.
          ASSIGN ls_range-r_low_value->* TO <fs_lv_value>.
          READ TABLE lt_column_tab INTO ls_comp INDEX ls_cell_data-col_no.
          ASSIGN COMPONENT ls_comp-name OF STRUCTURE <ls_structure> TO <lv_any>.
          <lv_any> = <fs_lv_value>.
        ELSE.
          "Use Concenate statement to get cell data which contains multiple values if necessary.
        ENDIF.
      ELSEIF ls_cell_data-r_value IS NOT INITIAL.
        ASSIGN ls_cell_data-r_value->* TO <fs_lv_value>.
        READ TABLE lt_column_tab INTO ls_comp INDEX ls_cell_data-col_no.
        ASSIGN COMPONENT ls_comp-name OF STRUCTURE <ls_structure> TO <lv_any>.
        <lv_any> = <fs_lv_value>.
      ENDIF.

    ENDLOOP.
    INSERT <ls_structure> INTO TABLE <fs_result_tab> .

  ENDLOOP.
  <fs_decision_table> = <fs_result_tab>.





ENDFUNCTION.

 

 

 

Step 5: Testing

In this part, we will test our defaulting application.

Create a new change request.

Picture17.png
Figure 18 List of Available CR Types

As you can see, the desired fields are populated just after the CR screen is opened.

Picture18.png
Figure 19 A part of Material Basic Data UIBB.

Picture19.png
Figure 20 Distribution Chains UIBB.

 

Conclusion

In this blog, we have seen a possible workaround for implementing defaulting rules in the MDG initial step using a DQM derivation scenario. Since the standard DQM derivation logic is triggered by a background job ( BAdI: USMD_SSW_SYSTEM_METHOD_CALLER ), it is not possible to apply those rules in the initial MDG-M CR step. But this solution could be a possible workaround to do the job.

Thank you for reading.
Best Regards,

Çınar, Orkhan



1 Comment
Labels in this area