客户信贷额度相关

1.查询客户信贷使用情况

函数:UKM_COMMTS_READ

FUNCTION zfmsd_credit_to_bi.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  EXPORTING
*"     VALUE(EV_TYPE) TYPE  BAPI_MTYP
*"     VALUE(EV_MSG) TYPE  BAPI_MSG
*"  TABLES
*"      IT_IN STRUCTURE  ZSSD0047
*"      ET_DATA STRUCTURE  ZSSD0048
*"----------------------------------------------------------------------
  DATA:lt_ukm_totals TYPE TABLE OF ukm_totals,
       ls_ukm_totals LIKE LINE OF lt_ukm_totals.

  IF it_in[] IS INITIAL.
    ev_type = 'E'.
    ev_msg = '信用段与客户必填'.
  ENDIF.

  IF it_in[] IS NOT INITIAL.

    "助记码
    SELECT partner,
           bu_sort1
      FROM but000
       FOR ALL ENTRIES IN @it_in[]
     WHERE partner = @it_in-kunnr
      INTO TABLE @DATA(lt_but000).
    SORT lt_but000 BY partner.

    "客户名称
    SELECT kunnr,
           name1,
           name2
      FROM kna1
       FOR ALL ENTRIES IN @it_in[]
     WHERE kunnr = @it_in-kunnr
      INTO TABLE @DATA(lt_kna1).
    SORT lt_kna1 BY kunnr.

    "应收单未审批金额
    SELECT credit_sgmnt,partner,zysdamount
      FROM ztsd0027
       FOR ALL ENTRIES IN @it_in[]
     WHERE credit_sgmnt = @it_in-credit_sgmnt
       AND partner = @it_in-kunnr
      INTO TABLE @DATA(lt_ztsd0027).
    SORT lt_ztsd0027 BY credit_sgmnt partner.
  ENDIF.

  LOOP AT it_in[] ASSIGNING FIELD-SYMBOL(<fs_in>).

    et_data-kunnr = <fs_in>-kunnr.
    et_data-credit_sgmnt = <fs_in>-credit_sgmnt.

    "助记码
    READ TABLE lt_but000 INTO DATA(ls_but000) WITH KEY partner = <fs_in>-kunnr BINARY SEARCH.
    IF sy-subrc EQ 0.
      et_data-sort1 = ls_but000-bu_sort1.
    ENDIF.

    "客户名称
    READ TABLE lt_kna1 INTO DATA(ls_kna1) WITH KEY kunnr = <fs_in>-kunnr BINARY SEARCH.
    IF sy-subrc EQ 0.
      et_data-name1 = ls_kna1-name1 && ls_kna1-name2.
    ENDIF.

    CALL FUNCTION 'UKM_COMMTS_READ'
      EXPORTING
        i_partner     = <fs_in>-kunnr
        i_segment     = <fs_in>-credit_sgmnt
      TABLES
        et_ukm_totals = lt_ukm_totals.

    LOOP AT lt_ukm_totals INTO ls_ukm_totals WHERE partner = <fs_in>-kunnr
                                               AND credit_sgmnt = <fs_in>-credit_sgmnt.
      "信贷风险类别
      et_data-comm_typ = ls_ukm_totals-comm_typ.

      "信贷风险类别描述
      SELECT SINGLE comm_typ_txt
        FROM ukmcomm_typest
        INTO et_data-comm_typ_txt
       WHERE comm_typ = et_data-comm_typ
         AND langu = sy-langu.

      "信用敞口金额
      IF et_data-comm_typ = '500'.
        "公司的期初上线方案导致重复信贷数据,重复信贷数据扣除的表是ZTSD0027,而在前台重复信贷金额会记录在500计费凭证值中
        "传给外围时需要扣除
        READ TABLE lt_ztsd0027 INTO DATA(ls_ztsd0027) WITH KEY credit_sgmnt = <fs_in>-credit_sgmnt
                                                               partner = <fs_in>-kunnr BINARY SEARCH.
        IF sy-subrc EQ 0.
          et_data-amount = ls_ukm_totals-amount - ls_ztsd0027-zysdamount.
        ELSE.
          et_data-amount = ls_ukm_totals-amount.
        ENDIF.
      ELSE.
        et_data-amount = ls_ukm_totals-amount.
      ENDIF.

      APPEND et_data TO et_data[].
      CLEAR:ls_ukm_totals.
    ENDLOOP.

    IF sy-subrc NE 0.
      APPEND et_data TO et_data[].
    ENDIF.

    CLEAR:lt_ukm_totals,ls_but000,ls_kna1,et_data.
  ENDLOOP.

