Supply Chain Management Blogs by Members
Learn about SAP SCM software from firsthand experiences of community members. Share your own post and join the conversation about supply chain management.
cancel
Showing results for 
Search instead for 
Did you mean: 
Satish_Kesavalu
Explorer

To perform the credit check, Credit Profile needs to be set up for the business partner under the UKM000 role.  Credit Profile of the Business partner drives the credit behavior of the Business partner.  Under the credit profile Credit Check rule plays vital role in performing the Credit Check in the credit engine. 

Satish_Kesavalu_0-1711004201667.png

 

Every Credit Check rule can have one or multiple Check Steps that can be defined to execute.  SAP had provided several Check Steps as shown below.

For Ex: SAP standard Check rule ‘01’ has several SAP check standard Check steps

Navigate to the IMG Path :

SPRO-> Financial Supply Chain Management -> Credit Management -> Credit Risk Monitoring -> Credit Limit Check -> Define Check Rules

Satish_Kesavalu_1-1711004246244.png

Select the Check rule and select Checks in the left side tree structure, to see the list of Credit check steps assigned and will be performed during credit check.

Satish_Kesavalu_2-1711004266254.png

Let us see the detailed steps on how to create Custom Credit check step and assign the Created credit check step to Custom Credit Check Rule and then assign the newly created Credit check Rule to the Business partner in the credit profile under the UKM000 BP role.

Create Custom Credit Check Step ( Z10 ):- 

               In this step lets us define to fail the credit check always.

Navigate to the IMG Path :

SPRO-> Financial Supply Chain Management -> Credit Management -> Credit Risk Monitoring -> Enhancements -> BAdi: Individual step of Credit Check

Execute the step BAdi: Individual step of Credit Check

Satish_Kesavalu_3-1711004315355.png

Choose Create and Define the step Number Z10  and the description as “Fail Credit Check always”

Satish_Kesavalu_4-1711004332136.png

Satish_Kesavalu_5-1711004346714.png

In the Method CHECK_STEP, define the custom logic to decide the credit check should be successful or failed.

Satish_Kesavalu_6-1711004367183.png

In this example we will define the Check Step to fail always. 

Variable C_PASSED is cleared.

The below Custom error message can be populated into the return table parameter ct_results.

Satish_Kesavalu_7-1711004384790.png

 

METHOD if_ex_ukm_check_step~check_step.

    DATA : lv_dummy TYPE string.

    CLEAR c_passed.

    MESSAGE e000(zcust_msg) INTO lv_dummy.

    CALL METHOD cl_ukm_credit_checker=>add_reason
      EXPORTING
        i_check_step = flt_val
        io_account   = io_account
      CHANGING
        ct_results   = ct_results.


  ENDMETHOD.

 

Satish_Kesavalu_8-1711004424018.png

Now we have created a New Custom Credit Check step.  We need to assign this credit check step to Custom Check rule.

Now lets us create New Check Rule,

Navigate to the IMG Path :

SPRO-> Financial Supply Chain Management -> Credit Management -> Credit Risk Monitoring -> Credit Limit Check -> Define Checking Rules

Create New entry with the Check Rule “Z2” and Name of Check Rule as “Fail Credit Check always”

Satish_Kesavalu_9-1711004445328.png

Select the Check Rule and select Checks and assign the Newly created check step “Z10”

Satish_Kesavalu_10-1711004470583.png

Satish_Kesavalu_11-1711004486245.png

Now we have completed the Creation of Custom Credit check Rule “Z2” and Check Step “Z10”.  We can assign this Credit check rule Z2 to Business partner if the credit check needs to fail always for the Business partner whenever the credit check is performed for this BP.

Assign the Custom Credit Check Rule “Z2” to the Business Partner

Satish_Kesavalu_12-1711004502038.png

We can perform the simulation of credit check to validate the credit check results of the custom Check Rule “Z2”

Navigate to the Credit Segment data of the Business Partner

Satish_Kesavalu_13-1711004527452.png

and choose the “Simulate Credit check” option highlighted below

Note : Credit Segment master data should be created and the Credit limit of the Business Partner needs to be setup.  *** creation of Credit segment master data will be explained in the upcoming blogs.

Satish_Kesavalu_14-1711004544089.png

Provide the input value amount and Currency and choose Credit Check, the results is shown in the output.

Have you noticed the error message raised in the custom Check Step “Z10” is executed by the credit engine and the error message is displayed.

Satish_Kesavalu_15-1711004559552.png

Now lets us see how we can perform the credit check of the given Business partner using the SAP standard Methods which in-turn provides the credit check results based on the newly created Check rule / Check Step.

Lets us create a custom Function Module which can in-turn call the SAP Standard Methods to perform the credit check.

Import Parameters

IM_BP                  TYPE     BU_PARTNER                  Business Partner Number

IM_VKORG         TYPE     VKORG                                Sales Organization / Credit segment

IM_NETWR         TYPE     NETWR                                Net Value in Document Currency

IM_WAERS         TYPE     WAERS                                Currency Key

Export Parameters

