Enterprise Resource Planning Blogs 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: 
GOWRESHANHARAN
Explorer
12,185

Introduction:


Credit Management is a process in which Company sells a product/service to customers on a credit basis. The company collects payments from customers at a later time, after the sale of the product. The amount of credit fixed by a company for a customer is called a credit limit. The customer can purchase the product from a company within the credit limit, and when the credit limit is crossed, the order is blocked by the system.

The creditworthiness and payment behavior of your business partners have an immediate effect on the business results of your company. Efficient receivables and credit management reduce the risk of financial losses and help you to optimize business relationships with your business partners. SAP Credit Management (FIN-FSCM-CR) supports your company in determining the risk of losses on receivables from your business partners early and in making credit decisions efficiently and in some cases automated. With SAP Credit Management (FIN-FSCM-CR) you can operate centralized credit management. The business systems connected (for example Sales and Distribution, Logistics Execution, and Financial Accounting) report the commitment of a business partner to SAP Credit Management. 

Defining Credit Limits:

When defining a credit limit, the maximum permissible credit and/or commitment level for each customer in the master record must be maintained.

The credit limit defaults as the first level from the payment terms.

The most cautious setting is Order Restriction. To use restriction on order level, choose Sales Restriction, Delivery Restriction and Order Restriction, because not every delivery note or invoice is always based on an order. Therefore, include the higher restrictions.

The credit limit setting can be modified at any time. The credit limit includes payments with a future date. This is important if check payments are received with postdated checks. The commitment limit does not consider these types of payments.

Mass Upload Credit Limit to BP.


There is no direct way to upload credit to the Business Partner. So I tried a workaround to achieve this.

1. Upload the credit limit:

In this process, upload the credit limit to some other fields in the system or you can also create a table to store the credit limit.

For this example, I'm going to store the credit limit in Table => BP1012 (Rating)

2. Data Modeling of table BP1012:


3. Creating Rating Produce for the Credit Limit. 

Path: SPRO -> SAP Customizing Implementation Guide → Financial Supply Chain Management → Credit Management → Credit Risk Monitoring → Master Data → Define Rating Procedure



Create a Rating Procedure for the credit limit Storage. Fill in the following data to create a rating procedure.

Rating ProcedureCreditlim
DescriptionCredit Limit
Description of Rating ProcedureCredit Limit


4. Upload Data to BP1012 Table :

BAPI: FS_API_BP1012_ADD


Please find the below code to upload the credit limit to table BP1012 using an Excel file.

*&---------------------------------------------------------------------*

*& Report ZFI_BP_DATA_UPLOAD

*&---------------------------------------------------------------------*

*&

*&---------------------------------------------------------------------*

REPORT zfi_bp_data_upload.

*

TYPES : BEGIN OF ty_excel_data,

          partner      TYPE bp1012-partner,

          grade_method TYPE bp1012-grade_method,

          flg_permit   TYPE bp1012-flg_permit,

          grade        TYPE bp1012-grade,

          date_when    TYPE bp1012-date_when,

          text         TYPE bp1012-text,

          valid_from   TYPE bp1012-date_from,

          valid_to     TYPE bp1012-date_to,

        END OF ty_excel_data,

        BEGIN OF ty_alv_data,

          partner TYPE bp1012-partner,

          status  TYPE bapiret2-type,

          message TYPE bapiret2-message,

        END OF ty_alv_data.

DATA : gt_data      TYPE TABLE OF ty_excel_data,

       gwa_data     TYPE ty_excel_data,

       gt_alv_data  TYPE STANDARD TABLE OF ty_alv_data,

       gwa_alv_data TYPE ty_alv_data.

*

DATA: o_alv    TYPE REF TO cl_salv_table,

      o_cols   TYPE REF TO cl_salv_columns,

      o_column TYPE REF TO cl_salv_column.



*

DATA : lt_return TYPE TABLE OF bapiret2,

       lt_bp1012 TYPE TABLE OF bp1012,

       wa_bp1012 TYPE bp1012.

*

DATA: lv_rc TYPE i.

DATA: lt_file_table TYPE filetable,

      ls_file_table TYPE file_table.



DATA : lv_filename      TYPE string,

       lt_records       TYPE solix_tab,

       lv_headerxstring TYPE xstring,

       lv_filelength    TYPE i.

