Credit Limit for Customer in SAP SD post will detail all the important Data for Credit calculation for Customer in SAP SD .
It includes determination of credit control area, Calculation of Credit horizon date, and determination of Credit Exposure in SAP SD.
Retriving Credit control area
Credit Control Area can be retrieve from the Company code.
The Value of Credit Control Area ( KKBER ) is stored in SAP Table T001-KKBER.
Here a sample ABAP Program to retrieve Credit Control Area for a SAP company code based on Sales Organisation:
" SAP CUSTOMER CREDIT AREA CONTROL
SELECT SINGLE t001~kkber tvko~waers
INTO (lv_kkber, lv_waers_comp)
FROM tvko AS tvko
INNER JOIN t001 AS t001
ON tvko~bukrs = t001~bukrs
WHERE tvko~vkorg = IV_VKORG.
Retrieving Risk Category for customer
The Risk Category classifies Customer on Credit risk exposure.
Technically it is stored in SAP Table KNKK Customer master credit management: Control area data
and the field CTLPC : Credit management: Risk category. This information is set by Risk Control Area
The field KNKK-CASHD Date of Last Payment is also a relevant field when dealing with Credit Limit.
Here a sample ABAP program code to retrieve Risk Category for SAP SD Customer:
" Retriving Risk Category for Customer in SAP SD
SELECT SINGLE ctlpc cashd
INTO (lv_ctlpc, lv_cashd)
WHERE kunnr = IV_KUNNR
AND kkber = l_kkber.
" Get Currency of Risk Category
SELECT SINGLE waers
WHERE kkber = lv_kkber.
SAP SD Credit Horizon Date
In order to understand the calculation of SD credit Horizon Date check this OSS note 379007. This note explains the mechanism of horizon date calculation.
The SD Credit Horizon Date can be calculated with the following standard Function Module SD_CREDIT_HORIZON_DATE.
Here a sample ABAP Programs to retrieve this information:
" Calculate Credit Horizon Date ( Credit limit )
CALL FUNCTION 'SD_CREDIT_HORIZON_DATE'
i_kkber = lv_kkber
i_ctlpc = lv_ctlpc
i_horizon_exist = 'X'
e_horizon_date = lv_horda.
" If no Credit Horizon Date found, set it to max date
IF lv_horda IS INITIAL.
lv_horda = '99991231'.
This SCN Wiki page details the mechanism of Credit Horizon Date calculation. It is well written and step by step detailed.
SAP SD Customer Credit Exposure
SD Credit Exposure is the sum of Open Delivery, Open Invoice + Open Order.
The different values can be retrieve using the standard function module SD_CREDIT_EXPOSURE.
A sample ABAP Code to retrieve the Credit Exposure in order to calculate Credit Limit for a SAP Customer in SAP SD will be:
(check above how to retrieve Horizon Date HORDA and Credit Area Control KKBER )
" SD_CREDIT_EXPOSURE For SAP Customer
CALL FUNCTION 'SD_CREDIT_EXPOSURE'
flag_open_delivery = 'X'
flag_open_invoice = 'X'
flag_open_order = 'X'
horizon_date = lv_horda
kkber = lv_kkber
knkli = IV_KUNNR
open_delivery = lv_open_deliv
open_invoice = lv_open_inv
open_order = lv_open_ord.
" Credit Exposure is the sum of Open Delivery, Open Invoice + Open Order
LV_CREDIT_EXPOSURE = lv_open_deliv + lv_open_inv + lv_open_ord.
Credit Limit for SD Customer
The credit limit for SD Customer is set on SAP tcode/ Transaction FD32/FD33.
The corresponding field is KLIMK Customer’s credit limit in the table KNKK containing Customer master credit management: Control area data
The keys to retrieve Customer Credit Limit in SAP SD ( KNKK-KLIMK) are :
- KNKK-KUNNR : Customer Number
- KNKK-KKBER : Credit control area