Beyond ABAPdesigned by@Tejoram97
Beyond ABAP / QM ABAP / Development & Extensibility

Development & Extensibility

QM ABAP · Logistics ·

Open the interactive lesson →
  1. Where to enhance QM: choosing the technique
  2. Customer exits (SMOD / CMOD)
  3. BAdIs: classic, S/4HANA and cloud
  4. BAPIs: reading lots, recording results, usage decision
  5. IDocs, ALE and QM-IDI
  6. OData APIs and CDS views
  7. Key-user and clean-core extensibility
  8. Typical QM developments (RICEFW)
  9. Interview questions

What an ABAP developer builds in QM: logic in customer exits and BAdIs at lot creation, results recording, usage decision and notification save; programs and interfaces that read lots and record results with BAPIs; ALE / QM-IDI interfaces to labs; APIs and CDS views in S/4HANA; and the typical QM RICEFW objects (certificates, LIMS interface, mass usage decision). The general techniques are on CORE ABAP › 10 Enhancements, 07 Interfaces and 11 Forms; the business background is on pages 01 – 04 of this section.

Part 1 – Where to enhance QM: choosing the technique

QM enhancement points along lot creation, results recording, usage decision, notification and certificate

Requirement

Technique

Where

Change fields of a new inspection lot (e.g. text, sample, QM order type)

BAdI BADI_QPL1_CHANGE_AT_CREATE (S/4HANA; was exit QPL10001), exit QPL10007

Parts 2, 3

Different inspection type than the standard determination

Exit QAAT0001

Part 2

Check or derive values while results are recorded

Exits QEEM0002 – QEEM0015, BAdI QE_RESULT_VALUATION, QE_SAVE

Parts 2, 3

Block or check a usage decision, own stock quantities

Exits QEVA0010, QEVA0001, BAdI INSPECTIONLOT_UPDATE

Parts 2, 3

Defaults and checks on quality notifications

Exits QQMA0007 / QQMA0014, BAdI NOTIF_EVENT_SAVE; cloud: BADI_QQM_NOTIF_EVENT_SAVE_CLD

Parts 2, 3

Record results / make the UD from a program or interface

BAPIs or API_INSPECTIONLOT_SRV

Parts 4, 6

Lab system (LIMS) interface

QM-IDI RFCs + QIRF exits, or the API via Cloud Integration

Part 5, page 04

Certificate of analysis layout

Certificate form + exits QC100003 / QC100004

Part 8

S/4HANA clean core

Custom fields, released BAdIs, released CDS views and APIs

Part 7

Part 2 – Customer exits (SMOD / CMOD)

QM has a large set of customer exits (function modules EXIT_SAPLQ…). Find them in SMOD with enhancement Q* + F4, read the documentation there, and activate them in a CMOD project. Also useful: a breakpoint on the statement CALL CUSTOMER-FUNCTION while running QA11 or QE51N. How exits work: CORE ABAP › 10 Enhancements.

Area

Exit

Purpose

Lot creation

QPL10001

Edit the lot work area at creation – in S/4HANA migrated to BAdI BADI_QPL1_CHANGE_AT_CREATE; the exit FM is no longer called

QPL10004 / QPL10007

User subscreen with additional lot data / change the QM order type

QAAT0001 / QAAT0002

Inspection type determination different from variant 01 / control of acceptance lots at goods receipt

QPAP0002

Material–plan assignment and plan selection

QDSE0001 – QDSE0003

Dynamic modification: quality level and inspection stage

Results recording

QEEM0002 / 0003 / 0004 / 0006

Additional functions after reading characteristics / valuating / valuating partial samples / closing characteristics

QEEM0011 / 0012 / 0015

Before valuating characteristics / partial samples, after entering single results

QEEM0021 – 0024, QEEM0029 / 0030

Own functions on user keys +US1 – +US4; own subscreens in the characteristic overview / single screen

Usage decision

QEVA0001

Quantity posting for the usage decision

QEVA0003

Calculate the next inspection date of the batch

QEVA0005 / QEVA0007

User subscreen with additional UD data / compulsory comment or long text

QEVA0008 / QEVA0010

