Supply Chain Management Blog Posts by SAP
Expand your SAP SCM knowledge and stay informed about supply chain management technology and solutions with blog posts by SAP. Follow and stay connected.
cancel
Showing results for 
Search instead for 
Did you mean: 
robinthakral
Product and Topic Expert
Product and Topic Expert
14,448

INTRODUCTION:


T-Code FD32 is deprecated in the S/4 HANA system, but there are many BDCs written in old client systems. Now, UKMBP_CMS is the table that needs to be updated.

Challenge: There is only one standard FM that does it UKM_DB_UKMBP_CMS_EXECUTE but this FM is doing direct updates into the table without any error handling as well as writing DML on the table and is not released for customer.

In this blog post, we will cover the class-methods:

  • CL_UKM_BUPA_FACTORY          ( Partner )

  • CL_UKM_BUSINESS_PARTNER ( Partner Credit Profile )

  • CL_UKM_ACCOUNT                     ( Partner Credit Segment )


to handle the requirement.

MAIN CONTENT:



  1. Declare a final local class for data & method.
    ************************************************************************
    * Class Declarations
    ************************************************************************
    CLASS lcl_fi_ukm000_update DEFINITION FINAL.
    ** INTERFACES
    PUBLIC SECTION.
    Constants: lc_error TYPE c VALUE 'E',
    lc_success TYPE c VALUE 'S'.

    **data:
    DATA:lo_facade TYPE REF TO cl_ukm_facade,
    lo_partner TYPE REF TO cl_ukm_business_partner,
    lo_bupa_factory TYPE REF TO cl_ukm_bupa_factory,

    lt_tpz22 TYPE SORTED TABLE OF tpz22 WITH NON-UNIQUE KEY ranking,
    lt_final TYPE STANDARD TABLE OF ty_s_final, “ Final table structure
    lt_bapiret TYPE SORTED TABLE OF bapiret2 WITH NON-UNIQUE KEY type number,
    lt_bapiret2 TYPE bapiret2_t,
    lt_bapiret_record TYPE SORTED TABLE OF bapiret2 WITH NON-UNIQUE KEY type number,
    lt_bapiret_total TYPE bapiret2_t.

    METHODS:
    maintain_bp_credit_details,
    update_credit_profile_segment,
    update_external_credit_info,
    update_additional_adj_info,
    update_identification.
    ENDCLASS.


  2. Update the Final table and then at End-of-selection call the main method MAINTAIN_BP_CREDIT_DETAILS.

  3. Declare implementation of class-methods,
    CLASS lcl_fi_ukm000_update IMPLEMENTATION.

    *&---------------------------------------------------------------------*
    *& Maintain BP - SAP CREDIT MANAGEMENT Details
    *&---------------------------------------------------------------------*
    METHOD maintain_bp_credit_details.
    DATA: lt_output TYPE SORTED TABLE OF ty_s_final WITH NON-UNIQUE KEY primary_key COMPONENTS kunnr
    WITH NON-UNIQUE SORTED KEY type_key COMPONENTS type ,
    ls_bupa_error TYPE mds_ctrls_error.

    CLEAR: lt_bapiret_record[], lt_bapiret_total[], lt_output[].
    lt_output[] = lt_final[].

    "*********here customer is BP only, make sure to ALPHA = IN if needed earlier**************
    LOOP AT lt_output[] INTO ls_final USING KEY type_key WHERE type IS INITIAL.
    CLEAR: ls_bupa_error, ls_bupa_error-messages[].
    "____________________ Lock BP___________________
    DATA(lo_bupa) = NEW cl_im_mds_bupa_lock( ).
    lo_bupa->if_ex_bupa_lock~lock(
    EXPORTING
    iv_partner = ls_final-kunnr
    CHANGING
    cs_error = ls_bupa_error ).

    IF ls_bupa_error-is_error IS INITIAL.
    " Process Updating the Data
    "__________________________"
    update_credit_profile_segment( ).
    update_external_credit_info( ).
    update_additional_adj_info( ).
    update_identification( ).

    IF line_exists( lt_bapiret_record[ type = lc_error ] ).
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    " Remove manually added success messages.
    DELETE lt_bapiret_record[] WHERE parameter = ls_final-kunnr AND type = lc_success.
    ELSE.
    lo_bupa_factory->save_all( i_upd_task = abap_false ). "For Factory methods

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "For API Methods
    EXPORTING
    wait = abap_true.
    ENDIF.
    "____________________Unlock BP____________________
    lo_bupa->if_ex_bupa_lock~unlock(
    EXPORTING
    iv_partner = ls_final-kunnr
    CHANGING
    cs_error = ls_bupa_error ).
    ELSE.
    lt_bapiret_record[] = VALUE #( FOR ls_bapiret IN ls_bupa_error-messages
    ( parameter = |{ ls_final-kunnr }|
    type = ls_bapiret-type
    message = ls_bapiret-message
    )
    ) .
    ENDIF.
    APPEND LINES OF lt_bapiret_record[] TO lt_bapiret_total[].
    CLEAR: lt_bapiret_record[].
    ENDLOOP.
    display_data( ). " Display Final ALV table
    ENDMETHOD.

    *&---------------------------------------------------------------------*
    *& Update Credit Profile within Role UKM000 - SAP CREDIT MANAGEMENT
    *& Update Credit Segment at Header Level
    *&---------------------------------------------------------------------*
    METHOD update_credit_profile_segment.
    DATA: lo_account TYPE REF TO cl_ukm_account,
    ls_bp_credit_sgm TYPE ukm_s_bp_cms_sgm,
    ls_ukm_s_bp_cms TYPE ukm_s_bp_cms.
    CONSTANTS: lc_std TYPE ukm_limit_rule VALUE 'STANDARD'.

    "set & fetch Parent data
    lo_facade = cl_ukm_facade=>create( i_activity = cl_ukm_cnst_eventing=>bp_maintenance ).
    lo_bupa_factory = lo_facade->get_bupa_factory( ).
    lo_partner = lo_bupa_factory->get_business_partner( ls_final-kunnr ).

    " Fetch & update credit profile data
    lo_partner->get_bp_cms(
    IMPORTING
    es_bp_cms = ls_ukm_s_bp_cms
    ).
    ls_ukm_s_bp_cms-limit_rule = lc_std.
    ls_ukm_s_bp_cms-risk_class = ls_final-cre_risk.
    ls_ukm_s_bp_cms-own_rating = ls_final-db_paydex_score. " Credit score.
    ls_ukm_s_bp_cms-rating_chg_date = sy-datum.
    ls_ukm_s_bp_cms-rating_val_date = sy-datum + 1. " plus 1 days
    lo_partner->set_bp_cms(
    EXPORTING
    is_bp_cms = ls_ukm_s_bp_cms
    ).

    "Fetch & update credit segment data
    lo_account = lo_bupa_factory->get_credit_account(
    i_partner = ls_final-kunnr
    i_credit_sgmnt = CONV ukm_credit_sgmnt( ls_final-kkber ) ).

    lo_account->get_bp_cms_sgm(
    IMPORTING
    es_bp_cms_sgm = ls_bp_credit_sgm ).

    ls_bp_credit_sgm-x_limit_zero = abap_false.
    ls_bp_credit_sgm-credit_limit = ls_final-cred_lim.
    ls_bp_credit_sgm-limit_chg_date = sy-datum.
    ls_bp_credit_sgm-req_date = ls_final-ref_date.

    lo_account->set_bp_cms_sgm(
    EXPORTING
    is_bp_cms_sgm = ls_bp_credit_sgm
    ).

    APPEND VALUE #( parameter = |{ ls_final-kunnr }|
    type = lc_success
    message = |{ ls_final-kunnr } { TEXT-019 }|
    message_v1 = TEXT-019
    ) TO lt_bapiret_record[].
    ENDMETHOD.
    *&---------------------------------------------------------------------*
    *& Update BP External Credit Info - Credit Profile - UKM000 –
    *& this is independent of Partner class instance.
    *&---------------------------------------------------------------------*
    METHOD update_external_credit_info.
    DATA: lt_bp1012 TYPE STANDARD TABLE OF bp1012,
    lt_message TYPE tty_xo_message,
    lv_guid TYPE bu_partner_guid.

    CLEAR: lt_bapiret[], lt_bapiret2[].

    DATA(lv_score) = CONV bp_grade_rank( ls_final-tot_score ).
    SHIFT lv_score LEFT DELETING LEADING space.

    " date range should be beyond date_to & date_from.
    lt_bp1012 = VALUE #( ( grade_method = lc_grade_method_dnb "'DNB'
    grade = VALUE #( lt_tpz22[ ranking = lv_score ]-grade OPTIONAL ) "ls_final-dbrating
    flg_permit = abap_true
    text = ls_final-cust_group
    date_when = sy-datum
    date_from = sy-datum
    date_to = cl_reca_date=>add_to_date( id_years = 1 id_date = sy-datum )
    ) ).

    lt_message[] = fsbp_api_adapter=>execute_mo_specific_add( " will add new record - use change for changing
    i_partner = ls_final-kunnr
    i_partnerguid = lv_guid
    i_table_name = if_fsbp_const_xo_objects=>mo_bp1012
    i_check_authority = abap_false
    i_data_new = lt_bp1012[]
    ).
    IF lt_message[] IS NOT INITIAL.
    lt_bapiret[] = VALUE #( FOR ls_bapiret IN lt_message[]
    ( parameter = |{ ls_final-kunnr }|
    type = ls_bapiret-type
    message = ls_bapiret-message
    )
    ) .
    INSERT LINES OF lt_bapiret[] INTO TABLE lt_bapiret_record[]. " for sorted table - append dont work
    ENDIF.
    IF NOT line_exists( lt_bapiret[ type = lc_error ] ).
    APPEND VALUE #( parameter = |{ ls_final-kunnr }|
    type = lc_success
    message = |{ ls_final-kunnr } { TEXT-020 }|
    message_v1 = TEXT-020
    ) TO lt_bapiret_record[].
    ENDIF.

    ENDMETHOD.
    *&---------------------------------------------------------------------*
    *& Update BP Additional Adjustment - Credit Profile - UKM000
    *& this is independent of Partner class instance.
    *&---------------------------------------------------------------------*
    METHOD update_additional_adj_info.
    DATA: lt_bp3100 TYPE STANDARD TABLE OF bp3100,
    lt_message TYPE tty_xo_message,
    lv_guid TYPE bu_partner_guid..
    CONSTANTS: lc_addtype_50 TYPE bp_addtype VALUE 50,
    lc_data_type_01 TYPE bp_data_type VALUE 01.
    CLEAR: lt_bapiret[], lt_bapiret2[].

    " _____________Have to Add the Required Record _______________
    lt_bp3100[] = VALUE #( ( partner = ls_final-kunnr
    addtype = lc_addtype_50 "50
    data_type = lc_data_type_01 "01
    amnt = CONV bp_amnt( ls_final-dbtrade_ref_amt )
    addate = sy-datum
    datefr = sy-datum
    dateto = sy-datum
    text = ls_final-kraus
    ) ).
    lt_message[] = fsbp_api_adapter=>execute_mo_specific_add(
    i_partner = ls_final-kunnr
    i_partnerguid = lv_guid
    i_table_name = if_fsbp_const_xo_objects=>mo_bp3100
    i_check_authority = abap_false
    i_data_new = lt_bp3100[]
    ).
    IF lt_message[] IS NOT INITIAL.
    lt_bapiret[] = VALUE #( FOR ls_bapiret IN lt_message[]
    ( parameter = |{ ls_final-kunnr }|
    type = ls_bapiret-type
    message = ls_bapiret-message
    )
    ) .
    INSERT LINES OF lt_bapiret[] INTO TABLE lt_bapiret_record[]. " for sorted table - append dont work
    ENDIF.
    IF NOT line_exists( lt_bapiret[ type = lc_error ] ).
    APPEND VALUE #( parameter = |{ ls_final-kunnr }|
    type = lc_success
    message = |{ ls_final-kunnr } { TEXT-021 }|
    message_v1 = TEXT-021
    ) TO lt_bapiret_record[].
    ENDIF.

    ENDMETHOD.
    *&---------------------------------------------------------------------*
    *& Update BP Identification - Credit Profile - UKM000 or General
    *& This information is Generic irrespective of ROLE in BP
    *&---------------------------------------------------------------------*
    METHOD update_identification.
    "IDENTIFICATION
    DATA: lt_bapiret2 TYPE bapiret2_t,
    ls_id_upd TYPE bapibus1006_identification.
    CONSTANTS: lc_idcat_bup001 TYPE bu_id_category VALUE 'BUP001'.

    CLEAR: lt_bapiret[], lt_bapiret2[].

    ls_id_upd = VALUE #( idinstitute = ls_final-cust_group
    identrydate = sy-datum
    idvalidfromdate = sy-datum
    idvalidtodate = cl_reca_date=>add_to_date( id_years = 1 id_date = sy-datum )
    ).
    lo_partner->save_but0id(
    EXPORTING
    i_id_type = lc_idcat_bup001
    i_id_number = CONV bu_id_number( ls_final-kraus )
    i_identification = ls_id_upd
    IMPORTING
    et_return = lt_bapiret2 )
    .
    IF lt_bapiret2[] IS NOT INITIAL.
    lt_bapiret[] = VALUE #( FOR ls_bapiret IN lt_bapiret2[]
    ( parameter = |{ ls_final-kunnr }|
    type = ls_bapiret-type
    message = ls_bapiret-message
    )
    ) .
    INSERT LINES OF lt_bapiret[] INTO TABLE lt_bapiret_record[]. " for sorted table - append dont work
    ENDIF.
    IF NOT line_exists( lt_bapiret[ type = lc_error ] ).
    APPEND VALUE #( parameter = |{ ls_final-kunnr }|
    type = lc_success
    message = |{ ls_final-kunnr } { TEXT-022 }|
    message_v1 = TEXT-022
    ) TO lt_bapiret_record[].
    ENDIF.

    ENDMETHOD.
    ENDCLASS.

    Here DISPLAY_ALV is not declared as you can declare the factory ALV method on your own to display the Final table or LT_BAPIRET_TOTAL. Handle success & error text as per your requirement.

     

    Rest, you can trigger SAVE_ALL( I_UPD_TASK = ABAP_TRUE ) " X to handle the update and Fiori front-end update.

     

     

     

     

     

    Reference links:

    Comparison for SAP S/4HANA Basic Credit Management and Advanced Credit Management




    Topic page:

    ABAP Topic: https://community.sap.com/topics/abap,

    Do give your comments and feedback.
    Follow for more: Robin Thakral











