Offene & Ausgeglichene Posten

Buchungsdaten, offene Posten und Clearing-Informationen via OData.

S/4HANA Architectural Change

In SAP S/4HANA, the physical tables BSID (customer open items) and BSAD (customer cleared items) no longer exist as independent entities. Instead, they function as compatibility views layered over the unified ACDOCA (Accounting Documents) table.

SAP has migrated away from the dual-table architecture to a single source of truth. SAP provides CDS views and OData APIs that expose this data through standardized interfaces, eliminating the need for direct table access or custom compatibility views.

S/4HANA Standard APIs

Primary OData Service

API_OPLACCTGDOCITEMCUBE_SRV (OData v2)

Key Fields & Mapping

SAP FieldABAP FieldTypeDescription
CompanyCodeBUKRSString(4)Company code (e.g., '0001')
CustomerKUNNRString(10)Customer number
VendorLIFNRString(10)Vendor number
AccountingDocumentBELNRString(10)Document number
FiscalYearGJAHRString(4)Fiscal year
PostingDateBUDATDateDocument posting date
DocumentDateBLDATDateDocument date
AmountInCompanyCodeCurrencyDMBTRDecimal(23,2)Amount in company code currency
ClearingDocumentAUGBLString(10)Clearing document number
ClearingJournalEntryAUGBL + timestampString(10)Identifier for clearing transaction
ClearingDateAUGDTDateDate of clearing
DunningLevelMANSTString(1)Dunning level (0=no dunning)
IsClearedCalculatedBooleanLogical flag (true if ClearingDate is populated)
DueDateFÄLLIGKEITDatePayment due date (if applicable)

Query Examples

Open Items Only
GET /sap/opu/odata/sap/API_OPLACCTGDOCITEMCUBE_SRV/A_OperationalAcctgDocItemCube
  ?$filter=CompanyCode eq '0001' 
    and PostingDate ge datetime'2026-01-01T00:00:00'
    and IsCleared eq false
  &$top=1000
  &$skip=0
Cleared Items (Recent Clearings)
GET /sap/opu/odata/sap/API_OPLACCTGDOCITEMCUBE_SRV/A_OperationalAcctgDocItemCube
  ?$filter=CompanyCode eq '0001' 
    and ClearingDate ge datetime'2026-03-01T00:00:00'
    and ClearingDate le datetime'2026-03-31T23:59:59'
  &$top=1000
Specific Customer Open Items
GET /sap/opu/odata/sap/API_OPLACCTGDOCITEMCUBE_SRV/A_OperationalAcctgDocItemCube
  ?$filter=CompanyCode eq '0001' 
    and Customer eq '0000001234'
    and IsCleared eq false
  &$orderby=PostingDate desc
  &$select=Customer,AccountingDocument,FiscalYear,AmountInCompanyCodeCurrency,DueDate

ECC: Custom SEGW Implementation

In SAP ECC environments without S/4HANA, Bilendo implements custom OData services using the SEGW (Service Engineering Workbench) framework.

Entity Type Definition

Two separate entity types maintain architectural clarity:

ZBilendoOpenItem (BSID)
ZBilendoClearedItem (BSAD)

DPC Implementation

