Developer ToolsFree generatorPDF, Excel, Word exportSAP ECC / S/4HANA

SAP ABAP Vendor Open Items SELECT Generator (BSIK)

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.

Fill in

Generated code
Download:

Report skeleton

REPORT ZFI_VENDOR_OPEN_ITEMS.

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 '20261031'.

Selection

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 5000 ROWS
  WHERE bukrs = '1000'
    AND lifnr BETWEEN '0000100000' AND '0000199999'
    AND budat <= lv_key_date.

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

Overdue calculation and output

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.

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.

Skip the ABAP for routine finance questions

Ask how a read-only assistant over your SAP data could answer open item and aging questions without custom reports.

Optional. The tool and every export work without this. No spam.

How to use the generator

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.

  • 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

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

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

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.

Frequently Asked Questions

Does this work for customers too?

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?

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?

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?

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.

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.