11 Comments
robinthakral
Product and Topic Expert
Product and Topic Expert
0 Kudos
Drop me comments, if you need the successful implementation of the FM UKM_DB_UKMBP_CMS_EXECUTE
tim_kich
Explorer
0 Kudos
Hi Robin.  This might be what I'm looking for.  I have written a custom transaction to create business partners and SAP customers, but what seems to be missing is creating the credit profile and credit segment.  Can you please share on how to implement using UKM_DB_UKMBP_CMS_EXECUTE?
robinthakral
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Tim,

Good to know that you found my blog useful !!

The thing so far I can get from your statement is that you have created a customer that SAP is auto-syncing as a Partner(customer). So, as per the reference blog link, I can tell you that make sure that you are activating the  UKM000 role in the configuration and creating in parallel or later the UKM000 role for the partner required.

then you can only use the same the class-method, I have shared, as FM UKM_DB_UKMBP_CMS_EXECUTE has not been released, so the SAP support team will not help you with this.
Trust me, I had implemented the FM only at first but during quality checks, I noticed this thing and looked out for API class and hence implemented the shared approach.
asha15
Newcomer
0 Kudos

Thanks for the information.
My requirement is mass update of credit limits BP for credit segment ‘0000’. So I have used the  get_bp_cms_sgm.
I am able to get the details. Then I used set_bp_cms_sgm. But credit limit is not getting changed. I followed the Same logic which you have given here.
When I check inside set_bp_cms_sgm, the first event is changing the entered credit limit to current credit limit from the table because of this second event is not getting executed.
Again I debugged, the problem was max_limit_increase  percentage field was 0.