METHOD GET_ENTITYSET.
  " Entity: ZBilendoOpenItem (Open Customer Items)
  
  CASE i_entityset_name.
    WHEN 'ZBilendoOpenItems'.
      
      DATA: lt_open_items TYPE TABLE OF zbilendo_open_item,
            ls_filter TYPE LINE OF if_sadl_cds_range_list=>tt_range,
            lv_bukrs TYPE bukrs VALUE '',
            lv_budat_from TYPE budat,
            lv_budat_to TYPE budat,
            lv_umskz TYPE umskz VALUE ''.
      
      " Extract filter parameters from i_filter
      LOOP AT i_filter->get_ranges( ) INTO ls_filter.
        CASE ls_filter-name.
          WHEN 'CompanyCode'.
            READ TABLE ls_filter-ranges INTO DATA(ls_range) INDEX 1.
            lv_bukrs = ls_range-low.
          WHEN 'PostingDateFrom'.
            READ TABLE ls_filter-ranges INTO ls_range INDEX 1.
            lv_budat_from = ls_range-low.
          WHEN 'PostingDateTo'.
            READ TABLE ls_filter-ranges INTO ls_range INDEX 1.
            lv_budat_to = ls_range-low.
          WHEN 'TransactionCode'.
            READ TABLE ls_filter-ranges INTO ls_range INDEX 1.
            lv_umskz = ls_range-low.
        ENDCASE.
      ENDLOOP.
      
      " Query BSID with filters
      SELECT bukrs, kunnr, belnr, gjahr, budat, dmbtr, augbl, augdt, manst
        FROM bsid
        INTO CORRESPONDING FIELDS OF TABLE lt_open_items
        WHERE bukrs EQ lv_bukrs
          AND budat GE lv_budat_from
          AND budat LE lv_budat_to
          AND ( lv_umskz IS INITIAL OR umskz EQ lv_umskz )
        ORDER BY budat DESCENDING
        OFFSET i_skip ROWS
        FETCH NEXT i_top ROWS ONLY.
      
      et_entityset = CORRESPONDING #( lt_open_items ).
      
  ENDCASE.
  
ENDMETHOD.

Supported $Options

OptionExampleBehavior
$filterCompanyCode eq '0001' and PostingDate ge datetime'2026-01-01T00:00:00'Server-side filtering on CompanyCode, PostingDate, TransactionCode, Customer
$top$top=500Limits result rows (default: 500, max: 10000)
$skip$skip=1000Paging offset
$orderby$orderby=PostingDate descOrdering by PostingDate, DueDate, or AmountInCompanyCodeCurrency
$select$select=Customer,AccountingDocument,AmountInCompanyCodeCurrencyField projection

Ausgleichslogik (Clearing Logic)

Nullsummenausgleich (Zero-Sum Clearing)

When documents are cleared in SAP, a clearing journal entry (AUGBL/AUGDT) is recorded. The logical clearing status is determined by the presence of a non-null ClearingJournalEntry:

The ClearingDate field represents the posting date of the clearing transaction and is the basis for reconciliation reporting.

Innensaldoausgleich (Internal Offset) – Limitation

The OPAMT (open amount) field used for advanced internal offset calculations is not available in S/4HANA standard APIs or ECC custom services. The standard APIs provide the initial document amount (AmountInCompanyCodeCurrency) and clearing status only.

For innensaldoausgleich requirements, additional custom logic must be implemented via ABAP modules or journal entry detail querying.

Performance-Hinweise (Performance Guidelines)

Query Optimization

  1. Always Filter on CompanyCode + Date Range

    • Do NOT query without a CompanyCode filter; results are unpredictable across environments

    • Always include a PostingDate filter (e.g., last 12 months minimum)

    • Example: ?$filter=CompanyCode eq '0001' and PostingDate ge datetime'2025-01-01T00:00:00'

  2. Use Server-Driven Paging

    • Always include $top and $skip parameters

    • Recommended: $top=1000 per request

    • Total result sets exceeding 50,000 rows require batching across multiple requests

  3. Select Only Required Fields

    • Use $select to reduce payload size

    • Omitting large text fields (e.g., DocumentReference) can improve response time by 15–20%

Index Strategy

SystemTableIndexComments
S/4HANAACDOCA(BUKRS, BUDAT, LIFNR/KUNNR)Optimized for date-range queries
ECCBSID(BUKRS, KUNNR, BUDAT)Primary index for open items
ECCBSAD(BUKRS, BUDAT)Clearing date index on AUGDT

Typical Response Times (ECC 6.0, 1M+ documents)

Query TypeFilter ScopeResponse Time
Open items (single company, 90 days)10K rows200–400 ms
Cleared items (single company, 30 days)5K rows100–200 ms
Specific customer (all time)<500 rows50–100 ms

**