Customer function key (e.g. reset UD) / usage decision check

Notification

QQMA0007 / QQMA0013

Default values when creating a notification / a task

QQMA0006 / QQMA0014

Automatic task determination / checks before saving

QQMA0001, QQMA0008 – 0012

User subscreens: header, item, cause, task, activity

QQMA0018 / QQMA0019 / QQMA0029

Deadlines from priority / default partner / change notification type

Certificates

QC100001 – QC100008, QCE10002

Batches used, profile determination, before form printout, after reading delivery data; IDoc QALITY02

Master data

QPMK0001, QSMT0001, QPAA0006

Change MIC / method data at creation; extra consistency checks for inspection characteristics in plans

Costs, vendor

QLCO0002, QLIB0002

Preset appraisal cost confirmation / complaint score for vendor evaluation

QM-IDI

EXIT_SAPLQIRF_* function exits

Before / after processing for each QIRF RFC module

  • Several classic exits are not called any more in S/4HANA because they were migrated to BAdIs (SMOD shows message ENHANCEMENT 621 'already migrated to BAdI definition …'). Check this before planning a conversion – custom code in a dead exit fails silently.

Part 3 – BAdIs: classic, S/4HANA and cloud

BAdI

Area

Use

INSPECTIONLOT_UPDATE

Lot and UD

Create and change inspection lot and usage decision – e.g. fill own fields, trigger follow-up logic after the UD

QE_SAVE

Results recording

Logic when results are saved (checks, own tables)

QE_RESULT_VALUATION

Results recording

Own valuation of single values (accept / reject)

NOTIF_EVENT_SAVE

Notifications (QM / PM)

Change the notification when saving (fields not covered by BAPI_QUALNOT_CREATE)

NOTIF_EVENT_POST

Notifications

Read the notification data at update – e.g. send it to another system

BADI_QPL1_CHANGE_AT_CREATE

Lot creation – S/4HANA

Successor of exit QPL10001

BADI_QQM_NOTIF_EVENT_SAVE_CLD

Quality notification – cloud

Released BAdI for Custom Logic when a quality notification is saved; filter on notification type (e.g. Q2)

BADI_QPL1_CHANGE_AT_CREATE4CLD

Lot creation – ABAP Cloud

Change the lot header during lot creation (used in S/4HANA Cloud developer extensibility)

  • Find BAdIs with SE18 / SE84 by package or application component QM, or a breakpoint on CL_EXITHANDLER=>GET_INSTANCE (classic) / GET BADI (new); implement in SE19.
  • Released vs. not released: in ABAP Cloud you may only use BAdIs and APIs with a release contract (check the API state in ADT). Lot-creation function modules such as QPL1_INSPECTION_LOT_CREATE or the QPLEXT_… modules are not released for custom code.

Part 4 – BAPIs: reading lots, recording results, usage decision

Program flow: find lots, read operations, record results, commit, set usage decision, commit – and the matching API entities

BAPI / FM

Purpose

BAPI_INSPLOT_GETLIST

Inspection lots by material, batch, plant, dates … (RETURN message Q5001 'no entries' when nothing is found)

BAPI_INSPLOT_GETDETAIL

Lot detail data, status and usage decision

BAPI_INSPOPER_GETDETAIL

One operation of a lot with its characteristics (optionally single results) – call it before recording to know the characteristic numbers

BAPI_INSPOPER_RECORDRESULTS

Record results for one operation: INSPLOT, INSPOPER, INSPPOINTDATA (inspection points), CHAR_RESULTS (BAPI2045D2), SAMPLE_RESULTS (BAPI2045D3), SINGLE_RESULTS (BAPI2045D4), RETURNTABLE

BAPI_INSPLOT_SETUSAGEDECISION

Usage decision: NUMBER, UD_DATA (BAPI2045UD); returns RETURN, STOCK_DATA; tables SYSTEM_STATUS, USER_STATUS

BAPI_QUALNOT_CREATE → BAPI_QUALNOT_SAVE

Create a quality notification (header, items, causes, tasks); SAVE before the commit

BAPI_QUALNOT_GETDETAIL

