βš™οΈSAPTools

BSEG: Accounting Document Segment

FI

BSEG stores the line items of FI accounting documents: one row per document line with the G/L account, cost center and the amounts in local and document currency. The document header is in BKPF.

Primary key

BUKRS + BELNR + GJAHR + BUZEI

plus the client field

Module

FI

Fields in this reference

9

How the BSEG key works

The primary key is MANDT, BUKRS, BELNR, GJAHR and BUZEI. The first four fields identify the document in BKPF and BUZEI is the line item number.

BSEG fields

FieldType / data elementLengthDescription
πŸ”‘MANDTCLNT3Client
πŸ”‘BUKRSBUKRS4Company Code
πŸ”‘BELNRBELNR10Document Number
πŸ”‘GJAHRGJAHR4Fiscal Year
πŸ”‘BUZEIBUZEI3Line Item Number
HKONTHKONT10G/L Account
KOSTLKOSTL10Cost Center
DMBTRDMBTR15Amount in Local Currency
WRBTRWRBTR15Amount in Document Currency

This is a curated subset of the most commonly used fields, not the complete table definition. A real system contains more fields and can differ by release and customizing, so confirm the definition in transaction SE11 before relying on it.

Example ABAP SELECT for BSEG

" Open SQL applies the client (MANDT) automatically, so it is not part of the WHERE clause.
DATA lv_bukrs TYPE bseg-bukrs.
DATA lv_belnr TYPE bseg-belnr.
DATA lv_gjahr TYPE bseg-gjahr.

SELECT buzei, hkont, kostl, dmbtr
  FROM bseg
  WHERE bukrs = @lv_bukrs
    AND belnr = @lv_belnr
    AND gjahr = @lv_gjahr
  INTO TABLE @DATA(lt_bseg).

Modern Open SQL with host variables (ABAP 7.40 and later). Need a different field list or conditions? Build it in the ABAP SELECT Builder.

BSEG in SAP S/4HANA

In ECC, BSEG is a cluster table, which means it cannot be used in database joins and conditions on non-key fields are slow. In SAP S/4HANA the Universal Journal table ACDOCA is the primary source for FI line items, so check the simplification list of your release before building new reports on BSEG.

Tables related to BSEG

  • BKPF (joined on BUKRS + BELNR + GJAHR): Header of the document.
  • SKA1 (joined on HKONT = SAKNR): G/L account master data at chart-of-accounts level.
  • SKB1 (joined on BUKRS + HKONT = SAKNR): G/L account master data at company-code level.

Practical tips for BSEG

  • For open and cleared items in ECC, use the secondary index tables instead of scanning BSEG: BSIS and BSAS for G/L accounts, BSID and BSAD for customers, BSIK and BSAK for vendors.
  • DMBTR is the amount in local currency and WRBTR the amount in document currency. The sign depends on the debit/credit indicator SHKZG.
  • When reading a single document, always supply BUKRS, BELNR and GJAHR. Selecting by G/L account alone on a cluster table is slow.

BSEG FAQ

Why is selecting from BSEG slow?

In ECC it is a cluster table, so conditions on fields other than the document key cannot be evaluated by the database alone and the data has to be read and unpacked first. Use the secondary index tables, or ACDOCA in S/4HANA.

What is the primary key of BSEG?

MANDT, BUKRS, BELNR, GJAHR and BUZEI: the document key from BKPF plus the line item number.

Keep exploring