# SAP Open Purchase Order Items ABAP Report Generator

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

## Short answer

Builds an ABAP report that selects open PO schedule lines with open quantity from EKKO, EKPO and EKET, filtered by purchasing organisation, plant, document type and date.

## Category

sap

## Erp

SAP S/4HANA

## Audience

- ABAP developer
- SAP MM consultant
- Buyer
- Procurement analyst

## Tool

**Kind:** template

**Output:** code

**Language:** abap

**Fields:**

#### Purchasing organisation

**Key:** ekorg

**Type:** text

**Default:** 1000

#### Plant

**Key:** plant

**Type:** text

**Default:** 1000

#### Document type

**Key:** bsart

**Type:** select

**Options:**

- NB
- FO
- UB

**Default:** NB

**Help:** NB = standard PO, FO = framework order, UB = stock transport order

#### Delivery date up to (YYYYMMDD)

**Key:** date_to

**Type:** text

**Default:** 20261130

#### Report name

**Key:** report

**Type:** text

**Default:** ZMM_OPEN_PO_ITEMS

**Blocks:**

REPORT {{report}}.

* Open PO schedule lines: not deleted, delivery not completed,
* scheduled on or before the entered date.

SELECT k~ebeln,
       p~ebelp,
       k~lifnr,
       k~bsart,
       p~matnr,
       p~werks,
       p~meins,
       e~eindt,
       e~menge AS sched_qty,
       e~wemng AS received_qty
  FROM ekko AS k
  INNER JOIN ekpo AS p ON p~ebeln = k~ebeln
  INNER JOIN eket AS e ON e~ebeln = p~ebeln
                      AND e~ebelp = p~ebelp
  WHERE k~ekorg = '{{ekorg}}'
    AND k~bsart = '{{bsart}}'
    AND k~loekz = @space
    AND p~werks = '{{plant}}'
    AND p~loekz = @space
    AND p~elikz = @space
    AND e~eindt <= '{{date_to}}'
  ORDER BY e~eindt, k~ebeln, p~ebelp
  INTO TABLE @DATA(lt_items).

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

LOOP AT lt_items INTO DATA(ls_item).
  DATA(lv_open) = ls_item-sched_qty - ls_item-received_qty.
  IF lv_open <= 0.
    CONTINUE.
  ENDIF.
  WRITE: / ls_item-ebeln, ls_item-ebelp, ls_item-lifnr,
           ls_item-matnr, ls_item-eindt, lv_open, ls_item-meins.
ENDLOOP.

**Notes:** Open quantity is scheduled quantity (EKET-MENGE) minus received quantity (EKET-WEMNG). The delivery completed indicator is EKPO-ELIKZ and the deletion indicator is LOEKZ. Requires ABAP 7.40 or higher for inline declarations. Test in a development system, and add authority checks on purchasing organisation (M_BEST_EKO) and plant (M_BEST_WRK) before productive use. For large systems, add a WHERE clause on document date to limit volume.

## Content

**Intro:** Standard transaction ME2N and ME2M list open purchase orders, but teams often need a custom report with specific filters or an output for a downstream tool. This generator builds an ABAP report that joins the three core purchasing tables and calculates open quantity per schedule line.

**Sections:**

#### How to use the generator

**Body:** Fill in the purchasing organisation, plant, document type and the latest delivery date you care about, then give your report a Z name. Copy the generated code into SE38 or an ABAP development tool in Eclipse, activate it and run it. It lists each open schedule line with vendor, material, delivery date and open quantity. Adjust the output section to use a class such as the ALV grid if you need sorting, filtering and export from the report itself.

**Bullets:**

- Use a development system first
- Add select options for broader filters
- Keep the select list short for performance

#### How the tables relate

**Body:** EKKO holds the purchasing document header with the vendor, purchasing organisation and document type. EKPO holds items with material, plant, unit of measure and indicators for deletion and delivery completed. EKET holds the schedule lines, with scheduled quantity, delivery date and the quantity already received. A purchase order item can have several schedule lines, so open quantity should be calculated per schedule line, not per item. Joining on document and item keeps the three consistent.

#### Making it production ready

**Body:** Replace hard-coded values with a selection screen using SELECT-OPTIONS or PARAMETERS, add authority checks for the purchasing organisation and plant, and consider limiting by document date to avoid reading years of history. On large systems add an index-friendly filter, and for very high volume consider a CDS view or standard purchase order analytical views rather than custom joins. Check whether your release exposes released CDS views for purchasing documents, which are preferable in S/4HANA extension scenarios.

#### Common mistakes

**Body:** Forgetting the deletion and delivery completed indicators produces closed or cancelled items in the list. Treating item quantity as open quantity misses partial deliveries. Skipping unit of measure conversion can mislead when order units differ from base units. Note also that subcontracting and scheduling agreement items follow different logic in the tables.

**Bullets:**

- Filter LOEKZ and ELIKZ
- Use EKET for open quantity
- Check order unit versus base unit

**Cta:** Netray can answer open order questions in plain language over your SAP data, showing the query it ran, read-only and respecting your authorisations.

**Faq:**

#### Which tables hold purchase order data?

**Answer:** EKKO is the header, EKPO the item, EKET the schedule lines, and EKBE the document history of goods receipts and invoices. Conditions are in the KONV table in older releases and in PRCD_ELEMENTS in S/4HANA.

#### How do I find open quantity on a PO?

**Answer:** Subtract the received quantity from the scheduled quantity for each schedule line in EKET (MENGE minus WEMNG). Alternatively compare item quantity with the sum of goods receipts in EKBE, which is slower.

#### What does ELIKZ mean?

**Answer:** It is the delivery completed indicator on the PO item. When set, the item is treated as fully delivered, even if the quantity is under-delivered, and MRP no longer plans the open quantity.

#### Can I use this code unchanged?

**Answer:** Treat it as a starting point. Field names are standard, but you should adjust it for your release, add authority checks, and test performance on production-sized data before scheduling it.

## Search terms

sap open purchase orders abap select, ekko ekpo eket join, sap open po report abap, sap open po quantity eket wemng, abap select purchase order items, sap me2n open orders custom report, sap open schedule lines query

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