Read a quality notification

BAPI_TRANSACTION_COMMIT / _ROLLBACK

End the LUW – the QM BAPIs never commit themselves

BAPI_INSPCHAR_SETRESULT

Obsolete – replaced by BAPI_INSPOPER_RECORDRESULTS

4.1 Example: usage decision with stock posting

  • The UD code must exist in the selected set of the plant (customizing); a wrong combination returns 'Selected set code does not exist, or data entered is incomplete'.
  • UD_STOCK_POSTING = 'X' posts the stock as the UD code proposes (e.g. all to unrestricted). The BAPI has no field for split quantities – for 'part unrestricted, part scrap' use QA11 or the stock posting of the Fiori app.
  • Long-term characteristics: UD_FORCE_COMPLETION does not close a lot that still has open long-term characteristics.
" Accept an inspection lot and post its stock (same as QA11 with UD code A)
DATA ls_ud     TYPE bapi2045ud.
DATA ls_return TYPE bapireturn1.

ls_ud = VALUE #(
ud_selected_set  = '01'                     " selected set of the plant (customizing)
ud_plant         = p_werks
ud_code_group    = '01'
ud_code          = 'A'                      " A = accepted in this selected set
ud_stock_posting = abap_true ).             " post as proposed by the UD code

CALL FUNCTION 'BAPI_INSPLOT_SETUSAGEDECISION'
EXPORTING
number  = p_lot                           " inspection lot number (QPLOS)
ud_data = ls_ud
IMPORTING
return  = ls_return.

IF ls_return-type CA 'EA'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MESSAGE ls_return-message TYPE 'I' DISPLAY LIKE 'E'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true.                       " stock posting runs in the update task
MESSAGE |Usage decision set for lot { p_lot ALPHA = OUT }| TYPE 'S'.
ENDIF.

4.2 Recording results – what to know

  • Results are recorded per operation: first BAPI_INSPOPER_GETDETAIL to get the characteristics (INSPCHAR numbers, quantitative / qualitative, required sample size), then one RECORDRESULTS call per operation, then commit.
  • CHAR_RESULTS holds the summarized result and valuation per characteristic (closed indicator, evaluation A / R, mean value or code); SINGLE_RESULTS holds individual values when the characteristic requires single-result recording. Mixing them up is the most common error.
  • For lots with inspection points fill INSPPOINTDATA (the point identification as defined in the routing header); errors such as 'evaluation of the sample not possible' appear when only some characteristics of a sample are valuated.
  • Check RETURNTABLE (BAPIRET2) for E / A messages before committing.

Part 5 – IDocs, ALE and QM-IDI

Interface

Objects

Developer task

ALE message types MATQM, QPMK, QSMT, QPGR

Inspection setup, MICs, methods, code groups – BAPI-based, inbound FM BAPI_IDOC_INPUT1

Distribution model BD64, filters; exits QPMK0010 / QPMK0020, QSMT0010 / QSMT0020, QPGR0020 for extension parameters

IDoc QALITY02

Electronic quality certificate

Fill extra segments in exit QCE10002

QM-IDI (function group QIRF)

Worklist, specifications, results, usage decision to / from a LIMS

RFC user and authorizations, mapping in EXIT_SAPLQIRF_* function exits (page 04 Part 8)

QM-STI

Statistical data to CAQ software

Exits QIST0002 … QIST0011

  • Inspection plans themselves are usually loaded (migration) or created by API rather than distributed by ALE.
  • WE19 / BD87 for testing and reprocessing, partner profiles WE20: CORE ABAP › 07 Interfaces.

Part 6 – OData APIs and CDS views

6.1 Released APIs (SAP Business Accelerator Hub)

API (technical name)

Content

Communication scenario

API_INSPECTIONLOT_SRV

A_InspectionLot, A_InspectionOperation, A_InspectionCharacteristic, A_InspectionResult, A_InspectionSubset, A_InspLotUsageDecision – read, record results, make the UD

SAP_COM_0318 Quality Inspection Process Integration

API_INSPECTIONPLAN_SRV

A_InspectionPlan with operations, characteristics and material assignments

Inspection master data