ENDFUNCTION.

2.信贷额度检查时,扣减未审批金额

前提:BP中维护客户的信用规则是B2B-EXIST(无限额计算的公式)

BP模拟信用检查时:

1.在类CL_UKM_CREDIT_CHECK_SIMU-->CHECK_CREDIT_WORTHINESS中调用信用检查方法前,将对应的客户和信用段传进内存.

 2.在类CL_IM_UKM_CHECK_010-->IF_EX_UKM_CHECK_STEP~CHECK_STEP中将对应的信贷额度进行扣减或增加

 结果:

 客户下达销售订单或交货单计算信贷额度增强:

1.在类CL_UKM_XI_FACADE_R3_50-->IF_UKM_CREDIT_QUERY_R3~CHECK_CREDIT中调用信用检查方法前,将对应的客户和信用段传进内存.

 第二步跟上述BP代码一致,结果也可自行测

3.增加信贷类别计算时增加相应信贷类别额度计算

1.增加信用曝光类别:

 2.增加负债类别

 3.创建BADI实施,增加信用类别数据

  METHOD if_ex_ukm_fill~fill_fields.

    DATA: ls_in LIKE LINE OF is_notification.

    READ TABLE is_notification INTO DATA(ls_data) INDEX 1.
    "Without this conditional transaction UKM_CASE will dump.
    IF sy-tcode NE 'UKM_CASE' AND sy-tcode NE 'UKM_MY_DCDS'.
      CLEAR ls_in.
      SELECT *
        FROM ytest_credit
        INTO TABLE @DATA(lt_credit).

      LOOP AT lt_credit INTO DATA(ls_credit).
        ls_in-partner = ls_credit-partner.
        ls_in-credit_sgmnt = ls_credit-credit_sgmnt.
        ls_in-comm_typ = 'Z01'.
        ls_in-amount = ls_credit-amount.
        ls_in-currency = ls_credit-currency.
        APPEND ls_in TO is_notification.
      ENDLOOP.
*      ls_in-partner = '0001019367'. "BP
*      ls_in-credit_sgmnt = '1000'. "Credit segment
*      ls_in-comm_typ = 'Z01'. "Liability category
*      ls_in-amount = '1300'. "Value added to Credit Exposure
*      ls_in-currency = 'USD'. "Currency
*      ls_in-objkey = 'TFBV-00003-3000000001-31001588'. "Object key will be showed in reports
*      ls_in-objtype = 'MATNR'. "Customized object type
*      ls_in-date = '20200805'. "Date since BP is carrying debt, it will influence CM behaviour
*
*      APPEND ls_in TO is_notification.
*
*      CLEAR ls_in.
*      ls_in-partner = '0001019367'.
*      ls_in-credit_sgmnt = '1000'.
*      ls_in-comm_typ = 'Z01'.
*      ls_in-amount = '5200'.
*      ls_in-currency = 'USD'.
*      ls_in-objkey = 'TFBV-00003-3000000002-31001589'.
*      ls_in-objtype = 'MATNR'.
*      ls_in-date = '20200805'.
*
*      APPEND ls_in TO is_notification.
    ENDIF.

    EXPORT ukm_item = is_notification TO MEMORY ID 'UKM_ITEM'.

  ENDMETHOD.
posted @ 2024-08-13 17:47  阿胖的阿多  阅读(60)  评论(0编辑  收藏  举报