my doubt is what percentage it should be there in ukm_crlt_rule table?

Check_limit_change method CL_UKM_ACOUNT can you explain the logic. I have tried executing all possible paths in this. May be entry from UKM_BP_CMS_SGM data is wrong.
Entry should be there with new credit value as requested credit limit (field) in UKM_BP_CMS_SGM? Then why we need to assign it to ls_bp_credit_sgm-credit_limit before calling set_bp_cms_sgm?

I am new to credit management. Please help me.
robinthakral
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Asha,
Likewise, this was my only time working with Credit Management and I only did R&D to concur with the requirement with limited knowledge of Business Processes. I found it useful to share, as I struggled for weeks for the same and it feels good to see responses. Rest, I will try the implementation and impact of method CL_UKM_ACOUNT.

And pls pls don't forget to FACTORY_SAVE / COMMIT the tasks as handled at the end of 4 methods.
robinthakral
Product and Topic Expert
Product and Topic Expert
Youssef3
Discoverer
0 Kudos

Hello @robinthakral ,

Can i have please the successful implementation of the FM UKM_DB_UKMBP_CMS_EXECUTE ?

 

Thanks in advance 

robinthakral
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi @Youssef3 & @tim_kich ,

I would not recommend the approach for the reasons stated earlier and would believe you would opt for class-method later. But for the ease of understanding and successful trials of yours. PF required code below:

*&---------------------------------------------------------------------*
*&        Maintain BP - SAP CREDIT MANAGEMENT Details
*&---------------------------------------------------------------------*
  METHOD maintain_bp_credit_details.
 DATA:  lt_output     TYPE SORTED TABLE OF ty_s_final WITH NON-UNIQUE KEY primary_key COMPONENTS kunnr kraus kkber
                                                     WITH NON-UNIQUE SORTED KEY type_key COMPONENTS  type ,
           ls_bupa_error TYPE mds_ctrls_error.
    CLEAR: lt_bapiret_record[], lt_bapiret_total[], lt_output[].
    lt_output[] = lt_final[].
 LOOP AT lt_output[] INTO ls_final USING KEY type_key WHERE type IS INITIAL.
      CLEAR: ls_bupa_error, ls_bupa_error-messages[].
      "____________________ Lock BP___________________
      DATA(lo_bupa) = NEW cl_im_mds_bupa_lock( ).
      lo_bupa->if_ex_bupa_lock~lock(
        EXPORTING
          iv_partner      = ls_final-kunnr
        CHANGING
          cs_error        = ls_bupa_error ).

      IF ls_bupa_error-is_error IS INITIAL.
        " Process Updating the Data
        "__________________________"
        update_credit_profile_segment( ).
        update_external_credit_info( ).
        update_additional_adj_info( ).
        update_identification( ).

        IF line_exists( lt_bapiret_record[ type = lc_error ] ).
          CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
          " Remove manually added success messages
          DELETE lt_bapiret_record[] WHERE parameter = ls_final-kunnr AND type = lc_success.
        ELSE.
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
            EXPORTING
              wait = abap_true.
        ENDIF.
        "____________________Unlock BP____________________
        lo_bupa->if_ex_bupa_lock~unlock(
        EXPORTING
          iv_partner      = ls_final-kunnr
        CHANGING
          cs_error        = ls_bupa_error ).
      ELSE.
        lt_bapiret_record[] =  VALUE #( FOR ls_bapiret IN ls_bupa_error-messages
                                  ( parameter  = |{ ls_final-kunnr }|
                                    type       = ls_bapiret-type
                                    message    = ls_bapiret-message
                                  )
                                ) .
      ENDIF.
      APPEND LINES OF lt_bapiret_record[] TO lt_bapiret_total[].
      CLEAR: lt_bapiret_record[].
    ENDLOOP.

    IF NOT lt_bapiret_total[] IS INITIAL. " Although it will definitely hold error or success message - but ATC Check handling
      CLEAR: lt_final[].
      lt_final[] = VALUE #( FOR ls_bapiret IN lt_bapiret_total[]
                            FOR ls_output IN lt_output WHERE ( kunnr = ls_bapiret-parameter+0(10) )
                             (
                             kunnr    = ls_output-kunnr
                             kkber    = ls_output-kkber
                             mat_avg  = ls_output-mat_avg
                             cred_lim = ls_output-cred_lim
                             cre_risk = ls_output-cre_risk
                             type     = ls_bapiret-type
                             message  = ls_bapiret-message
                             )
                           ).
      lt_output =  FILTER #( lt_output USING KEY type_key WHERE type = lc_error ) .
      APPEND LINES OF lt_output TO lt_final[].
      SORT lt_final[].
