MM Program Custom development Background program

Automatic Delivery Completed Flag for Old Open Purchase Order Items Program

Short answer: A custom background program that selects purchase order items by rule, those whose remaining quantity is below a tolerance or whose delivery date passed long ago with no goods receipt expected, and sets them to delivery completed. This cleans up open order lists and removes unnecessary order commitments on cost centers or projects.

Estimated effort
M · 3–5 working days
System
ECC and S/4HANA
Tables
4
Scope
Global
Built by
NeKuDos Teknoloji
Last updated

Why is the standard not enough?

The delivery completed flag is set by hand in ME22N item by item. Mass maintenance (MASS / MEMASSPO) needs the records to be selected by hand and does not apply business rules such as the remaining quantity percentage, days since the last goods receipt or invoices waiting. Items partially received years ago therefore keep showing as open in ME2N and remain as commitments in CJI5 or KSB1.

Who uses it? Purchasing teams, controlling teams that track budgets and commitments, MM teams responsible for year-end closing.

Closest standard alternatives

  • ME22N Change Purchase Order. Sets the delivery completed flag by hand on one order item.
  • ME2N Purchasing Documents per Document Number. Lists open items; cannot apply rules or set the flag.

Tables used

The tables the program reads and updates. ECC and S/4HANA differences are marked separately.

TableRoleAccessSystem
EKKOPurchasing Document HeaderOrder header: company code, purchasing organization, document type, vendor (driving table)ReadECC + S/4
EKPOPurchasing Document ItemOrder item: quantity and the delivery completed flag (ELIKZ) is updatedWriteECC + S/4
EKETPurchasing Schedule LinesSchedule line: latest delivery dateReadECC + S/4
EKBEPurchasing Document HistoryOrder history: received and invoiced quantity, last receipt dateReadECC + S/4

BAPIs and functions used

  • BAPI_PO_CHANGEChange Purchase Order. Sets the delivery completed indicator on the order item
  • BAPI_TRANSACTION_COMMITCommit a BAPI transaction. Saves the changes permanently per order
  • BAPI_TRANSACTION_ROLLBACKRoll Back BAPI Transaction. Rolls back changes in test mode or on error

Selection screen parameters

ParameterDescriptionTypeReference fieldRequiredExample
S_BUKRSCompany codeRange / multipleEKKO-BUKRSYes1000
S_EKORGPurchasing organizationRange / multipleEKKO-EKORGNo1000
S_BSARTOrder document typeRange / multipleEKKO-BSARTNoNB
S_WERKSPlantRange / multipleEKPO-WERKSNo1100
P_RULE1Rule 1: remaining quantity below toleranceCheckbox—NoX
P_TOLPCTRemaining quantity tolerance (%)Single value—No5
P_RULE2Rule 2: delivery date and last receipt are oldCheckbox—NoX
P_DAYSDays after the delivery dateSingle value—No90
P_TESTTest mode (list without changing)Checkbox—NoX

Result list columns

#ColumnSource
1Purchase orderEKPO-EBELN
2ItemEKPO-EBELP
3VendorEKKO-LIFNR
4MaterialEKPO-MATNR
5PlantEKPO-WERKS
6Order qtyEKPO-MENGE
7Received qtyCalculated Σ EKBE-MENGE (VGABE = 1, reversals negative)
8Remaining qtyCalculated EKPO-MENGE − received qty
9Remaining valueCalculated Remaining qty × EKPO-NETPR ÷ EKPO-PEINH
10Latest delivery dateEKET-EINDT
11Last goods receiptCalculated Latest EKBE-BUDAT (VGABE = 1)
12RuleCalculated The rule that made the item a candidate and its value
13StatusCalculated Completed, skipped or error
14MessageCalculated Skip reason or BAPI return message

Sample result list

Purchase orderItemVendorMaterialPlantOrder qtyReceived qtyRemaining qtyRemaining valueLatest delivery dateLast goods receiptRuleStatusMessage
450001248800010100245PK-1180110010,0009,70030055506/30/202607/02/2026Remaining 3% ≤ 5%CompletedDelivery completed flag set
450001230100030100387RM-204011002,0001,20080048,96005/15/202605/20/2026186 days past the delivery dateCompletedDelivery completed flag set
450001241500020100512CH-0315120040004003,64007/31/2026109 days past the delivery dateSkippedAn invoice is waiting for the item
A view built with fictional sample data; not real system data.

How does the program work?

  1. EKKO and EKPO are read by company code, purchasing organization, document type and plant; items whose delivery completed (ELIKZ) and deletion (LOEKZ) flags are blank and that expect a goods receipt remain.
  2. Net goods receipts (VGABE = 1) and invoiced quantity (VGABE = 2) are summed from EKBE and the last receipt date is found; the latest delivery date (EINDT) comes from EKET.
  3. Rule 1: remaining quantity ÷ order quantity × 100 ≤ tolerance percentage. Rule 2: the latest delivery date and the last goods receipt are older than P_DAYS days. If either rule is met, the item becomes a candidate.
  4. Exceptions: if the invoiced quantity is above the received quantity (invoice waiting), or an open inbound delivery or shipping notification exists, the item is skipped and the reason is written to the list.
  5. Candidates are changed per order with BAPI_PO_CHANGE using POITEM-NO_MORE_GR = X and the POITEMX flag; in test mode the BAPI runs with its test flag and BAPI_TRANSACTION_ROLLBACK follows. In a real run BAPI_TRANSACTION_COMMIT is done per order, and the result list can be emailed to the purchasing groups.

Performance notes

The first run can find thousands of old items; split it by purchasing group and run it in the background. Later monthly runs take a few minutes. Because BAPI_PO_CHANGE is called per order, locked orders fail and are retried in the next run.

Features

  • Test mode (check without posting)
  • Line-by-line result and error log
  • Runs as a background job
  • Send the result by email Closed and skipped items can be sent to each purchasing group as a separate list.

Authorization objects

  • M_BEST_BSAPurchase order change authorization by document type
  • M_BEST_EKOPurchase order change authorization by purchasing organization
  • M_BEST_WRKPurchase order change authorization by plant

Frequently asked questions

Can goods still be received on an item that was flagged?

Yes. The delivery completed flag does not block goods receipts; it only removes the item from open lists and commitments. If needed, the flag can be removed in ME22N.

How are project and cost center commitments affected?

The order commitment for the remaining quantity is reduced when the flag is set. The program is therefore also used to clean up inflated commitments in project and budget reports.

Does the program work on S/4HANA?

Yes. BAPI_PO_CHANGE and the order tables are the same in S/4HANA. Standard order closing apps in S/4HANA can also be used; this program adds company-specific rules and exceptions.

Related reports

CO Report Custom ALV report

Cost Center Plan vs Actual with Commitments Report

A custom ALV report that shows plan, actual and open purchasing commitments per cost center and cost element on one row, and calculates the remaining …

COSP · COSS · CSKS · CSKT

MM Report Custom ALV report

Open Purchase Orders by Vendor Report

A custom ALV report that shows, per vendor, the quantity not yet received, the open order value and the days of delay since the delivery date in a …

EKKO · EKPO · EKET · LFA1

Let us build this program for your system

Briefly describe your system and expectations. We will clarify the scope and come back with an effort and price quote.

Related report: Automatic Delivery Completed Flag for Old Open Purchase Order Items Program