Managing Customer Credit Limits Programmatically in ABAP
Creating or Updating Credit Limits
Use BAPI_BUPA_CREDITLIMIT_CHANGE to assign or adjust a credit limit for a business partner. If no record exists for the specified validity period, the function creates one; otherwice it updates the matching entry.
DATA: lr_bp TYPE bupa_pd_number,
lr_limit TYPE bapibus1003_cl_amt,
lr_ccy TYPE bapibus1003_cl_curr,
lr_from TYPE bapibus1003_cl_validfrom,
lr_to TYPE bapibus1003_cl_validto.
lr_bp = '0000000001'.
lr_limit = 25000.
lr_ccy = 'USD'.
lr_from = '20240101'.
lr_to = '99991231'.
CALL FUNCTION 'BAPI_BUPA_CREDITLIMIT_CHANGE'
EXPORTING
businesspartner = lr_bp
creditlimit = lr_limit
creditlimit_curr = lr_ccy
validfrom = lr_from
validto = lr_to.
IF sy-subrc = 0.
WRITE: / 'Credit limit persisted'.
ELSE.
WRITE: / 'Update terminated with errors'.
ENDIF.
Removing a Credit Limit
Standard SAP does not expose a dedicated deletion BAPI for this object. To effectively remove a limit, overwrite the amount with zero and expire the validity interval by setting the end date to a point in the past.
lr_limit = 0.
lr_to = '20200101'. " Force expiration
CALL FUNCTION 'BAPI_BUPA_CREDITLIMIT_CHANGE'
EXPORTING
businesspartner = lr_bp
creditlimit = lr_limit
creditlimit_curr = lr_ccy
validfrom = lr_from
validto = lr_to.
Simulating Freeze and Release
BAPI_BUPA_CREDITLIMIT_CHANGE does not accept a dedicated status parameter for blocking or unblocking credit. Two common workarounds are validity manipulation and custom fields.
Option A: Validity-Based Blocking
Adjust the validity horizon so the record becomes inactive or active.
Freeze by ending the interval today:
lr_to = sy-datum.
CALL FUNCTION 'BAPI_BUPA_CREDITLIMIT_CHANGE'
EXPORTING
businesspartner = lr_bp
creditlimit = lr_limit
creditlimit_curr = lr_ccy
validfrom = lr_from
validto = lr_to.
Release by extending the interval into the future:
lr_to = '99991231'.
CALL FUNCTION 'BAPI_BUPA_CREDITLIMIT_CHANGE'
EXPORTING
businesspartner = lr_bp
creditlimit = lr_limit
creditlimit_curr = lr_ccy
validfrom = lr_from
validto = lr_to.
Option B: Custom Extension
If the standard validity approach does not satisfy business requirements, append a custom status indicator to the credit limit object via a customer include and update it through a custom wrapper or enhancement. This requires explicit implementation in the customer namespace and is only necessary when the date-driven method proves insufficient.