**    ELSE.
**      lt_final[] = lt_output[].
    ENDIF.

    display_data( ). " Display Final ALV table
  ENDMETHOD.

*&---------------------------------------------------------------------*
*&        Update Credit Profile within Role UKM000 - SAP CREDIT MANAGEMENT
*&        Update Credit Segment at Header Level
*&---------------------------------------------------------------------*
  METHOD    update_credit_profile_segment.
    DATA: lt_cms_upd TYPE STANDARD TABLE OF ukm_s_bp_cms_upd,
          lt_sgm_upd TYPE STANDARD TABLE OF ukm_s_bp_cms_sgm_upd.
    CONSTANTS: lc_change_i TYPE c VALUE 'I'.

    lt_cms_upd = VALUE #( ( partner = ls_final-kunnr
                              limit_rule = 'STANDARD'  "'Standard Rule Without Automatic Calculation'
                              risk_class = ls_final-cre_risk
**                              risk_class_chgdt = sy-datum
**                              check_rule = '01' "ls_final-check_rule.
**                              credit_group = '0002' "ls_final-credit_group.
                              own_rating = ls_final-db_paydex_score " Credit score
                              rating_chg_date = sy-datum
                              rating_val_date = sy-datum + 1 " plus 1 days
                              change_id = lc_change_i     " 'I'
                              ) ).

    lt_sgm_upd = VALUE #( ( partner                 = ls_final-kunnr "#EC CI_CONV_OK
                            credit_sgmnt            = ls_final-kkber "'MFI'     "#EC CI_CONV_OK
                            x_limit_zero            = abap_false           " 'X'/ '' - yes/no
                            credit_limit            = ls_final-cred_lim
                            limit_chg_date          = sy-datum