*

DATA : gv_file TYPE string.

*

FIELD-SYMBOLS: <lt_data> TYPE STANDARD TABLE.

FIELD-SYMBOLS: <yt_data> TYPE ANY TABLE.

FIELD-SYMBOLS: <wa> TYPE any,

               <f1> TYPE any,

               <f2> TYPE any.

*---------------------------------------------------------*

*

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

  PARAMETERS : p_file    TYPE rlgrap-filename OBLIGATORY.

  SELECTION-SCREEN BEGIN OF LINE.

    SELECTION-SCREEN COMMENT 65(25) TEXT-001 FOR FIELD p_file.

  SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b1.

*

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

*    Search Help for File Upload

  CALL METHOD cl_gui_frontend_services=>file_open_dialog

    EXPORTING

      window_title = 'Select a file'

    CHANGING

      file_table   = lt_file_table

      rc           = lv_rc.

  IF sy-subrc = 0.

    READ TABLE lt_file_table INTO ls_file_table INDEX 1.

    p_file = ls_file_table-filename.

  ENDIF.

*

*---------------------------------------------------------*

*

START-OF-SELECTION.

  gv_file = p_file.

*

  lv_filename = p_file.

*

  CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

      filename                = gv_file

      filetype                = 'BIN'

    IMPORTING

      filelength              = lv_filelength

      header                  = lv_headerxstring

    TABLES

      data_tab                = lt_records

    EXCEPTIONS

      file_open_error         = 1

      file_read_error         = 2

      no_batch                = 3

      gui_refuse_filetransfer = 4

      invalid_type            = 5

      no_authority            = 6

      unknown_error           = 7

      bad_data_format         = 8

      header_not_allowed      = 9

      separator_not_allowed   = 10

      header_too_long         = 11

      unknown_dp_error        = 12

      access_denied           = 13

      dp_out_of_memory        = 14

      disk_full               = 15

      dp_timeout              = 16

      OTHERS                  = 17.

*

  "convert binary data to xstring

  "if you are using cl_fdt_xl_spreadsheet in odata then skips this step

  "as excel file will already be in xstring

  CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

    EXPORTING

      input_length = lv_filelength

    IMPORTING

      buffer       = lv_headerxstring

    TABLES

      binary_tab   = lt_records

    EXCEPTIONS

      failed       = 1

      OTHERS       = 2.

*

  IF sy-subrc <> 0.

    "Implement suitable error handling here

  ENDIF.

*

  DATA : lo_excel_ref TYPE REF TO cl_fdt_xl_spreadsheet .

*

  TRY .

      lo_excel_ref = NEW cl_fdt_xl_spreadsheet(

        document_name = lv_filename

        xdocument     = lv_headerxstring ).

    CATCH cx_fdt_excel_core.

      "Implement suitable error handling here

  ENDTRY .

*

  "Get List of Worksheets

  lo_excel_ref->if_fdt_doc_spreadsheet~get_worksheet_names(

    IMPORTING

      worksheet_names = DATA(lt_worksheets) ).

*

  IF NOT lt_worksheets IS INITIAL.

    READ TABLE lt_worksheets INTO DATA(lv_woksheetname) INDEX 1.



    DATA(lo_data_ref) = lo_excel_ref->if_fdt_doc_spreadsheet~get_itab_from_worksheet(

      lv_woksheetname ).

    "now you have excel work sheet data in dyanmic internal table

    ASSIGN lo_data_ref->* TO <lt_data>.

  ENDIF.

*

  DELETE <lt_data> INDEX 1.



  LOOP AT <lt_data> ASSIGNING <wa>.

*

    ASSIGN COMPONENT 1 OF STRUCTURE <wa> TO <f1>.

    gwa_data-partner = |{ <f1> ALPHA = IN }|.

    CLEAR <f1>.

*

    ASSIGN COMPONENT 2 OF STRUCTURE <wa> TO <f1>.

    gwa_data-grade_method = |{ <f1> ALPHA = IN }|.

    CLEAR <f1>.

*

    ASSIGN COMPONENT 3 OF STRUCTURE <wa> TO <f1>.

    gwa_data-flg_permit = <f1>.

    CLEAR <f1>.

*

    ASSIGN COMPONENT 4 OF STRUCTURE <wa> TO <f1>.

    gwa_data-grade = <f1>.

    CLEAR <f1>.