API_MASTERINSPCHARACTERISTIC_SRV

Master inspection characteristics (A_InspectionSpecification)

SAP_COM_0110 Inspection Master Data Integration

Inspection Method API

Inspection methods

Inspection master data

API_QUALITYINFORECORD_SRV

Quality info record in procurement (and first article inspection)

SAP_COM_0358 Quality Info Record Integration

API_QUALITYNOTIFICATION (on-premise) / Quality Notification OData V4 (CE_QUALITYNOTIFICATION_0001)

Quality notifications with items, causes, tasks

–

  • Optimistic locking: the lot and the UD entity carry ChangedDateTime; sending an outdated value returns 'a newer version of inspection lot exists'; a request without If-Match / ETag is refused with HTTP 428 (precondition required).
  • Lot creation through an API is limited to manual lots (origin 89) where the release offers it; all other lots are created by their business event (page 03 Part 1).
  • Lots with partial lots cannot receive results through the API; inspection points need the point key in A_InspectionSubset.
  • OData basics: CORE ABAP › 08 OData; integration via Cloud Integration: Integration Suite › 02.

6.2 CDS views

The VDM for QM starts with I_InspectionLot (inspection lot, used e.g. as data source for custom CDS views and the Fiori apps) and further released views for operations, characteristics, results and quality notifications. Check names and the release state (C1 / released for ABAP Cloud) in ADT or the View Browser app for your release before building on a view. Field names follow the API: InspectionLot, Material, Plant, InspectionLotOrigin, InspectionLotType, Supplier …

" Goods-receipt lots of a plant – released VDM view (ABAP Cloud compatible)
SELECT FROM I_InspectionLot
FIELDS InspectionLot, Material, Supplier, InspectionLotType,
InspectionLotQuantity, InspectionLotQuantityUnit
WHERE Plant               = @p_werks
AND InspectionLotOrigin = '01'
INTO TABLE @DATA(lt_lots).

" Classic equivalent (on-premise): QALS lot header, QAVE usage decision
SELECT l~prueflos, l~matnr, l~charg, l~lifnr, l~art, l~losmenge, l~mengeneinh
FROM qals AS l
WHERE l~werk     = @p_werks
AND l~herkunft = '01'
AND NOT EXISTS ( SELECT prueflos FROM qave WHERE prueflos = l~prueflos )
INTO TABLE @DATA(lt_open).                    " lots without usage decision
  • QM tables (QALS, QAVE, QAMV, QAMR, QASE, QMEL …) and their CDS views per object: page 02.

Part 7 – Key-user and clean-core extensibility

Part 8 – Typical QM developments (RICEFW)

Typical QM RICEFW objects: reports, interfaces, conversions, enhancements, forms, workflow

Type

Example

Objects used

R Report

Open lots with ageing, rejection rate per supplier, results per batch

QALS, QAVE, QAMR / I_InspectionLot; ALV or Fiori analytical list page

R Mass usage decision

Accept all lots without defects of a plant / supplier in one run

BAPI_INSPLOT_GETLIST + BAPI_INSPLOT_SETUSAGEDECISION with commit per lot; standard alternative QA10

I LIMS / instrument interface

Lab system receives lots, sends results

QM-IDI or API_INSPECTIONLOT_SRV via Cloud Integration

C Data migration

MICs, methods, catalogs, inspection plans, Q-info records

Migration cockpit objects (page 06)

E Enhancement

Block the UD if a long-term test is open; default notification fields

QEVA0010, QQMA0007 / NOTIF_EVENT_SAVE

F Form

Certificate of analysis, inspection lot label, sample label

Certificate profile + form; QC100004; Adobe form in output management

W Workflow

Approval of a quality notification task, 8D steps

Notification workflow, quality tasks in My Inbox (CORE ABAP › 12 Workflow)

Mass usage decision: commit after each lot (stock postings are per lot), collect the RETURN messages into an ALV log, and run it as a background job with a variant – or first check whether the standard automatic UD (QA10, report RQEVAI30, job planning per plant) already covers it.

Part 9 – Interview questions

Q1. Which QM user exits have you used?

