QM Program Custom development Background program

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

Short answer: 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.

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

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.

Who uses it? Buyers, production planning, quality control and warehouse teams.

Closest standard alternatives

  • QA33 Display Data for Inspection Lot. Lists usage decisions and inspection lots; sends no notification to anyone.
  • QA11 Record Usage Decision. The usage decision is made here; email requires a custom function in the follow-up action.

Tables used

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

TableRoleAccessSystem
QAVEUsage DecisionUsage decisions: code, valuation, date and time (driving table)ReadECC + S/4
QALSInspection Lot RecordInspection lot: origin, material, batch, vendor, orderReadECC + S/4
QPCTCode TextsText of the usage decision codeReadECC + S/4
QAMBLink Between Inspection Lot and Material DocumentLink from usage decision stock postings to material documentsReadECC + S/4
MSEGMaterial Document ItemQuantity moved to blocked stock or returnedReadECC + S/4
EKKOPurchasing Document HeaderPurchasing group of the orderReadECC + S/4
T024Purchasing GroupsEmail address of the purchasing groupReadECC + S/4
TVARVCTable of Variant Variables (Client-Specific)Timestamp of the last successful runRead / writeECC + S/4

S/4HANA notes

  • MSEG → MATDOC: In S/4HANA MATDOC replaces MSEG; reading MSEG works through a compatibility view but is slow at high volumes.

BAPIs and functions used

  • SO_DOCUMENT_SEND_API1SAPoffice: Send Document with Attachments. Sends the alert email

Selection screen parameters

ParameterDescriptionTypeReference fieldRequiredExample
S_WERKPlantRange / multipleQALS-WERKYes1000
S_ARTInspection typeRange / multipleQALS-ARTNo01, 04
S_HERKLot originRange / multipleQALS-HERKUNFTNo01, 04, 08
P_REJSend only rejections immediatelyCheckbox—NoX
P_SUMMSend acceptances as a daily summaryCheckbox—NoX
P_DLISTDefault distribution listSingle value—NoKALITE_BILDIRIM
P_TESTTest mode (list without sending)Checkbox—No—

Result list columns

#ColumnSource
1Inspection lotQALS-PRUEFLOS
2OriginQALS-HERKUNFT
3MaterialQALS-MATNR
4BatchQALS-CHARG
5VendorQALS-LIFNR
6Purchase orderQALS-EBELN
7Decision codeQAVE-VCODE
8ValuationQAVE-VBEWERTUNG
9Rejected quantityCalculated Quantity moved to blocked stock or returned (QAMB → MSEG)
10RecipientCalculated Purchasing group, production supervisor or distribution list
11StatusCalculated Sent, added to summary, no recipient or error

Sample result list

Inspection lotOriginMaterialBatchVendorPurchase orderDecision codeValuationRejected quantityRecipientStatus
01000000451201HM-1001L2611-091005124500021462R1R2,000[email protected]Sent
01000000453001SC-33001003874500021478A2A0[email protected]Added to daily summary
04000000128804BR-2100F2611-04R2R150[email protected]Sent
08000000031508SP-0045R1R40[email protected]No recipient found; sent to distribution list
A view built with fictional sample data; not real system data.

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.

Performance notes

Restrict QAVE by decision date and time; since each run only reads the decisions of the last 15 minutes, the job finishes in a few seconds. Read QALS, EKKO and T024 in bulk with the keys from the decision list.

Features

  • Runs as a background job The job is scheduled to run every 15 minutes.
  • Test mode (check without posting)
  • Line-by-line result and error log
  • Send the result by email

Authorization objects

  • Q_INSPTYPEInspection lot display authorization by inspection type
  • S_BTCH_JOBAuthorization to schedule the background job
  • S_OC_SENDAuthorization 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.

Related reports

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 Email Alerts to Purchasing and Production for Usage Decisions and Quality Rejections