*

    ASSIGN COMPONENT 5 OF STRUCTURE <wa> TO <f1>.

    IF <f1> IS NOT INITIAL.

*      gwa_data-date_when = <f1>+6(4) && <f1>+0(2) && <f1>+3(5).

      gwa_data-date_when = <f1>+0(4) && <f1>+5(2) && <f1>+8(2).

    ELSE.

      gwa_data-date_when = <f1>.

    ENDIF.

    CLEAR <f1>.

*

    ASSIGN COMPONENT 6 OF STRUCTURE <wa> TO <f1>.

    gwa_data-text = <f1> .

    CLEAR <f1>.

*

    ASSIGN COMPONENT 7 OF STRUCTURE <wa> TO <f1>.

    IF <f1> IS NOT INITIAL.

      gwa_data-valid_from = <f1>+6(4) && <f1>+0(2) && <f1>+3(5).

    ELSE.

      gwa_data-valid_from = <f1>.

    ENDIF.

    CLEAR <f1>.

*

    ASSIGN COMPONENT 8 OF STRUCTURE <wa> TO <f1>.

    IF <f1> IS NOT INITIAL.

      gwa_data-valid_to = <f1>+6(4) && <f1>+0(2) && <f1>+3(5).

    ELSE.

      gwa_data-valid_to = <f1>.

    ENDIF.

    CLEAR <f1>.

*

    APPEND gwa_data TO gt_data.

    CLEAR: gwa_data , <wa>.

  ENDLOOP.

*

*

  DATA(lt_data) = gt_data[].

  SORT lt_data ASCENDING BY partner.

  DELETE ADJACENT DUPLICATES FROM lt_data COMPARING partner.

*

  LOOP AT lt_data INTO DATA(lwa_data).

    LOOP AT gt_data INTO gwa_data WHERE partner = lwa_data-partner.

      wa_bp1012-partner      = gwa_data-partner.

      wa_bp1012-grade_method = gwa_data-grade_method.

      wa_bp1012-flg_permit   = gwa_data-flg_permit.

      wa_bp1012-grade        = gwa_data-grade.

      wa_bp1012-date_when    = gwa_data-date_when.

      wa_bp1012-text         = gwa_data-text.

      wa_bp1012-date_from    = gwa_data-valid_from.

      wa_bp1012-date_to      = gwa_data-valid_to.

      APPEND wa_bp1012 TO lt_bp1012.

      CLEAR wa_bp1012.

    ENDLOOP.

    IF lines( lt_bp1012[] ) > 0.

      CALL FUNCTION 'FS_API_BP1012_ADD'

        EXPORTING

          iv_partner = lwa_data-partner

        TABLES

          et_return  = lt_return

          it_bp1012  = lt_bp1012.

*

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

        EXPORTING

          wait = 'X'.

*

      IF lines( lt_return[] ) > 0 .

        TRY.

            DATA(lwa_return) = lt_return[ 1 ].

            gwa_alv_data-partner = |{ lwa_data-partner ALPHA = OUT }|.

            gwa_alv_data-status  = 'E'.

            gwa_alv_data-message = lwa_return-message.

            APPEND gwa_alv_data TO gt_alv_data.

            CLEAR : gwa_alv_data.

          CATCH cx_sy_itab_line_not_found.

            gwa_alv_data-partner = |{ lwa_data-partner ALPHA = OUT }|.

            gwa_alv_data-status  = 'E'.

            gwa_alv_data-message = 'Error Occured in Data Upload'.

            APPEND gwa_alv_data TO gt_alv_data.

            CLEAR : gwa_alv_data.

        ENDTRY.

      ELSE.

        gwa_alv_data-partner = |{ lwa_data-partner ALPHA = OUT }|.

        gwa_alv_data-status  = 'S'.

        gwa_alv_data-message = 'Data Uploaded Successfullly'.

        APPEND gwa_alv_data TO gt_alv_data.

        CLEAR : gwa_alv_data.

      ENDIF.

    ENDIF.

    CLEAR : lt_bp1012[].

  ENDLOOP.

*

  IF gt_alv_data IS NOT INITIAL.

    DATA: lx_msg TYPE REF TO cx_salv_msg.

