# SAP ABAP Vendor Open Items SELECT Generator (BSIK)

> Source: https://netray.co/tools/sap-abap-open-items-select-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Fill in company code, vendor range and key date to get a ready-to-edit ABAP report that lists open vendor items with an overdue calculation.

## Category

developer

## Erp

SAP ECC / S/4HANA

## Audience

- ABAP developer
- SAP FICO consultant
- Finance analyst

## Tool

**Kind:** template

**Output:** code

**Language:** abap

**Fields:**

#### Program name

**Key:** program

**Type:** text

**Default:** ZFI_VENDOR_OPEN_ITEMS

#### Company code

**Key:** bukrs

**Type:** text

**Default:** 1000

#### Vendor from

**Key:** lifnr_from

**Type:** text

**Default:** 0000100000

#### Vendor to

**Key:** lifnr_to

**Type:** text

**Default:** 0000199999

#### Key date (YYYYMMDD)

**Key:** key_date

**Type:** text

**Default:** 20261031

#### Max rows

**Key:** max_rows

**Type:** number

**Default:** 5000

**Blocks:**

#### Report skeleton

**Body:** REPORT {{program}}.

TYPES: BEGIN OF ty_item,
         bukrs TYPE bsik-bukrs,
         lifnr TYPE bsik-lifnr,
         belnr TYPE bsik-belnr,
         gjahr TYPE bsik-gjahr,
         buzei TYPE bsik-buzei,
         budat TYPE bsik-budat,
         bldat TYPE bsik-bldat,
         blart TYPE bsik-blart,
         shkzg TYPE bsik-shkzg,
         dmbtr TYPE bsik-dmbtr,
         waers TYPE bsik-waers,
         zfbdt TYPE bsik-zfbdt,
         zbd1t TYPE bsik-zbd1t,
         due_date TYPE d,
         days_over TYPE i,
       END OF ty_item.

DATA: lt_items TYPE STANDARD TABLE OF ty_item,
      ls_item  TYPE ty_item.

DATA: lv_key_date TYPE d VALUE '{{key_date}}'.

#### Selection

**Body:** SELECT bukrs lifnr belnr gjahr buzei budat bldat blart shkzg dmbtr waers zfbdt zbd1t
  FROM bsik
  INTO CORRESPONDING FIELDS OF TABLE lt_items
  UP TO {{max_rows}} ROWS
  WHERE bukrs = '{{bukrs}}'
    AND lifnr BETWEEN '{{lifnr_from}}' AND '{{lifnr_to}}'
    AND budat <= lv_key_date.

IF sy-subrc <> 0.
  WRITE: / 'No open items found'.
  RETURN.
ENDIF.

#### Overdue calculation and output

**Body:** LOOP AT lt_items INTO ls_item.
  ls_item-due_date = ls_item-zfbdt + ls_item-zbd1t.
  ls_item-days_over = lv_key_date - ls_item-due_date.
  IF ls_item-shkzg = 'H'.
    ls_item-dmbtr = ls_item-dmbtr * -1.
  ENDIF.
  MODIFY lt_items FROM ls_item.
ENDLOOP.

SORT lt_items BY lifnr days_over DESCENDING.

LOOP AT lt_items INTO ls_item.
  WRITE: / ls_item-lifnr, ls_item-belnr, ls_item-gjahr, ls_item-budat,
           ls_item-dmbtr, ls_item-waers, ls_item-days_over.
ENDLOOP.

**Notes:** BSIK holds items that are open today. Items posted before the key date but cleared since then are not in BSIK, so this is not a true historical open items list; for that, read BSAK as well and filter on clearing date (AUGDT). In S/4HANA BSIK is a compatibility view, and CDS views or ACDOCA are preferred for new development. DMBTR is in local currency; the sign comes from SHKZG (S debit, H credit). The due date is baseline date plus the first payment term days and ignores cash discount logic.

## Content

**Intro:** A quick ABAP report over vendor open items is one of the most common requests a FICO consultant gets. This generator produces a working skeleton against BSIK that you can adapt, test in a sandbox, and move through your normal transport process.

**Sections:**

#### How to use the generator

**Body:** Enter your company code, the vendor number range and a key date, and the code updates on the right. Copy it into SE38 or ADT, activate and run it in a development client. The vendor numbers are padded with leading zeros because LIFNR is a ten-character field. Adapt the output to an ALV grid before releasing it to users.

**Bullets:**

- Check that the vendor range is padded to ten characters.
- Use a company code authority check before productive use.
- Replace WRITE with CL_SALV_TABLE for a real report.

#### What the code does

**Body:** The SELECT reads the items for one company code and vendor range posted up to the key date. The loop calculates the due date from the baseline date (ZFBDT) plus the first payment term day count (ZBD1T), then derives days overdue against the key date and flips the sign of credit items, indicated by SHKZG equal to H. The sort puts the most overdue items per vendor first.

#### Limits and S/4HANA notes

**Body:** BSIK is current-state only. For a month-end aged payables report that must be reproducible later you need both open and cleared items with a clearing date after the key date, or you should use the standard aged-items reports. In S/4HANA new code should read the standard CDS views or ACDOCA. Foreign currency amounts are in WRBTR, not DMBTR, so decide which currency your report needs.

#### Common mistakes

**Body:** Developers often forget the authority check on BUKRS, select without UP TO or restrictions on large systems, or mix local and document currency totals in one column. Another mistake is treating the due date as the net due date without payment term days 2 and 3 for discounts. Test with a vendor who has credit memos and down payments, since both look different from simple invoices.

**Cta:** If you write many one-off finance reports like this, Netray can discuss a read-only layer that answers open items questions in plain language and shows the SQL it used.

**Faq:**

#### Does this work for customers too?

**Answer:** The pattern is the same with BSID instead of BSIK and KUNNR instead of LIFNR. Change the table name, the key field and the range fields. The sign logic with SHKZG applies in the same way.

#### Why does the report miss items cleared after the key date?

**Answer:** BSIK only has items that are open now. An item open on the key date but cleared later is in BSAK. A historical open items report must read BSAK with a clearing date after the key date and combine it with BSIK.

#### Can I run this in S/4HANA?

**Answer:** BSIK is available as a compatibility view in S/4HANA, so simple reports usually run. For new development SAP recommends reading ACDOCA or released CDS views, which perform better and survive future changes.

#### How do I convert it to an ALV?

**Answer:** Replace the WRITE loop with CL_SALV_TABLE=>FACTORY, passing lt_items, then call the display method. Add column headings from the data elements for a proper layout.

## Search terms

abap select bsik open items, sap vendor open items abap report, abap bsik select where, sap open items key date abap, sap abap fi report template, abap overdue days vendor items, bsik abap code example, sap ap aging abap

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