ET_QUERY_RESULTS     TYPE     UKM_T_QUERY_RESULTS            Results of Internal Credit Query

Class CL_UKM_XI_FACADE
Method IF_UKM_CREDIT_QUERY~CHECK_CREDIT

will perform the credit check and provide the results. 

Explanation of the Import and export parameters for the Method IF_UKM_CREDIT_QUERY~CHECK_CREDIT

pass the BP / Credit Segment / Order Amount and Currency to the export parameter it_items which will return the Credit check results in the importing parameter et_query_results.

In this example, Credit segment is created for each Sales org with the same name as Sales org, hence Sales Org value is passed to the credit segment in the variable lv_creditsegment.

 

FUNCTION zbp_credit_check.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IM_BP) TYPE  BU_PARTNER
*"     VALUE(IM_VKORG) TYPE  VKORG
*"     VALUE(IM_NETWR) TYPE  NETWR
*"     VALUE(IM_WAERS) TYPE  WAERS
*"  EXPORTING
*"     REFERENCE(ET_QUERY_RESULTS) TYPE  UKM_T_QUERY_RESULTS
*"     REFERENCE(EV_DENIAL_REASON) TYPE  CHAR250
*"----------------------------------------------------------------------

  DATA: lt_items          TYPE ukm_t_check_item,
        lt_denial_reasons TYPE ukm_t_denial_reason.

  DATA : lv_creditsegment TYPE ukm_credit_sgmnt,
         lv_net_amount    TYPE ukm_comm_actual_item.

  CLEAR : lv_creditsegment, lv_net_amount.
  lv_creditsegment = im_vkorg.
  lv_net_amount = im_netwr.

  lt_items = VALUE #( ( partner       = im_bp
                        credit_sgmnt  = lv_creditsegment
                        amount        = lv_net_amount
                        currency      = im_waers
                        schedule_data = VALUE #( (  effective_date  = sy-datum
                                                    amount          = lv_net_amount
                                                    currency        = im_waers
                                                    credit_sgmnt    = lv_creditsegment
                                                    partner         = im_bp ) ) ) ).

**** Method IF_UKM_CREDIT_QUERY~CHECK_CREDIT of Class CL_UKM_XI_FACADE
**** will perform the credit check and provide the results
  TRY.
      cl_ukm_xi_facade=>if_ukm_credit_query~check_credit(
        EXPORTING it_items         = lt_items
        IMPORTING et_query_results = et_query_results ).
  ENDTRY.

  IF et_query_results[ 1 ]-passed IS INITIAL.
***    Credit Check is failed

    lt_denial_reasons = et_query_results[ 1 ]-denial_reasons.

    LOOP AT lt_denial_reasons INTO DATA(ls_denial_reason) WHERE msgty = 'E'.

      CALL FUNCTION 'FORMAT_MESSAGE'
        EXPORTING
          id        = ls_denial_reason-msgid
          lang      = sy-langu
          no        = ls_denial_reason-msgno
          v1        = ls_denial_reason-msgv1
          v2        = ls_denial_reason-msgv2
          v3        = ls_denial_reason-msgv3
          v4        = ls_denial_reason-msgv4
        IMPORTING
          msg       = ev_denial_reason
        EXCEPTIONS
          not_found = 1
          OTHERS    = 2.
      IF sy-subrc <> 0.
* Implement suitable error handling here
      ENDIF.


    ENDLOOP.

  ELSE.
***    Credit check is successful

  ENDIF.
ENDFUNCTION.

 

 

In the credit check result internal table parameter et_query_results if the parameter PASSED = ‘X’, then credit check is successful and if the parameter PASSED = space then credit check is failed.

 

 

  IF et_query_results[ 1 ]-passed IS INITIAL.
***    Credit Check is failed

  ELSE.

***    Credit check is successful

  ENDIF.

 

If the Credit check is failed, the denial reason is captured and sent by the method in the field denial_reasons in the internal table et_query_results

Take the necessary action based on the Credit check results

Create variable lt_denial_reason of type UKM_T_DENIAL_REASON and populate the denial reason.

 

lt_denial_reasons = et_query_results[ 1 ]-denial_reasons.

    LOOP AT lt_denial_reasons INTO DATA(ls_denial_reason) WHERE msgty = 'E'.

    ENDLOOP.

 

In the above screenshot, the Business partner has bee assigned with the Credit check rule “Z2”.

Satish_Kesavalu_16-1711004724310.png

Function Module will return the Denial reason similar to Simulation that was performed in the previous step.

Satish_Kesavalu_17-1711004738192.png

Note :-  The Error Message “Custom - Credit Check Blocked for all Scenarios”  is raised from the Custom Credit check step configured and enabled in the above steps.

BADI UKM_CHECK_STEP and BADI Implementation ZIM_CUSTOM_CHECK is called when the credit check is performed using the SAP standard Method IF_UKM_CREDIT_QUERY~CHECK_CREDIT  of Class CL_UKM_XI_FACADE.

Hope this blogs helps to understand the implementation of custom credit check. 

Thanks all for your visit and support, please give Kudos if you like this page and provide comments.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Labels in this area