**                             limit_valid_date        = sy-datum + 60
                            req_date                = ls_final-ref_date
                            change_id               = lc_change_i       "'I'
                           ) ).

    CALL FUNCTION 'UKM_DB_UKMBP_CMS_EXECUTE'
      TABLES
        n_ukmbp_cms     = lt_cms_upd
        n_ukmbp_cms_sgm = lt_sgm_upd.
    APPEND VALUE #(  parameter  = |{ ls_final-kunnr }|
                     type       = lc_success
                     message    = |{ ls_final-kunnr } { TEXT-019 }|
                     message_v1 = TEXT-019
                   ) TO lt_bapiret_record[].
  ENDMETHOD.
*&---------------------------------------------------------------------*
*&        Update BP External Credit Info - Credit Profile - UKM000
*&---------------------------------------------------------------------*
  METHOD    update_external_credit_info.
    DATA:  lt_bp1012  TYPE STANDARD TABLE OF bp1012.

    CLEAR: lt_bapiret[], lt_bapiret2[].

    DATA(lv_score) = CONV bp_grade_rank( ls_final-tot_score ).
    SHIFT lv_score LEFT DELETING LEADING space.

    " date range should be beyond date_to & date_from.
    lt_bp1012 = VALUE #( ( grade_method = lc_grade_method_dnb  "'DNB'
                           grade        = VALUE #( lt_tpz22[ ranking = lv_score ]-grade OPTIONAL )  "ls_final-dbrating
                           flg_permit   = abap_true
                           text         = ls_final-cust_group
                           date_when    = sy-datum
                           date_from    = sy-datum
                           date_to      = cl_reca_date=>add_to_date( id_years = 1 id_date  = sy-datum )
                        ) ).
    CALL FUNCTION 'FS_API_BP1012_ADD' " will add new record - use change for changing
      EXPORTING
        iv_partner = ls_final-kunnr
      TABLES
        et_return  = lt_bapiret2
        it_bp1012  = lt_bp1012[].
    IF lt_bapiret2[] IS NOT INITIAL.
      lt_bapiret[] =  VALUE #( FOR ls_bapiret IN lt_bapiret2[]
                                ( parameter  = |{ ls_final-kunnr }|
                                  type       = ls_bapiret-type
                                  message    = ls_bapiret-message
                                )
                              ) .
      INSERT LINES OF lt_bapiret[] INTO TABLE lt_bapiret_record[]. " for sorted table - append dont work
    ENDIF.
    IF NOT line_exists( lt_bapiret[ type = lc_error ] ).
      APPEND VALUE #( parameter  = |{ ls_final-kunnr }|
                       type       = lc_success
                       message    = |{ ls_final-kunnr } { TEXT-020 }|
                       message_v1 = TEXT-020
                   ) TO lt_bapiret_record[].
    ENDIF.

  ENDMETHOD.
