cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Incompatibilities between 2 transient TRQ items in S/4 Hana

petra_just
Active Participant
693

hi experts, we are trying to consolidate sales orders which have the same unloading point and the same incoterms 2 text. We have written a class that we have assigned at our incompatibility settings and assigned it in the freight unit building rule. The coding seems right. We get 2 values that we compare. We concatenate the 2 field contents and compare. But, even though the 2 values are correctly filled (see debugger screenshot), it will split or not split randomly.

In my below attached result, it has 2 different values, but it still consolidates the 2 sales orders.

Please help!

Thanks

Petra Hunger

METHOD inc_check.
"Petra Hunger, 13.05.21"This method shall be used with report /SCMTMS/SUBSEQUENT_FUB_LOGINT"it shall consolidate sales orders with the same unloading point and Incoterms text 2"and split them if they differ

  DATA: lr_request_inc      TYPE REF TO /scmtms/cl_pc_request_inc,

        lt_attr_name        TYPE /bobf/t_frw_name,
        lt_trq_item         TYPE /scmtms/t_trq_item_k,
        ls_incomp_values    TYPE  /scmtms/s_inc_definition,
        lt_boinst_key       TYPE /bobf/t_frw_key,
        et_bokey_dokey_data TYPE /scmtms/t_bokey_dokey_data,
        lv_do_bo_item       TYPE  /bobf/obm_node_key VALUE '80E0ED0A0C021DDE88859101A7FC12C6',
        ls_do_bo            TYPE /scmtms/s_cond_do_data_k,
        lt_do_bo_link       TYPE /scmtms/t_bokey_value,
        lo_trq_data         TYPE REF TO /scmtms/cl_trq_data,
        lv_value            TYPE char45,
        lv_value1           TYPE char45,
        lv_key              TYPE /bobf/conf_key,
        lv_key1             TYPE /bobf/conf_key.

  ls_do_bo-node_key = lv_do_bo_item.
  lo_trq_data = /scmtms/cl_fu_builder_helper=>get_trq_data_container( ).
  CHECK lines( it_request ) = 1.


  READ TABLE it_request INTO DATA(lr_request) INDEX 1 .
  CHECK sy-subrc = 0.


  lr_request_inc ?= lr_request.
  CHECK lr_request_inc IS BOUND.
  CHECK lr_request_inc->mt_trq_item IS NOT INITIAL.

  "put the trq item key into a table to be able to use the class to read teh transient data
  LOOP AT lr_request_inc->mt_trq_item ASSIGNING FIELD-SYMBOL(<ls_trq_item_key>).
    DATA(lv_trq_item) = <ls_trq_item_key>-key.
    APPEND VALUE #( key = lv_trq_item ) TO lt_boinst_key.
  ENDLOOP.

  READ TABLE lr_request_inc->mt_relev_inc_header ASSIGNING FIELD-SYMBOL(<s_relev_inc_header>) INDEX 1.
  IF sy-subrc <> 0.
    ASSERT 1 = 0.

  ENDIF.

  LOOP AT lt_boinst_key ASSIGNING FIELD-SYMBOL(<ls_boinst>).
    LOOP AT lo_trq_data->mt_d_trq_item ASSIGNING FIELD-SYMBOL(<ls_trq_item>) WHERE key = <ls_boinst>-key.
      DATA(lv_inco2)        = <ls_trq_item>-inc_transf_loc_n.
      DATA(lv_unload_point) = <ls_trq_item>-unload_point.
      CONCATENATE lv_inco2 lv_unload_point INTO lv_value.
      lv_key = <ls_trq_item>-key.

      IF lv_value1 IS NOT INITIAL AND lv_value <> lv_value1.
        ls_incomp_values-value_a          = lv_value1.
        ls_incomp_values-value_b          = lv_value.


* Get UUID for condition
        TRY.
            ls_incomp_values-cond_key_a = cl_system_uuid=>create_uuid_x16_static( ).
            ls_incomp_values-cond_key_b = cl_system_uuid=>create_uuid_x16_static( ).
          CATCH cx_uuid_error.  " Error Class for UUID Processing Errors
            ASSERT 1 = 0.
        ENDTRY.
        ls_incomp_values-incomp_uuid      = <s_relev_inc_header>-key.
        ls_incomp_values-violation_action = <s_relev_inc_header>-automatic_action.
        APPEND ls_incomp_values TO lr_request_inc->mt_incomp_values.


        INSERT VALUE #( cond_key  = ls_incomp_values-cond_key_a
                        boinstkey = lv_key1
                        value     = lv_value1 ) INTO TABLE lr_request_inc->mt_bokey_values_link.


        INSERT VALUE #( cond_key  = ls_incomp_values-cond_key_b
                        boinstkey = lv_key
                        value     = lv_value ) INTO TABLE lr_request_inc->mt_bokey_values_link.
      ENDIF.
      lv_key1   = lv_key.
      lv_Value1 = lv_value.
    ENDLOOP.
  ENDLOOP.

ENDMETHOD.
<img alt="">

Accepted Solutions (0)

Answers (0)