# Automatic Email Alerts to Purchasing and Production for Usage Decisions and Quality Rejections

> A custom program run by a background job at short intervals that reads the usage decisions made since the last run and, for rejections, sends an email with material, batch, vendor, purchase order, rejected quantity and decision code to the purchasing group, the production supervisor or a quality distribution list depending on the origin of the inspection lot. Acceptances can be sent as a daily summary.

- 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/usage-decision-and-quality-rejection-email-alerts/


## Why is the standard not enough?

When a usage decision is made in QA11 or QA32, the standard system informs nobody automatically; follow-up actions of the usage decision do not send email without a custom function and do not determine the recipient by purchasing group. QA33 lists decisions afterwards but needs someone to look. The custom job determines the recipient by origin, prevents a second email for the same lot and logs the result.

### Closest standard alternatives

- QA33: Lists usage decisions and inspection lots; sends no notification to anyone.
- QA11: The usage decision is made here; email requires a custom function in the follow-up action.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| QAVE | Usage decisions: code, valuation, date and time (driving table) | Read | - | ECC + S/4 |
| QALS | Inspection lot: origin, material, batch, vendor, order | Read | QALS-PRUEFLOS = QAVE-PRUEFLOS | ECC + S/4 |
| QPCT | Text of the usage decision code | Read | QPCT-CODEGRUPPE = QAVE-VCODEGRP AND QPCT-CODE = QAVE-VCODE | ECC + S/4 |
| QAMB | Link from usage decision stock postings to material documents | Read | QAMB-PRUEFLOS = QALS-PRUEFLOS | ECC + S/4 |
| MSEG | Quantity moved to blocked stock or returned | Read | MSEG-MBLNR = QAMB-MBLNR AND MSEG-MJAHR = QAMB-MJAHR AND MSEG-ZEILE = QAMB-ZEILE | ECC + S/4 |
| EKKO | Purchasing group of the order | Read | EKKO-EBELN = QALS-EBELN | ECC + S/4 |
| T024 | Email address of the purchasing group | Read | T024-EKGRP = EKKO-EKGRP | ECC + S/4 |
| TVARVC | Timestamp of the last successful run | Read / write | TVARVC-NAME = P_VARNM | ECC + S/4 |

## BAPIs and functions used

- SO_DOCUMENT_SEND_API1: Sends the alert email

## 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 | No |
| S_HERK | Lot origin | Range / multiple | QALS-HERKUNFT | No |
| P_REJ | Send only rejections immediately | Checkbox | - | No |
| P_SUMM | Send acceptances as a daily summary | Checkbox | - | No |
| P_DLIST | Default distribution list | Single value | - | No |
| P_TEST | Test mode (list without sending) | Checkbox | - | No |

## Result list columns

| Column | Source |
|---|---|
| Inspection lot | QALS-PRUEFLOS |
| Origin | QALS-HERKUNFT |
| Material | QALS-MATNR |
| Batch | QALS-CHARG |
| Vendor | QALS-LIFNR |
| Purchase order | QALS-EBELN |
| Decision code | QAVE-VCODE |
| Valuation | QAVE-VBEWERTUNG |
| Rejected quantity | Calculated: Quantity moved to blocked stock or returned (QAMB → MSEG) |
| Recipient | Calculated: Purchasing group, production supervisor or distribution list |
| Status | Calculated: Sent, added to summary, no recipient or error |

## How does the program work?

1. The job runs every 15 minutes; the date and time of the last successful run are stored in TVARVC and updated at the end of the job.
2. Usage decisions made after this time are read from QAVE; the decision code and valuation (VBEWERTUNG: A accept, R reject) are taken and the code text comes from QPCT.
3. The inspection lot is read from QALS: origin (01 goods receipt, 04 production, 08 stock transfer etc.), material, batch, vendor, order and lot quantity. The quantity moved to blocked stock or returned is calculated from the usage decision stock postings (QAMB and the linked material document items).
4. Recipient: for goods receipt lots the email address of the order's purchasing group (T024-SMTP_ADDR), for production lots the production supervisor, for other origins the distribution list from the parameter.
5. The email with lot and decision data is sent with SO_DOCUMENT_SEND_API1; a second email for the same inspection lot is not sent. Acceptances can be sent once a day as a summary table.
6. At the end of the run, sent, recipient-not-found and failed records are listed in the log.

## Authorization objects

- Q_INSPTYPE: Inspection lot display authorization by inspection type
- S_BTCH_JOB: Authorization to schedule the background job
- S_OC_SEND: Authorization to send email

## Frequently asked questions

### Can the email be sent at the moment of the decision?

Yes: a function with the same logic can be attached to the usage decision follow-up action. The background job approach does not slow down the decision screen, an email problem does not block saving the decision and the resend check lives in one place. Either option is chosen as needed.

### Can inspection results be attached to the email?

Yes. Characteristic results (QAMR) can be added to the email as a table or as a PDF attachment, and a rejection report to share with the vendor can be produced as well. This adds 1–2 days to the estimate.

### Does it work on S/4HANA?

Yes. QALS, QAVE and T024 are the same in S/4HANA. If clean core is preferred, inspection lot data is read from I_InspectionLot; the BCS classes can be used for sending email.

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