*&---------------------------------------------------------------------*
*&        Update BP Additional Adjustment - Credit Profile - UKM000
*&---------------------------------------------------------------------*
  METHOD    update_additional_adj_info.
    DATA: lt_bp3100   TYPE STANDARD TABLE OF bp3100.
    CONSTANTS: lc_addtype_50   TYPE bp_addtype VALUE 50,
               lc_data_type_01 TYPE bp_data_type VALUE 01.
    CLEAR: lt_bapiret[], lt_bapiret2[].

    " _____________Have to Add the Required Record _______________
    lt_bp3100[] = VALUE #( ( partner   = ls_final-kunnr
                             addtype   = lc_addtype_50        "50
                             data_type = lc_data_type_01      "01
                             amnt      = CONV bp_amnt( ls_final-dbtrade_ref_amt )
                             addate    = sy-datum
                             datefr    = sy-datum
                             dateto    = sy-datum
                             text      = ls_final-kraus
                         ) ).
    CALL FUNCTION 'FS_API_BP3100_ADD'
      EXPORTING
        iv_partner = ls_final-kunnr
      TABLES
        it_bp3100  = lt_bp3100[]
        et_return  = lt_bapiret2.

    IF lt_bapiret2[] IS NOT INITIAL.
      lt_bapiret[] =  VALUE #( FOR ls_bapiret IN lt_bapiret2[]
                                ( parameter  = |{ ls_final-kunnr }|
                                  type       = ls_bapiret-type
                                  message    = ls_bapiret-message
                                )
                              ) .
      INSERT LINES OF lt_bapiret[] INTO TABLE lt_bapiret_record[]. " for sorted table - append dont work
    ENDIF.
    IF NOT line_exists( lt_bapiret[ type = lc_error ] ).
      APPEND VALUE #( parameter  = |{ ls_final-kunnr }|
                      type       = lc_success
                      message    = |{ ls_final-kunnr } { TEXT-021 }|
                      message_v1 = TEXT-021
                     )  TO lt_bapiret_record[].
    ENDIF.

  ENDMETHOD.