*

    TRY.



        cl_salv_table=>factory(

          IMPORTING

            r_salv_table = o_alv

          CHANGING

            t_table      = gt_alv_data ).

      CATCH cx_salv_msg INTO lx_msg.                    "#EC NO_HANDLER

    ENDTRY.

*

    o_cols = o_alv->get_columns( ).

*

*   set the Column optimization

    o_cols->set_optimize( 'X' ).

*

    TRY.

        o_column = o_cols->get_column( 'PARTNER' ).

        o_column->set_long_text( 'Business Partner' ).

        o_column->set_medium_text( 'Business Partner' ).

        o_column->set_short_text( 'BP' ).

        o_column->set_output_length( 10 ).

*

        o_column = o_cols->get_column( 'STATUS' ).

        o_column->set_long_text( 'Status' ).

        o_column->set_medium_text( 'Status' ).

        o_column->set_short_text( 'Status' ).

        o_column->set_output_length( 5 ).

*

        o_column = o_cols->get_column( 'MESSAGE' ).

        o_column->set_long_text( 'Message Text' ).

        o_column->set_medium_text( 'Message Text' ).

        o_column->set_short_text( 'Message' ).

        o_column->set_output_length( 50 ).

*

      CATCH cx_salv_not_found.                          "#EC NO_HANDLER

    ENDTRY.

*

    o_alv->display( ).

  ELSE.

    MESSAGE 'No Data to Display' TYPE 'I'.

  ENDIF.

Please find the below image, Which shows you the sample input Excel file format to upload data.

 

Rating ProducerCreditlim
TextActual Credit Limit


5. Review Business Partner :

Transaction Code: BP

Review the credit limit upload in the Business Partner.

Creating a Class And Method:


Create a class and method with holds the logic to fetch the credit limit from the BP1012 table.

Transaction Code: SE24

1. Create a Class:

Class Name: Zcredit


2. Create a method :

Method NameZCREDIT_CALCULATE
LevelStatic Method
VisibilityPublic


Source Code for Method : ZCREDIT_CALCULATE

  METHOD zcredit_calculate.

    DATA: lv_field1 TYPE bp1012-text.

    DATA: dref1 TYPE REF TO char60.

    FIELD-SYMBOLS: <fs_field1> TYPE any.

    BREAK-POINT.

    CREATE DATA dref1 TYPE bp1012-text.



    ASSIGN dref1->* TO <fs_field1>.



    SELECT SINGLE text FROM bp1012 INTO lv_field1 WHERE partner = i_partner AND grade_method ='Creditlim'.

    IF sy-subrc = 0.

      IF <fs_field1> IS ASSIGNED.

        <fs_field1> = lv_field1.

        r_result = <fs_field1>.

*        GET REFERENCE OF <fs_field1> INTO r_result.

      ENDIF.

*      CLEAR: lwa_partner.

    ENDIF.



  ENDMETHOD.


 

Please find the parameter details:



3. Create Implementation in BADI - UKM_EV_FORMULA:
Create Implementation in BADI - UKM_EV_FORMULA ( Custom Implementation - ZUKM_EV_FORMULA )
 

Transaction Code: SE18

4. Sample Code Snippet to add function to Formula Editor:

Open the custom implementation: ZUKM_EV_FORMULA

Transaction Code: SE18

Implement the BADI “ZUKM_EV_FORMULA” with the below code in the method “ADD_FIELDS”.

  METHOD if_ex_ukm_ev_formula~add_fields.

    CONSTANTS: lc_empty  TYPE sfbefsym VALUE '',

               lc_bp_gen TYPE sfbefsym VALUE 'ZITOCHUCL'.

    DATA: lv_check TYPE sfbeoprnd.



    CASE i_key.

      WHEN 'FUNCS'.

        CLEAR lv_check.

        lv_check-tech_name = 'ZITOCHUCL'.

        lv_check-class = 'ZCREDIT'.

        lv_check-method = 'ZCREDIT_CALCULATE'.

        APPEND lv_check TO ct_operands.



      WHEN OTHERS.

    ENDCASE.

  ENDMETHOD.

5. Define Formulas:

Path:SPRO -SAP Customizing Implementation Guide → Financial Supply Chain Management → Credit Management → Credit Risk Monitoring→ Define Formulas