QEVA0010 to check the usage decision, QEVA0001 for UD quantity postings, QQMA0007 / QQMA0014 for notification defaults and checks before saving, QEEM exits for additional functions in results recording, QC100004 before the certificate is printed.

Q2. Your custom code in QPL10001 stopped working after the S/4HANA conversion. Why?

QPL10001 was migrated to the BAdI BADI_QPL1_CHANGE_AT_CREATE; the exit function module is no longer called. Move the logic into an implementation of the BAdI.

Q3. Which BAdIs exist for results recording and the usage decision?

QE_SAVE (saving results), QE_RESULT_VALUATION (valuation of single values) and INSPECTIONLOT_UPDATE (create / change lot and usage decision).

Q4. How do you record results from a program?

BAPI_INSPOPER_GETDETAIL to read the characteristics of the operation, BAPI_INSPOPER_RECORDRESULTS with CHAR_RESULTS (summary and valuation), SAMPLE_RESULTS or SINGLE_RESULTS, check RETURNTABLE, then BAPI_TRANSACTION_COMMIT.

Q5. What do you pass to BAPI_INSPLOT_SETUSAGEDECISION?

The lot number in NUMBER and BAPI2045UD in UD_DATA with selected set, plant, code group and code, optionally UD_STOCK_POSTING. Check RETURN and commit. Split quantities cannot be passed.

Q6. How do you create a quality notification from an interface?

BAPI_QUALNOT_CREATE (header, items, causes, tasks), BAPI_QUALNOT_SAVE, then commit. Fields the BAPI does not cover can be set in BAdI NOTIF_EVENT_SAVE. In S/4HANA the quality notification API is the alternative.

Q7. How is QM master data distributed between systems?

BAPI-based ALE with message types QPMK (MICs), QSMT (methods), QPGR (code groups) and MATQM (inspection setup), modelled in BD64; exits for extension parameters.

Q8. Which API would you use for a modern LIMS integration?

API_INSPECTIONLOT_SRV (communication scenario SAP_COM_0318): read lots and characteristics, POST results, POST the usage decision to A_InspLotUsageDecision – via SAP Cloud Integration, with ChangedDateTime / ETag handling.

Q9. Which QM CDS views do you know?

I_InspectionLot as the main view of the VDM, plus released views for operations, characteristics, results and notifications – always checked for release state in ADT / View Browser before use.

Q10. How would you extend QM in a clean-core way?

Custom Fields on the inspection lot / notification context, Custom Logic in released BAdIs (e.g. BADI_QQM_NOTIF_EVENT_SAVE_CLD), released CDS views and APIs, RAP for own apps, BTP for side-by-side. CMOD exits and classic BAdIs only on-premise when nothing released exists.

Q11. What is a typical QM form and how is it built?

The certificate of analysis: its content comes from the certificate profile, the layout is a form assigned there / in output management; exits QC100003 and QC100004 adjust profile determination and data before printing.

Q12. How would you build a mass usage decision program?

Select lots (BAPI_INSPLOT_GETLIST or I_InspectionLot), check that results are complete and no defects exist, call BAPI_INSPLOT_SETUSAGEDECISION and commit per lot, write a log. First check the standard automatic UD (QA10 / RQEVAI30).

🏠 Start Here · ◀ 04 · Integration & Reporting · 06 · S/4HANA & Architect ▶ · Sections: CORE ABAP | OOPS ABAP | ABAP on HANA | Clean Core | RAP | ABAP Points | SAP Fiori | SAPUI5 | Mobile Development (MDK) | BTP Foundations | BTP Development | CAP | SAP Build | ABAP on BTP | Integration Suite | SAP Business AI | SAP BASIS | Security | SAP SDLC

Functional: FICO ABAP | TRM ABAP | VIM | SAP BIS | SD ABAP | MM ABAP | PP ABAP | QM ABAP | PM ABAP | PS ABAP | EWM | TM ABAP | GTM ABAP | EHS ABAP | HR ABAP | BW | SAP Datasphere | SAP Business Data Cloud | SAP MDG | SAP Analytics Cloud | SAP Ariba | SAP CX | SAP IBP