*&---------------------------------------------------------------------*
*&        Update BP Identification - Credit Profile - UKM000 or General
*&        This information is Generic irrespective of ROLE in BP
*&---------------------------------------------------------------------*
  METHOD    update_identification.
    DATA: ls_id     TYPE bapibus1006_id_details,
          ls_id_upd TYPE bapibus1006_identification,
          ls_id_x   TYPE bapibus1006_identification_x.
    CONSTANTS: lc_idcat_bup001 TYPE bu_id_category VALUE 'BUP001'.
    CLEAR: lt_bapiret[], lt_bapiret2[].

    CALL FUNCTION 'BAPI_IDENTIFICATION_GET_DETAIL'
      EXPORTING
        businesspartner        = ls_final-kunnr
        identificationcategory = lc_idcat_bup001
        identificationnumber   = CONV bu_id_number( ls_final-kraus ) "'00-514-3987'
      IMPORTING
        identification         = ls_id
      TABLES
        return                 = lt_bapiret2.

    lt_bapiret[] = lt_bapiret2[].
    IF NOT line_exists( lt_bapiret[ type = lc_error ] ).
      CLEAR: lt_bapiret[], lt_bapiret2[].

      "_______________Have to Update the existing record__________________
      ls_id_upd = CORRESPONDING #( ls_id ).
      ls_id_upd-idinstitute     = ls_final-cust_group.
      ls_id_upd-identrydate     = sy-datum.
      ls_id_upd-idvalidfromdate = sy-datum.
      ls_id_upd-idvalidtodate   = cl_reca_date=>add_to_date( id_years = 1 id_date  = sy-datum ).

      ls_id_x-idinstitute       = abap_true.
      ls_id_x-identrydate       = abap_true.
      ls_id_x-idvalidfromdate   = abap_true.
      ls_id_x-idvalidtodate     = abap_true.
      CALL FUNCTION 'BAPI_IDENTIFICATION_CHANGE'
        EXPORTING
          businesspartner        = ls_final-kunnr
          identificationcategory = lc_idcat_bup001
          identificationnumber   = CONV bu_id_number( ls_final-kraus )  "'00-514-3987'
          identification         = ls_id_upd
          identification_x       = ls_id_x
        TABLES
          return                 = lt_bapiret2.
      IF lt_bapiret2[] IS NOT INITIAL.
        lt_bapiret[] =  VALUE #( FOR ls_bapiret IN lt_bapiret2[]
                                  ( parameter  = |{ ls_final-kunnr }|
                                    type       = ls_bapiret-type
                                    message    = ls_bapiret-message
                                  )
                                ) .
        INSERT LINES OF lt_bapiret[] INTO TABLE lt_bapiret_record[]. " for sorted table - append dont work
      ENDIF.
      IF NOT line_exists( lt_bapiret[ type = lc_error ] ).
        APPEND VALUE #( parameter  = |{ ls_final-kunnr }|
                        type       = lc_success
                        message    = |{ ls_final-kunnr } { TEXT-022 }|
                        message_v1 = TEXT-022
                        ) TO lt_bapiret_record[].
      ENDIF.

    ELSE.
      CLEAR: lt_bapiret[], lt_bapiret2[].

      " _____________Have to Add the Required Record _______________
      ls_id_upd-idinstitute     = ls_final-cust_group.
      ls_id_upd-identrydate     = sy-datum.
      ls_id_upd-idvalidfromdate = sy-datum.
      ls_id_upd-idvalidtodate   = cl_reca_date=>add_to_date( id_years = 1 id_date  = sy-datum ).

      CALL FUNCTION 'BAPI_IDENTIFICATION_ADD'
        EXPORTING
          businesspartner        = ls_final-kunnr
          identificationcategory = lc_idcat_bup001
          identificationnumber   = CONV bu_id_number( ls_final-kraus )   "'00-514-3987'  "
          identification         = ls_id_upd
        TABLES
          return                 = lt_bapiret2.
      IF lt_bapiret2[] IS NOT INITIAL.
        lt_bapiret[] =  VALUE #( FOR ls_bapiret IN lt_bapiret2[]
                                  ( parameter  = |{ ls_final-kunnr }|
                                    type       = ls_bapiret-type
                                    message    = ls_bapiret-message
                                  )
                                ) .
        INSERT LINES OF lt_bapiret[] INTO TABLE lt_bapiret_record[]. " for sorted table - append dont work
      ENDIF.
      IF NOT line_exists( lt_bapiret[ type = lc_error ] ).
        APPEND VALUE #( parameter  = |{ ls_final-kunnr }|
                        type       = lc_success
                        message    = |{ ls_final-kunnr } { TEXT-023 }|
                        message_v1 = TEXT-023
                        ) TO lt_bapiret_record[].
      ENDIF.

    ENDIF.
  ENDMETHOD.
* 016 Msg. Type
* 017 Message
* 019 Credit data & segment Updated Successfully
* 020 External Credit Info(BP1012) Updated Successfully
* 021 Additional Adjustment Info(BP3100) added Successfully
* 022 Identification Numbers(BUT0ID) Updated Successfully
* 023 Identification Numbers(BUT0ID) Added Successfully
* 024 Customer No is not maintained in input file for Row
* 025 Credit Control Area is not maintained in input file for Customer
* 026 Row
* 027 Business Partner
* 028 does not exist !!
* 029 does not have Role - SAP Credit Management(UKM00)
* 030 BP does not have Credit Segment =
* 031 - SAP Credit Management(UKMBP_CMS_SGM)
* 032 Net Credit Score is zero, no update to BP for Customer
* 034 Credit Score Upload Status
RahulS
Associate
Associate
0 Kudos

Thanks a lot Robin. This was very helpfull.

 

NikunjPathak
Associate
Associate
0 Kudos

Hello,

Could you please help with updating "Additional Info in Credit Management" under Further Information, which in turn is under Credit Limit and Control under Credit Segment Data of a BP for UKM000 Role.

Thanks

We have utilized the function module UKM_DB_UKMBP_CMS_EXECUTE to update the customer credit limit. While the function performs as expected, it does not update the business partner's change log. Is there an alternative solution to address this issue?