After defining new Formula (ex: ZFSCM), click on the button “Formula Editor” to define the required formulas for custom fields.

FormulaZFSCM
Formula NameCredit Limit for Business Customers
Result TypeLIMIT Calculation of Credit Limit


Call the custom function and pass the Business partner as parameter.

6. UKM_MASS_UPD3:

With this job template, you can trigger a re-evaluation of the rules for calculating the credit limit for business partners. In effect, the credit limits in the credit accounts of the selected business partners are updated. This job enables you to perform a mass update of the credit limits.

You can restrict to the following criteria for your job:

    • Business Partner
    • Rating procedure
    • Credit segment
    • Valid-to date of the credit limit

You can restrict you selection further:

    • If you select the field Only Blocked in Credit Management, then only those credit accounts that are blocked in Credit Management are selected.
    • If you select the field Only Special Attention, only those credit accounts that are marked for special attention are selected.

You can create credit segments that have been maintained in Customizing but that do not yet exist in the selected business partner.

You have the following options to schedule the job:

    • In a test run, you only receive a list as output.
    • In a test run with a simulation, you can enter a rule for the score/limit and then carry out a simulation run.
    • In an update run, the changes are updated in the Credit Management data of the business partner.

Result:

You receive a list of all business partners and credit accounts that meet the selection criteria and that have been changed.

Case 1:Credit Limit - Not Maintained Manually 

1. Review Business Partners(Pre):

Transaction Code: BP

 

Business Partner17100001
Credit Segment0000
Credit Limit0
Valid DateNull

2. Run UKM_MASS_UPD3:

Transaction Code: UKM_MASS_UPD3

Run UKM_MASS_UPD3 for BP in Update Run.

Business Partner17100001
Credit Segment0000
Update RunChecked
Set Valid to date31/05/2023

Now, the new credit Limit is calculated and got updated in Business Partner Master.

3.Review Busniess Partness(Post):

Transaction Code: BP

 

Business Partner17100001
Credit Segment0000
Credit Limit99,999,910.11
Valid Date31.05.9999

Credit Limit Updated in a business partner.

Case 2:Credit Limit - Maintained Manually 

1. Review Busniess Partness(Pre):

Transaction Code: BP

 

Business Partner17100001
Credit Segment0000
Credit Limit99,999,910.11
Valid Date31.05.9999

2. Run UKM_MASS_UPD3:

Transaction Code: UKM_MASS_UPD3

In this case, UKM_Mass_UPD3 Will not work.

Sap Note: https://me.sap.com/notes/2937809

Define data type UKM_CHVALID:

    • Transaction Code: SE11
    • Select 'Data type'; Enter: UKM_CHVALID; Button: Create
    • Choose 'Data element'
    • Add a short description: 'Forced change of Credit limit'
    • Under tab 'Data Type' enter XFELD as the Domain.
    • Under the tab 'Field Label' set the following description

        • Short 10 'forced ch.'

        • Medium 15 'forced change'

        • Long 20 'forced change of Credit limit'
    • Save the data element in package UKM_MASSDATA_PROCESSING and activate it.
    • Define new message 031 in message class UKM_MS with the text 'All changes made manually to the credit limit will be overwritten.' This shall be self-explanatory.



Run UKM_MASS_UPD3 for BP in Update Run.

Business Partner17100001
Credit Segment0000
Update RunChecked
Set Valid to date31/05/2023

 

Forced Change of Credit LimitChecked


 


Now, the new credit Limit is calculated and got updated in Business Partner Master.

3. Review Busniess Partness (Post):

Transaction Code: BP

 

Business Partner17100001
Credit Segment0000
Credit Limit123,456.00
Valid Date31.05.9999

Credit Limit Updated in a business partner.

Conclusion:

By following the above steps you can manually upload the credit limit to the business partner with simple configurations and enhancements.

2 Comments
stefan_schmidt
Explorer
0 Kudos

This is a highly sophisticated approach. My Respect.

SNK
Explorer
0 Kudos

hello GOWRESHANHARAN,

Good one and thanks for this blog . appreciate your efforts .

2 questions , hope you can answer .

1. FM "FS_API_BP1012_ADD" is not released by SAP , is this safe to use ?

2. did you noticed any difference with latest S4 HANA 2023 version ?

Thanks Sirigiri.

 

Labels in this area