# BAPI_AP_ACC_GETKEYDATEBALANCE — Vendor Account Balance at Key Date

> Calculates the balance of a vendor account in a company code at a key date, optionally split by special G/L indicator. It is used in payment approval workflows, vendor portals and credit checks of external systems. Pass the vendor number with leading zeros and read the balances from KEYBALANCE.

- Modules: FI
- Type: BAPI
- Function group: 3008
- Remote-enabled (RFC): Yes
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/bapi-ap-acc-getkeydatebalance/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| COMPANYCODE | BAPI3008_1-COMP_CODE | Company code | Yes |
| VENDOR | BAPI3008_1-VENDOR | Vendor | Yes |
| KEYDATE | BAPI3008-KEY_DATE | Key date | Yes |
| BALANCESPGLI | BAPI3008-BAL_SGLIND | Balance per special G/L indicator | - |
| NOTEDITEMS | BAPI3008-NTDITMS_RQ | Include noted items | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| RETURN | BAPIRETURN | Return message |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| KEYBALANCE | BAPI3008_3 | Balance at key date | Yes |

## Call template (ABAP)

```abap
CALL FUNCTION 'BAPI_AP_ACC_GETKEYDATEBALANCE'
  EXPORTING
    companycode = lv_companycode
    vendor = lv_vendor
    keydate = lv_keydate
  IMPORTING
    return = lv_return
  TABLES
    keybalance = lt_keybalance.
```

## Related tables

BSAK, BSIK

