Your Purchase to Pay - Requisition Data Template
Your Purchase to Pay - Requisition Data Template
- Recommended attributes to collect for detailed analysis
- Key activities to track for process discovery
- Guidance for data extraction from SAP S/4HANA
Purchase to Pay - Requisition Attributes
| Name | Description | ||
|---|---|---|---|
| Activity Name ActivityName | The name of the business activity that occurred at a specific point in the requisition process. | ||
| Description The Activity Name describes a specific event or task that took place within the lifecycle of a purchase requisition. These activities are derived from system logs, such as change documents and workflow histories, and represent key process milestones like 'Requisition Created', 'Approval Step Started', or 'Purchase Order Created'. Analyzing these activities allows for the visualization of the process flow, identification of bottlenecks, and measurement of time spent in different stages. Understanding the sequence and frequency of activities like 'Requisition Amended' or 'Requisition Rejected' is crucial for identifying process inefficiencies and areas for improvement. Why it matters It defines the steps in the process, forming the backbone of the process map and enabling analysis of process flow, variations, and bottlenecks. Where to get This is a derived attribute, typically constructed by interpreting data from change document tables (CDHDR, CDPOS) and workflow logs (e.g., SWWLOGHIST). Examples Requisition CreatedApproval Step CompletedRequisition ApprovedPurchase Order Created | |||
| Event Time EventTime | The precise date and time when a specific activity occurred. | ||
| Description Event Time is the timestamp that records when an activity took place. This data is critical for chronological ordering of events within a case and is the basis for all duration and performance calculations in process mining. For example, the time difference between the 'Requisition Submitted' and 'Requisition Approved' events determines the approval cycle time. Accurate timestamps are essential for analyzing process performance, identifying delays, and monitoring adherence to service level agreements. This attribute enables dashboards that visualize cycle times, track stalled requisitions, and compare performance over different time periods. Why it matters This timestamp is essential for ordering events, calculating cycle times, and analyzing process performance and bottlenecks. Where to get Timestamps are typically sourced from change document headers (CDHDR-UDATE, CDHDR-UTIME) or workflow event logs. Examples 2023-04-15T10:05:30Z2023-04-15T14:22:01Z2023-04-16T09:00:15Z | |||
| Purchase Requisition ID PurchaseRequisitionId | The unique identifier for a purchase requisition document. | ||
| Description The Purchase Requisition ID is the primary key that uniquely identifies each request for goods or services within SAP S/4HANA. It serves as the central case identifier, linking all activities and changes related to a specific requisition from its creation to its final state, such as approval, rejection, or conversion into a purchase order. In process mining, this attribute is fundamental for reconstructing the end-to-end lifecycle of each requisition. By grouping all related events under a single Purchase Requisition ID, analysts can accurately measure cycle times, track status changes, and analyze the different paths a requisition can take through the approval process. Why it matters This is the essential case identifier that connects all related process steps, enabling a complete and coherent view of the requisition lifecycle. Where to get This attribute is the Purchase Requisition Number, found in table EBAN, field BANFN. Examples 100178901001789110017892 | |||
| Approver ID ApproverId | The identifier of the user who performed an approval or rejection step. | ||
| Description The Approver ID specifically identifies the user who completed an approval or rejection activity. This is distinct from the general User ID as it focuses solely on the decision-makers within the approval workflow. Capturing this information is vital for analyzing the approval process in detail. This attribute allows for the analysis of approval behavior, such as identifying managers with long approval times or those who frequently reject requisitions. It is fundamental for dashboards focused on approval step cycle times and workflow bottleneck analysis, helping to pinpoint specific individuals or roles that may be causing delays. Why it matters Pinpoints the specific decision-maker in an approval step, enabling detailed analysis of approval cycle times and bottlenecks by individual or role. Where to get This information is typically extracted from SAP Business Workflow tables like SWW_WI2OBJ and SWWLOGHIST, which link work items to the completing user. Examples MJOHNSONCWILLIAMSLBLACK | |||
| Department Department | The department or cost center to which the requisition's costs are charged. | ||
| Description The Department attribute, often represented by the Cost Center in SAP, identifies the business unit responsible for the requested purchase. It is a critical piece of financial and organizational information assigned at the line-item level of a requisition. In process mining, this attribute is essential for departmental performance analysis. It enables dashboards that compare key metrics like cycle time, amendment rates, and rejection rates across different departments. This helps identify high-performing departments whose practices could be adopted elsewhere, as well as departments that may require additional training or process support. Why it matters Enables performance comparison across business units, highlighting variations in cycle times or rejection rates to identify best practices and areas for improvement. Where to get This is the Cost Center, typically found in the account assignment table EBKN, field KOSTL. Examples FIN-1001IT-2005MKT-3010 | |||
| Requisition Amount RequisitionAmount | The total monetary value of the purchase requisition. | ||
| Description The Requisition Amount represents the total estimated cost of the goods or services being requested. This value is often a key factor in determining the complexity and length of the approval workflow, with higher value requisitions typically requiring more levels of approval. Analyzing this attribute allows for segmentation of the process based on value. It can help answer questions such as, 'Do high-value requisitions take longer to approve?' or 'What is the value of requisitions that are frequently rejected?'. It is a critical dimension for understanding the financial impact of process inefficiencies. Why it matters Helps segment the process by financial impact, often correlating with approval complexity and cycle time. It is vital for value-based process analysis. Where to get The total value can be found in table EBAN, field GFWERT. Item-level value is in EBAN-PREIS. Examples 1500.0075000.50250.75 | |||
| Requisition Status RequisitionStatus | The current processing or approval status of the purchase requisition. | ||
| Description The Requisition Status indicates the current state of the requisition within its lifecycle. In SAP, this is often represented by the Release Indicator, which shows whether a requisition is blocked, in approval, partially approved, or fully approved. This status changes as the requisition moves through the workflow. Tracking the status over time is fundamental to understanding the process flow. It helps in identifying where requisitions are getting stuck and for how long. Analyzing transitions between statuses allows for a detailed view of the approval process and its variants. Why it matters Indicates the current state of a requisition, which is critical for tracking progress, identifying bottlenecks, and analyzing process flow. Where to get The release status is often determined by the Release Indicator, found in table EBAN, field FRGZU. Examples B1S | |||
| Requisition Type RequisitionType | A code that classifies the purchase requisition, for example, for standard items, services, or capital expenditure. | ||
| Description The Requisition Type, also known as Document Type in SAP, is a key configuration field that categorizes purchase requisitions. Different types can trigger different approval workflows, have different field settings, and are used for different business purposes, such as standard stock items, external services, or asset purchases. By analyzing the process based on Requisition Type, organizations can understand how different types of requests are handled. It allows for comparing performance, cycle times, and approval paths across categories, which can reveal if certain requisition types are more or less efficient and help tailor process improvements. Why it matters Categorizes requisitions to enable comparative analysis, helping to understand if different types of requests have different process flows, bottlenecks, or cycle times. Where to get This is the Document Type field, found in table EBAN, field BSART. Examples NBFORV | |||
| User ID UserId | The identifier of the user who created the requisition or performed a specific activity. | ||
| Description The User ID identifies the employee or system user responsible for a particular event in the requisition's lifecycle. This can be the person who created the requisition, the manager who approved it, or the agent who amended it. In cases of automated steps, this might be a system or batch user ID. Analyzing by User ID helps in understanding user-specific behavior, workload distribution, and performance. It is key for identifying training needs, recognizing high-performing individuals, and ensuring accountability within the process. It also supports departmental performance analysis when combined with user master data. Why it matters Enables analysis of user performance, workload distribution, and process compliance. It is crucial for identifying training opportunities and resource bottlenecks. Where to get Found in EBAN-ERNAM for the creator. For subsequent changes, it's in CDHDR-USERNAME. For approvals, it's in workflow logs. Examples JSMITHRROEWF-BATCH | |||
| Approval Step Name ApprovalStepName | The specific name or description of an approval step in the workflow. | ||
| Description The Approval Step Name provides a human-readable description of a particular stage in the approval workflow, such as 'Manager Approval' or 'VP Finance Approval'. This is more descriptive than a generic 'Approval Step Completed' activity. This attribute is critical for the Approval Step Cycle Time and Workflow Bottleneck Analysis dashboards. It allows for a granular view of the approval process, making it possible to pinpoint exactly which approval stages are causing the most significant delays and where work is accumulating. This level of detail is necessary for targeted interventions to streamline the approval chain. Why it matters Provides granular detail on approval stages, enabling precise identification of bottlenecks within the multi-level approval workflow. Where to get This information is derived from the workflow task description, which can be found by linking the workflow log to task definition tables like T528T. Examples Manager ApprovalDirector ApprovalFinance VP Approval | |||
| Currency Currency | The currency code for the requisition amount. | ||
| Description This attribute specifies the currency in which the requisition amount is denominated, for example, USD, EUR, or JPY. It provides the necessary context for the Requisition Amount attribute, especially in multinational organizations that operate with multiple currencies. For accurate financial analysis and reporting, it is essential to consider the currency. When aggregating or comparing requisition values, all amounts should be converted to a common currency to ensure meaningful results. This attribute is a prerequisite for such conversions. Why it matters Provides essential context for the Requisition Amount, enabling accurate financial analysis and comparisons in multi-currency environments. Where to get This is found in table EBAN, field WAERS. Examples USDEURGBP | |||
| End Time EndTime | The precise date and time when a specific activity was completed. | ||
| Description EndTime is the timestamp that records when an activity was finished. While many system-generated events are instantaneous (meaning StartTime equals EndTime), human tasks like approvals may have a distinct start and end. This timestamp marks the completion of that work. Having a separate EndTime allows for more accurate measurement of active processing time versus idle waiting time. It is used in conjunction with StartTime to calculate the ProcessingTime metric. This level of detail enhances the analysis of resource utilization and efficiency for manual tasks. Why it matters Marks the completion of an activity, enabling the calculation of active processing time and providing a more detailed view of task duration. Where to get This is derived from workflow logs that may capture both when a work item was created (StartTime) and when it was completed (EndTime). Examples 2023-04-15T10:20:30Z2023-04-15T14:25:01Z2023-04-16T11:00:45Z | |||
| Is Automated IsAutomated | A flag indicating whether an activity was performed by a system user rather than a human. | ||
| Description The Is Automated attribute is a boolean flag that is true if an activity was executed by a system or batch user, such as 'WF-BATCH' for workflow actions. This helps distinguish between manual and automated steps in the process. This attribute is essential for measuring the level of automation in the requisition process and for calculating the 'Automated Approval Rate' KPI. By filtering for automated or manual steps, analysts can compare their efficiency and identify opportunities for further automation to reduce processing times and manual effort. Why it matters Distinguishes between human and system-driven activities, which is key for measuring automation rates and identifying opportunities to automate manual tasks. Where to get This is a derived attribute, typically based on a rule that checks if the User ID for an event belongs to a list of known system or batch users. Examples truefalse | |||
| Is Rework IsRework | A flag indicating if an activity constitutes rework, such as an amendment after submission. | ||
| Description Is Rework is a calculated boolean flag that identifies activities that represent non-value-added or repetitive work. A common example in this process is the 'Requisition Amended' activity occurring after the requisition has already been submitted for approval, forcing the approval process to restart. This attribute is crucial for quantifying the amount of rework in the process and its impact on overall cycle times. The Requisition Amendment and Rework Rate dashboard relies on this flag to highlight process inefficiencies. Reducing rework is often a primary goal of process improvement initiatives as it directly translates to saved time and effort. Why it matters Flags activities that represent wasted effort or repetition, allowing for the direct measurement of rework and its impact on process efficiency. Where to get This is a calculated attribute. The logic would typically flag any 'Requisition Amended' activity that occurs after the first 'Requisition Submitted For Approval' activity as rework. Examples truefalse | |||
| Last Data Update LastDataUpdate | The timestamp indicating when the data for this record was last refreshed from the source system. | ||
| Description This attribute records the date and time of the most recent data extraction or update from the source system. It is a critical piece of metadata for understanding the freshness of the data being analyzed. Analysts and business users rely on this timestamp to know if the process data reflects the most current state of operations. In any process analysis, knowing the currency of the data is fundamental for making informed decisions. This attribute helps manage user expectations and ensures that conclusions are drawn from data that is as up-to-date as required for the specific analysis. Why it matters Indicates the freshness of the data, which is crucial for trusting the analysis and making timely business decisions. Where to get This timestamp is generated and added during the data extraction, transformation, and loading (ETL) process. Examples 2023-10-27T02:00:00Z2023-10-28T02:00:00Z | |||
| Processing Time ProcessingTime | The duration of time spent on a specific activity. | ||
| Description Processing Time measures the time it took to complete a single activity. It is calculated as the difference between the end time and the start time of an event. For many events in SAP, the start and end times are the same, resulting in a processing time of zero. However, for approval steps, it can represent the time an approver spent working on the task. This calculated metric is useful for understanding the effort involved in different process steps. It can help distinguish between the time a case is waiting (wait time) and the time it is actively being worked on (processing time), providing a more nuanced view of process performance. Why it matters Measures the active work time for an activity, helping to distinguish between time spent working versus time spent waiting, which is key for resource analysis. Where to get This is a calculated attribute, typically derived as EndTime minus StartTime for each event in the event log. Examples PT15MPT2H30MP1D | |||
| Purchase Order Number PurchaseOrderNumber | The number of the purchase order that was created from the requisition. | ||
| Description The Purchase Order Number is the identifier of the official purchasing document created from an approved requisition. The creation of a purchase order is often the final, successful outcome for a requisition, signifying that the request has been converted into a formal order with a supplier. This attribute is crucial for measuring the Requisition to Purchase Order Lead Time KPI and the overall conversion rate. It links the requisitioning process with the downstream procurement process, enabling a broader, end-to-end view of the entire Purchase-to-Pay cycle. Why it matters Links the requisition to the subsequent procurement document, enabling measurement of the requisition-to-PO conversion rate and lead time. Where to get Found in table EBAN, field EBELN, once a PO has been created from the requisition item. Examples 450001789045000178914500017892 | |||
| Rejection Reason RejectionReason | The reason provided when a purchase requisition is rejected. | ||
| Description The Rejection Reason explains why an approver decided to reject a purchase requisition. Reasons might include budget exceedance, incorrect information, non-compliance with policy, or duplication of another request. This information provides crucial context for understanding process failures. Analyzing rejection reasons helps identify the root causes of process inefficiencies and rework. For example, if 'Incorrect Cost Center' is a common reason, it points to a need for better user training or system validation. This attribute is the key to the Requisition Rejection Analysis dashboard and is vital for targeted process improvement. Why it matters Provides the root cause for process failures, enabling targeted improvements to reduce rework and increase the first-time-right rate of requisitions. Where to get This is often not a standard field. It may be captured in workflow container elements, long text associated with the requisition, or custom fields. Examples Exceeds budgetIncorrect supplierDuplicate request | |||
| Required By Date RequiredByDate | The date by which the requester needs the requested goods or services. | ||
| Description The Required By Date, or Delivery Date in SAP, specifies when the goods or services on the requisition line item are needed. This date is set by the requester and serves as a target for the entire procurement process. This attribute is essential for calculating the 'On-Time Requisition Completion Rate' KPI. By comparing the Required By Date with the final approval or PO creation date, the organization can measure its ability to meet internal service levels and business needs. Analyzing requisitions that miss this date can highlight systemic delays in the procurement process. Why it matters Defines the target completion date for a request, allowing for the measurement of on-time delivery and adherence to internal service levels. Where to get This is the Delivery Date, found at the item level in table EBAN, field LFDAT. Examples 2023-11-152023-12-012024-01-20 | |||
| Source System SourceSystem | Identifies the specific SAP S/4HANA instance from which the data was extracted. | ||
| Description The Source System attribute indicates the originating system where the process data was generated. In organizations with multiple SAP instances, such as different systems for development, quality assurance, and production, or separate systems for different regions, this field is crucial for data governance and context. It ensures that data from different sources can be distinguished, preventing incorrect aggregation and enabling system-specific analysis. It is a mandatory attribute for maintaining data lineage and ensuring the traceability of the process data. Why it matters Provides essential context for data origin and governance, especially in landscapes with multiple systems, ensuring data traceability. Where to get This is typically the SAP System ID (SID), which can be retrieved from system variables or configuration tables. Examples S4PECCS4H_PROD_01 | |||
| Urgency Level UrgencyLevel | A classification of the requisition's urgency, which may influence its processing priority. | ||
| Description The Urgency Level indicates the priority of the purchase request. While not a standard dedicated field, some organizations use fields like the Requirement Tracking Number to capture this information. This allows requesters to flag critical needs that may require expedited processing. Analyzing the impact of urgency is important for evaluating whether the process effectively prioritizes critical requests. The Urgency Level Impact Analysis dashboard uses this attribute to compare cycle times and approval rates for urgent versus standard requisitions, helping to determine if priority handling is working as intended. Why it matters Allows for analysis of how process performance differs for high-priority requests, helping to validate if urgent items are truly expedited. Where to get There is no standard urgency field. Some companies use the Requirement Tracking Number (EBAN-BEDAR) for this purpose. It may also be a custom field. Examples HighMediumLow | |||
Purchase to Pay - Requisition Activities
| Activity | Description | ||
|---|---|---|---|
| Approval Step Completed | Occurs when an approver takes a positive action on a requisition, completing one step in the multi-level approval workflow. This is inferred from a change in the requisition's release status. | ||
| Why it matters This activity allows for detailed analysis of the approval workflow, measuring the time taken at each individual step. It helps identify efficient approvers versus bottlenecks in the process. Where to get Inferred from change documents (CDHDR/CDPOS) for the EBAN table. A change to the release code status (e.g., in field FRGZU) from unreleased to released for a specific code signifies this event. Capture Track changes to the release status fields in EBAN for each release code defined in the strategy. Event type inferred | |||
| Purchase Order Created | Indicates that a purchase order has been generated referencing the requisition item. This is an explicit system event that links the requisition to a subsequent procurement document. | ||
| Why it matters This is a major milestone and a successful outcome for the requisition process. The time between requisition approval and PO creation is a critical KPI for measuring procurement efficiency. Where to get Explicitly recorded when a purchase order item is created. The link is stored in the EKPO table (Purchase Order Item), which contains the source requisition number (BANFN) and item number (BNFPO). Capture Join EKPO table back to EBAN on the requisition number and item. The creation date of the PO item marks the event. Event type explicit | |||
| Requisition Approved | Marks the final and complete approval of the purchase requisition, making it eligible for conversion into a purchase order. This milestone is inferred when the overall release status reaches its final approved state. | ||
| Why it matters This is a critical success milestone and a common endpoint for cycle time analysis. It signifies that the requisition has passed all checks and is ready for the procurement department to action. Where to get Inferred from a status change in the EBAN table, specifically when the overall release indicator (FRGZU) or processing status (PROCSTAT) is updated to a final 'Approved' value. Capture Identify the timestamp when the final release code is applied or the overall requisition status changes to 'Approved'. Event type inferred | |||
| Requisition Closed | Indicates that the requisition item is considered fully processed and no further purchase orders can be created from it. This status is typically set automatically once the full quantity has been ordered. | ||
| Why it matters This activity represents the final, successful completion of the requisition item's lifecycle. It confirms that the business need has been fully translated into a procurement order. Where to get Inferred from the EBAN table. This occurs when the 'Closed' indicator (EBAKZ) is set, which typically happens when the quantity ordered in POs equals the requisition quantity. Capture Identify the event where the 'Closed' indicator (EBAKZ) is set in table EBAN via change documents. Event type inferred | |||
| Requisition Created | Marks the initial creation of the purchase requisition document in the system. This event is captured explicitly when a user saves a new requisition for the first time, recording the creation timestamp. | ||
| Why it matters This activity serves as the primary start point for the requisition lifecycle analysis. It is essential for measuring the end-to-end cycle time, from initial need identification to final approval or conversion to a purchase order. Where to get This is an explicit event captured from the EBAN table, using the creation date (ERDAT) and creation time (ERZEIT) fields for the specific purchase requisition number (BANFN). Capture Use creation timestamp fields (ERDAT, ERZEIT) from the EBAN table for each requisition (BANFN). Event type explicit | |||
| Requisition Rejected | Represents the final rejection of the purchase requisition by an approver, halting the process. This is captured by a specific status update indicating rejection. | ||
| Why it matters This activity is a critical failure endpoint. Analyzing rejection frequency, reasons, and points in the process helps identify issues with policy compliance, budget, or request quality. Where to get Inferred from a status change in the EBAN table. The processing status (PROCSTAT) or a release indicator is set to a value that explicitly means 'Rejected'. Capture Identify the timestamp when the overall status in EBAN is updated to a 'Rejected' state via change documents. Event type inferred | |||
| Approval Reset | Represents an event where the entire approval workflow is reset, often due to a significant amendment to the requisition. This forces the approval process to start over from the first level. | ||
| Why it matters This activity highlights significant rework that severely impacts cycle time. Identifying the causes of approval resets is key to streamlining the process and reducing delays. Where to get Inferred from change documents (CDHDR/CDPOS) on the EBAN table. This event is detected when release status fields (like FRGKZ or FRGZU) are cleared after having been partially or fully set. Capture Look for a change in release status from a released state back to an unreleased state within the change logs. Event type inferred | |||
| Approval Step Started | Indicates that a requisition is awaiting action from a specific approver or approval group. This is inferred when the requisition's status indicates it is pending a specific release code. | ||
| Why it matters This activity is essential for pinpointing bottlenecks in the approval chain. Analyzing the duration of this state helps identify stalled requisitions and overloaded approvers. Where to get Inferred from the EBAN table's release status fields (e.g., FRGZU) and the underlying release strategy configuration. The event starts when a specific release code becomes the next one to be processed. Capture Determine when a requisition enters a state where a specific release code is pending approval based on workflow logs or status fields. Event type inferred | |||
| Requisition Amended | Occurs when a user modifies a key field in the requisition after its initial creation, such as quantity, price, or material. This action is explicitly logged in SAP's change document system. | ||
| Why it matters Tracking amendments is crucial for identifying rework loops and their impact on cycle times. A high frequency of amendments suggests issues with data quality or changing requirements, which are key areas for process improvement. Where to get Explicitly logged in the SAP change document tables (CDHDR and CDPOS) for changes made to table EBAN. Each change to a tracked field creates an entry. Capture Extract change events from CDHDR/CDPOS where the object class is BANF for purchase requisitions. Event type explicit | |||
| Requisition Submitted For Approval | Represents the moment the requester formally submits the requisition, triggering the approval workflow. This is typically inferred when the requisition's release strategy is determined and the status changes to 'In Approval'. | ||
| Why it matters This is a critical milestone that starts the clock for approval cycle time KPIs. Analyzing the time between creation and submission can reveal delays in the requisition preparation phase. Where to get Inferred from change documents (CDHDR/CDPOS) for the EBAN table, specifically when the release strategy fields (e.g., FRGST) are populated or the overall status (PROCSTAT) changes to reflect an in-approval state. Capture Identify the first change document entry that indicates the start of the approval workflow or a status change to 'In Approval'. Event type inferred | |||
| Requisition Withdrawn | Occurs when the original requester cancels or deletes the requisition before it is fully processed. This is typically an explicit action that sets a deletion flag on the requisition item. | ||
| Why it matters Tracking withdrawals helps understand demand volatility and reasons for cancellation. It represents a terminal state for the requisition, preventing further processing. Where to get Explicitly captured when the deletion indicator (LOEKZ) field in the EBAN table is set for a requisition item. The change is logged in CDHDR/CDPOS. Capture Identify the event where the deletion indicator (LOEKZ) in table EBAN is set to 'L'. Event type explicit | |||
| Source of Supply Assigned | Represents the action of a buyer assigning a specific vendor, contract, or info record to an approved requisition item. This is a key step in preparing the requisition for purchase order creation. | ||
| Why it matters This activity bridges the gap between approval and ordering. Measuring the time to assign a source helps identify delays in the buyer's workload and sourcing efficiency. Where to get Inferred from a value being entered into the source-of-supply related fields in the EBAN table, such as fixed vendor (LIFNR), info record (INFNR), or contract (KONNR). Capture Track the population of fields like LIFNR, INFNR, or KONNR in the EBAN table via change documents. Event type inferred | |||
Extraction Guides
Steps
- Prerequisites: Ensure you have a user with appropriate authorizations in SAP S/4HANA to access the required CDS views. This typically involves permissions for objects like S_TABU_NAM and access to data display tools.
- Identify System Access Method: Determine how you will connect to the SAP S/4HANA database to execute SQL queries. Common tools include SAP HANA Studio, the Eclipse IDE with ADT (ABAP Development Tools), or third party SQL clients like DBeaver that can connect via the SAP HANA database client.
- Review the SQL Query: Familiarize yourself with the provided SQL script. It uses Common Table Expressions (CTEs) to gather data for different activities and unions them together to create a unified event log.
- Customize Placeholders: Locate and replace the placeholders in the query. You will need to set the date range (
[YYYY-MM-DD]format) for the extraction period and specify the relevant company codes ([Your Company Code]) for your organization. - Execute the Query: Run the complete, customized SQL query against the SAP S/4HANA database. Depending on the data volume and the selected date range, this query may take some time to execute.
- Initial Data Review: Once the query completes, review the first few rows of the output. Check that all columns, such as PurchaseRequisitionId, ActivityName, and EventTime, are populated as expected and the data formats are correct.
- Address Data Transformation: The provided query is designed to output data in a format ready for process mining. The
CASTandCONCATfunctions are used to ensure data types are consistent. No major post-execution transformation should be required. - Export the Event Log: Export the entire result set from your SQL client to a CSV file. Ensure the file encoding is set to UTF-8 to prevent character issues.
- Prepare for Upload: Before uploading to a process mining tool, verify the CSV file has the correct headers (
PurchaseRequisitionId,ActivityName,EventTime, etc.) and that the date and time format forEventTimeis consistent and supported by the target platform. - Upload to ProcessMind: Upload the final CSV file into your ProcessMind project. Configure the project by mapping
PurchaseRequisitionIdas the Case ID,ActivityNameas the Activity, andEventTimeas the Timestamp.
Configuration
- Core CDS Views: The extraction primarily uses
I_PurchaseRequisitionAPI01for core requisition data,I_ChangeDocumentandI_ChangeDocumentItemfor tracking changes and status updates, andI_PurchaseOrderItemAPI01for linking to purchase orders. - Authorization: The executing user needs read access to the aforementioned CDS views. Consult your SAP security team for the necessary roles and authorizations.
- Date Range Filtering: It is critical to apply a date range filter on the requisition creation date (
CreationDate) to limit the data volume. A range of 3 to 6 months of data is recommended for an initial analysis. - Organizational Filtering: Filter the data by
CompanyCodeto ensure you are analyzing the process for the correct business entity. You may also consider filtering byPurchaseRequisitionTypeto focus on specific procurement processes, for example, standard goods vs. services. - Change Document Configuration: The capture of activities like 'Requisition Amended' and various approval steps depends on change document logging being active for the relevant fields in your SAP system. If these events are missing, check the system configuration for table EBAN.
- Performance: For very large systems with millions of requisitions, running this query over a long period may impact system performance. Consider executing it during off-peak hours or in a non-production environment with recently refreshed data.
a Sample Query sql
WITH REQUISITIONS AS (
SELECT
PurchaseRequisition,
PurchaseRequisitionType,
PurReqnDescription,
CreatedByUser,
CreationDate,
CAST(CONCAT(CreationDate, 'T', LPAD(CreationTime, 6, '0')) AS TIMESTAMP) AS CreationTimestamp,
SourceOfSupplyIsAssigned
FROM I_PurchaseRequisitionAPI01
WHERE CreationDate BETWEEN '[YYYY-MM-DD]' AND '[YYYY-MM-DD]'
AND CompanyCode IN ('[Your Company Code]')
),
CHANGE_DOCS AS (
SELECT
ObjectValue AS PurchaseRequisition,
UserName,
CAST(CONCAT(CreationDate, 'T', LPAD(CreationTime, 6, '0')) AS TIMESTAMP) AS ChangeTimestamp,
FieldName,
ValueNew,
ValueOld
FROM I_ChangeDocument AS H
JOIN I_ChangeDocumentItem AS I
ON H.ChangeDocument = I.ChangeDocument
WHERE H.Objectclass = 'EINKBELEG'
AND H.CreationDate BETWEEN '[YYYY-MM-DD]' AND '[YYYY-MM-DD]'
)
-- 1. Requisition Created
SELECT
R.PurchaseRequisition AS "PurchaseRequisitionId",
'Requisition Created' AS "ActivityName",
R.CreationTimestamp AS "EventTime",
R.CreatedByUser AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM REQUISITIONS AS R
JOIN I_PurchaseRequisitionItemAPI01 AS I
ON R.PurchaseRequisition = I.PurchaseRequisition
UNION ALL
-- 2. Requisition Submitted For Approval & 5. Approval Step Started
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
CASE
WHEN C.ValueOld = ''
THEN 'Requisition Submitted For Approval'
ELSE 'Approval Step Started'
END AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
R.CreatedByUser AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R
ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I
ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'FRGZU' AND C.ValueNew != ''
UNION ALL
-- 3. Requisition Amended
SELECT DISTINCT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Requisition Amended' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
C.UserName AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName IN ('MENGE', 'PREIS', 'MATNR', 'LIFNR', 'INFNR')
AND C.ChangeTimestamp > R.CreationTimestamp
UNION ALL
-- 4. Approval Reset
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Approval Reset' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
C.UserName AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'FRGZU' AND C.ValueOld != '' AND C.ValueNew = ''
UNION ALL
-- 6. Approval Step Completed
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Approval Step Completed' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
NULL AS "UserId",
C.UserName AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'FRGZU' AND C.ValueNew IN ('1', '2', '3', '4', '5', '6', '7') -- Adjust release codes as per your config
UNION ALL
-- 7. Requisition Approved
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Requisition Approved' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
NULL AS "UserId",
C.UserName AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'FRGKE' AND C.ValueNew = '2' -- Final release indicator '2' is common for approved
UNION ALL
-- 8. Requisition Rejected
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Requisition Rejected' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
NULL AS "UserId",
C.UserName AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'FRGZU' AND C.ValueNew = 'B' -- 'B' for Blocked/Rejected is a common setting
UNION ALL
-- 9. Requisition Withdrawn
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Requisition Withdrawn' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
C.UserName AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'LOEKZ' AND C.ValueNew = 'X'
UNION ALL
-- 10. Source of Supply Assigned
SELECT DISTINCT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Source of Supply Assigned' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
C.UserName AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName IN ('LIFNR', 'INFNR') AND C.ValueNew != ''
AND C.ChangeTimestamp > R.CreationTimestamp
UNION ALL
-- 11. Purchase Order Created
SELECT DISTINCT
I.PurchaseRequisition AS "PurchaseRequisitionId",
'Purchase Order Created' AS "ActivityName",
CAST(CONCAT(H.PurchaseOrderDate, 'T', LPAD(H.CreationTime, 6, '0')) AS TIMESTAMP) AS "EventTime",
H.CreatedByUser AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.OrderPriceUnit * I.OrderQuantity AS "RequisitionAmount",
'PO Created' AS "RequisitionStatus"
FROM I_PurchaseOrderItemAPI01 AS I
JOIN I_PurchaseOrderAPI01 AS H
ON I.PurchaseOrder = H.PurchaseOrder
JOIN REQUISITIONS AS R
ON I.PurchaseRequisition = R.PurchaseRequisition
WHERE I.PurchaseRequisition IS NOT NULL AND I.PurchaseRequisition != ''
UNION ALL
-- 12. Requisition Closed
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Requisition Closed' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
C.UserName AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'EBAKZ' AND C.ValueNew = 'X' Steps
- Prerequisites: Ensure you have a user with appropriate authorizations in SAP S/4HANA to access the required CDS views. This typically involves permissions for objects like S_TABU_NAM and access to data display tools.
- Identify System Access Method: Determine how you will connect to the SAP S/4HANA database to execute SQL queries. Common tools include SAP HANA Studio, the Eclipse IDE with ADT (ABAP Development Tools), or third party SQL clients like DBeaver that can connect via the SAP HANA database client.
- Review the SQL Query: Familiarize yourself with the provided SQL script. It uses Common Table Expressions (CTEs) to gather data for different activities and unions them together to create a unified event log.
- Customize Placeholders: Locate and replace the placeholders in the query. You will need to set the date range (
[YYYY-MM-DD]format) for the extraction period and specify the relevant company codes ([Your Company Code]) for your organization. - Execute the Query: Run the complete, customized SQL query against the SAP S/4HANA database. Depending on the data volume and the selected date range, this query may take some time to execute.
- Initial Data Review: Once the query completes, review the first few rows of the output. Check that all columns, such as PurchaseRequisitionId, ActivityName, and EventTime, are populated as expected and the data formats are correct.
- Address Data Transformation: The provided query is designed to output data in a format ready for process mining. The
CASTandCONCATfunctions are used to ensure data types are consistent. No major post-execution transformation should be required. - Export the Event Log: Export the entire result set from your SQL client to a CSV file. Ensure the file encoding is set to UTF-8 to prevent character issues.
- Prepare for Upload: Before uploading to a process mining tool, verify the CSV file has the correct headers (
PurchaseRequisitionId,ActivityName,EventTime, etc.) and that the date and time format forEventTimeis consistent and supported by the target platform. - Upload to ProcessMind: Upload the final CSV file into your ProcessMind project. Configure the project by mapping
PurchaseRequisitionIdas the Case ID,ActivityNameas the Activity, andEventTimeas the Timestamp.
Configuration
- Core CDS Views: The extraction primarily uses
I_PurchaseRequisitionAPI01for core requisition data,I_ChangeDocumentandI_ChangeDocumentItemfor tracking changes and status updates, andI_PurchaseOrderItemAPI01for linking to purchase orders. - Authorization: The executing user needs read access to the aforementioned CDS views. Consult your SAP security team for the necessary roles and authorizations.
- Date Range Filtering: It is critical to apply a date range filter on the requisition creation date (
CreationDate) to limit the data volume. A range of 3 to 6 months of data is recommended for an initial analysis. - Organizational Filtering: Filter the data by
CompanyCodeto ensure you are analyzing the process for the correct business entity. You may also consider filtering byPurchaseRequisitionTypeto focus on specific procurement processes, for example, standard goods vs. services. - Change Document Configuration: The capture of activities like 'Requisition Amended' and various approval steps depends on change document logging being active for the relevant fields in your SAP system. If these events are missing, check the system configuration for table EBAN.
- Performance: For very large systems with millions of requisitions, running this query over a long period may impact system performance. Consider executing it during off-peak hours or in a non-production environment with recently refreshed data.
a Sample Query sql
WITH REQUISITIONS AS (
SELECT
PurchaseRequisition,
PurchaseRequisitionType,
PurReqnDescription,
CreatedByUser,
CreationDate,
CAST(CONCAT(CreationDate, 'T', LPAD(CreationTime, 6, '0')) AS TIMESTAMP) AS CreationTimestamp,
SourceOfSupplyIsAssigned
FROM I_PurchaseRequisitionAPI01
WHERE CreationDate BETWEEN '[YYYY-MM-DD]' AND '[YYYY-MM-DD]'
AND CompanyCode IN ('[Your Company Code]')
),
CHANGE_DOCS AS (
SELECT
ObjectValue AS PurchaseRequisition,
UserName,
CAST(CONCAT(CreationDate, 'T', LPAD(CreationTime, 6, '0')) AS TIMESTAMP) AS ChangeTimestamp,
FieldName,
ValueNew,
ValueOld
FROM I_ChangeDocument AS H
JOIN I_ChangeDocumentItem AS I
ON H.ChangeDocument = I.ChangeDocument
WHERE H.Objectclass = 'EINKBELEG'
AND H.CreationDate BETWEEN '[YYYY-MM-DD]' AND '[YYYY-MM-DD]'
)
-- 1. Requisition Created
SELECT
R.PurchaseRequisition AS "PurchaseRequisitionId",
'Requisition Created' AS "ActivityName",
R.CreationTimestamp AS "EventTime",
R.CreatedByUser AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM REQUISITIONS AS R
JOIN I_PurchaseRequisitionItemAPI01 AS I
ON R.PurchaseRequisition = I.PurchaseRequisition
UNION ALL
-- 2. Requisition Submitted For Approval & 5. Approval Step Started
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
CASE
WHEN C.ValueOld = ''
THEN 'Requisition Submitted For Approval'
ELSE 'Approval Step Started'
END AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
R.CreatedByUser AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R
ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I
ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'FRGZU' AND C.ValueNew != ''
UNION ALL
-- 3. Requisition Amended
SELECT DISTINCT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Requisition Amended' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
C.UserName AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName IN ('MENGE', 'PREIS', 'MATNR', 'LIFNR', 'INFNR')
AND C.ChangeTimestamp > R.CreationTimestamp
UNION ALL
-- 4. Approval Reset
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Approval Reset' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
C.UserName AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'FRGZU' AND C.ValueOld != '' AND C.ValueNew = ''
UNION ALL
-- 6. Approval Step Completed
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Approval Step Completed' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
NULL AS "UserId",
C.UserName AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'FRGZU' AND C.ValueNew IN ('1', '2', '3', '4', '5', '6', '7') -- Adjust release codes as per your config
UNION ALL
-- 7. Requisition Approved
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Requisition Approved' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
NULL AS "UserId",
C.UserName AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'FRGKE' AND C.ValueNew = '2' -- Final release indicator '2' is common for approved
UNION ALL
-- 8. Requisition Rejected
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Requisition Rejected' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
NULL AS "UserId",
C.UserName AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'FRGZU' AND C.ValueNew = 'B' -- 'B' for Blocked/Rejected is a common setting
UNION ALL
-- 9. Requisition Withdrawn
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Requisition Withdrawn' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
C.UserName AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'LOEKZ' AND C.ValueNew = 'X'
UNION ALL
-- 10. Source of Supply Assigned
SELECT DISTINCT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Source of Supply Assigned' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
C.UserName AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName IN ('LIFNR', 'INFNR') AND C.ValueNew != ''
AND C.ChangeTimestamp > R.CreationTimestamp
UNION ALL
-- 11. Purchase Order Created
SELECT DISTINCT
I.PurchaseRequisition AS "PurchaseRequisitionId",
'Purchase Order Created' AS "ActivityName",
CAST(CONCAT(H.PurchaseOrderDate, 'T', LPAD(H.CreationTime, 6, '0')) AS TIMESTAMP) AS "EventTime",
H.CreatedByUser AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.OrderPriceUnit * I.OrderQuantity AS "RequisitionAmount",
'PO Created' AS "RequisitionStatus"
FROM I_PurchaseOrderItemAPI01 AS I
JOIN I_PurchaseOrderAPI01 AS H
ON I.PurchaseOrder = H.PurchaseOrder
JOIN REQUISITIONS AS R
ON I.PurchaseRequisition = R.PurchaseRequisition
WHERE I.PurchaseRequisition IS NOT NULL AND I.PurchaseRequisition != ''
UNION ALL
-- 12. Requisition Closed
SELECT
C.PurchaseRequisition AS "PurchaseRequisitionId",
'Requisition Closed' AS "ActivityName",
C.ChangeTimestamp AS "EventTime",
C.UserName AS "UserId",
NULL AS "ApproverId",
R.PurchaseRequisitionType AS "RequisitionType",
I.CostCenter AS "Department",
I.RequisitionPrice * I.RequestedQuantity AS "RequisitionAmount",
I.PurReqnProcessingStatus AS "RequisitionStatus"
FROM CHANGE_DOCS AS C
JOIN REQUISITIONS AS R ON C.PurchaseRequisition = R.PurchaseRequisition
JOIN I_PurchaseRequisitionItemAPI01 AS I ON C.PurchaseRequisition = I.PurchaseRequisition
WHERE C.FieldName = 'EBAKZ' AND C.ValueNew = 'X'