# Mass Usage Decision for Inspection Lots That Passed All Characteristics

> A custom background program that sets the usage decision with a chosen code for inspection lots whose characteristics were all accepted and that have no open quality notification, and posts the quality stock to unrestricted stock. Quality teams deal only with problem lots, and clean lots do not wait in stock.

- Type: Program, Custom development, Background program
- Module: QM
- Estimated effort: M (4–6 working days)
- Last updated: 2026-11-17
- URL: https://nekuhub.com/en/programs/mass-usage-decision-for-accepted-inspection-lots-program/


## Why is the standard not enough?

QA11 makes the usage decision for one lot. QA16 offers a collective decision for accepted lots, but it is a dialog and does not apply company-specific checks (open notification, minimum waiting time, selected inspection types). The automatic usage decision setting in the inspection type works with a single code per inspection type and does not report which lot was skipped and why.

### Closest standard alternatives

- QA11: Makes the usage decision for one lot.
- QA16: Offers a collective decision for accepted lots; it is a dialog and does not apply company-specific checks.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| QALS | Candidate inspection lots and quantity to be posted | Read | QALS-STAT35 = ' ' | ECC + S/4 |
| QAMV | Characteristics of the lot | Read | QAMV-PRUEFLOS = QALS-PRUEFLOS | ECC + S/4 |
| QAMR | Characteristic valuation; all must be accepted | Read | QAMR-PRUEFLOS = QAMV-PRUEFLOS AND QAMR-VORGLFNR = QAMV-VORGLFNR AND QAMR-MERKNR = QAMV-MERKNR | ECC + S/4 |
| QMEL | Open quality notification linked to the lot (check) | Read | QMEL-PRUEFLOS = QALS-PRUEFLOS | ECC + S/4 |
| QAVE | Usage decision that is set | Write | QAVE-PRUEFLOS = QALS-PRUEFLOS | ECC + S/4 |

## BAPIs and functions used

- BAPI_INSPLOT_GETSTATUS: Checks the lot status and that results recording is complete
- BAPI_INSPLOT_SETUSAGEDECISION: Sets the usage decision and posts the quality stock
- BAPI_TRANSACTION_COMMIT: Saves the decision permanently

## Selection screen parameters

| Parameter | Description | Type | Reference field | Required |
|---|---|---|---|---|
| S_WERK | Plant | Range / multiple | QALS-WERK | Yes |
| S_ART | Inspection type | Range / multiple | QALS-ART | Yes |
| S_HERK | Lot origin | Range / multiple | QALS-HERKUNFT | No |
| S_MATNR | Material | Range / multiple | QALS-MATNR | No |
| P_CODGRP | Usage decision code group | Single value | QAVE-VCODEGRP | Yes |
| P_VCODE | Usage decision code | Single value | QAVE-VCODE | Yes |
| P_MINAGE | Minimum days since lot creation | Single value | - | No |
| P_NOTIF | Skip lots with an open quality notification | Checkbox | - | No |
| P_TEST | Test mode (list without deciding) | Checkbox | - | No |

## Result list columns

| Column | Source |
|---|---|
| Inspection lot | QALS-PRUEFLOS |
| Material | QALS-MATNR |
| Batch | QALS-CHARG |
| Posted to unrestricted | QALS-LMENGEZUB |
| Unit | QALS-MENGENEINH |
| Decision code | QAVE-VCODE |
| Status | Calculated: Decided, eligible (test) or skipped |
| Message | Calculated: Reason for skipping or the BAPI return message |

## How does the program work?

1. Lots without a usage decision (QALS-STAT35 blank) and created at least the set number of days ago are read from QALS with the plant, inspection type, lot origin and material from the selection screen.
2. BAPI_INSPLOT_GETSTATUS checks that results recording is complete. Every characteristic in QAMV must have an accepting valuation in QAMR (MBEWERTG = A); lots with open or rejected characteristics are skipped.
3. If selected, lots with an open quality notification linked to the lot (QMEL-PRUEFLOS) are skipped.
4. BAPI_INSPLOT_SETUSAGEDECISION is called with the code group and code from the selection screen; the quantity still to be posted (LMENGEZUB) is posted to unrestricted stock.
5. In test mode only the eligible lots are listed; in a real run BAPI_TRANSACTION_COMMIT follows each lot. Decided and skipped lots are logged with their reasons and a summary is sent by email.

## Authorization objects

- Q_INSPTYPE: Inspection lot authorization by inspection type
- Q_GP_CODE: Authorization for the usage decision code group
- M_MSEG_WMB: Material document authorization by plant for the stock posting

## Frequently asked questions

### Which lots get a decision?

Only lots whose characteristics are all valuated as accepted, whose results recording is complete and, if selected, that have no open quality notification. All other lots are skipped and the reason is logged.

### Can stock be posted to a stock type other than unrestricted?

Yes. A target stock type (e.g. keep in quality stock, blocked stock) can be added to the selection screen, or the target can be set per inspection type.

### Can this program be used on S/4HANA?

Yes. BAPI_INSPLOT_SETUSAGEDECISION is supported on S/4HANA and the QM tables keep the same structure.

---
Let us build this program for your system: https://nekuhub.com/en/request-a-quote/?report=qm-mass-usage-decision
