Your Purchase to Pay - Invoice Processing Data Template
Your Purchase to Pay - Invoice Processing Data Template
- Recommended attributes to collect
- Key activities to track
- Extraction guidance for SAP ECC
Purchase to Pay - Invoice Processing Attributes
| Name | Description | ||
|---|---|---|---|
| Activity Activity | The name of a specific business step or event that occurred during the invoice processing lifecycle. | ||
| Description The Activity attribute represents a distinct stage or action within the invoice processing workflow. These activities are derived from various system events, such as document creation, status changes, approvals, or user actions recorded in SAP change logs. Analyzing activities is the core of process mining. It allows for the visualization of process maps, identification of bottlenecks (e.g., long waits after 'Invoice Sent For Approval'), rework loops (e.g., repeated 'Payment Block Set' and 'Payment Block Released' cycles), and compliance deviations. The sequence and frequency of activities reveal the actual, as-is process flow. Why it matters It defines the steps in the process map, enabling the visualization of process flows, discovery of bottlenecks, and identification of rework. Where to get This attribute is typically derived from multiple sources, including transaction codes (SY-TCODE), status fields in tables like RBKP (e.g., RBSTAT), and change events from tables CDHDR and CDPOS. Examples Invoice ParkedInvoice Sent For ApprovalInvoice ApprovedInvoice PostedInvoice Cleared | |||
| Event Time EventTime | The precise timestamp, including date and time, when an activity occurred. | ||
| Description Event Time records the exact moment a business activity was executed and logged in the source system. This timestamp is the chronological backbone of the process, ordering all activities for each invoice into a coherent sequence. In analysis, Event Time is essential for calculating all duration-based metrics, such as cycle times, waiting times, and processing times between activities. It powers dashboards like the 'Invoice End-to-End Cycle Time' and 'Payment Block Resolution Duration' by providing the data needed to measure the time elapsed between any two points in the process. Accurate timestamps are critical for identifying delays and performance bottlenecks. Why it matters This timestamp is essential for ordering events correctly and calculating all performance metrics, such as cycle times and bottleneck durations. Where to get This is typically derived by combining the change date (UDATE) and change time (UTIME) from the change document header table, CDHDR. For specific creation events, it can be the creation date and time from tables like RBKP (ERNAM, ERZET). Examples 2023-03-15T10:30:00Z2023-03-16T14:05:21Z2023-03-28T09:00:00Z | |||
| Invoice Number InvoiceNumber | The unique identifier for a vendor invoice document. | ||
| Description The Invoice Number serves as the unique case identifier for the invoice processing journey. Each number corresponds to a single invoice received from a vendor, allowing all related activities, from data capture to final payment, to be tracked as part of one cohesive process instance. In process mining analysis, this attribute is fundamental for reconstructing the end-to-end lifecycle of every invoice. It enables the connection of disparate events logged in SAP, such as parking, posting, blocking, and clearing, into a chronological sequence. This provides a clear view of how each invoice is handled, how long it takes, and where deviations from the standard process occur. Why it matters This is the primary key that links all events related to a single invoice, making it the essential foundation for process analysis and variant exploration. Where to get This is typically the Document Number from the SAP table RBKP, field BELNR, often concatenated with Company Code (BUKRS) and Fiscal Year (GJAHR) for absolute uniqueness. Examples 510004567851000456795100045680 | |||
| Clearing Date ClearingDate | The date on which the payment was made and the invoice was cleared from accounts payable. | ||
| Description The Clearing Date marks the final step in the invoice lifecycle: payment. It is the date the open invoice item is cleared by a payment document in the system. This date represents the actual payment execution time. This attribute is the endpoint for many critical KPIs, including the 'Average Invoice Cycle Time' and 'On-Time Payment Rate'. It is compared against the Payment Due Date to measure payment performance. For cash discount analysis, it is compared against the discount period to see if the payment was made in time to capture the discount. Why it matters It marks the completion of the process and is the basis for calculating total cycle time, on-time payment rates, and cash discount realization. Where to get For cleared items, this is the 'Clearing Date' field (AUGDT) from the cleared vendor items table, BSAK. Examples 2023-04-152023-05-022023-05-20 | |||
| Invoice Amount InvoiceAmount | The total gross amount of the invoice in the original document currency. | ||
| Description Invoice Amount represents the total value of the invoice submitted by the vendor. This is a key financial metric for each invoice case. In process mining, this attribute is essential for value-based analysis. It allows for filtering and segmenting the process based on invoice value, which often correlates with process complexity and approval requirements. For instance, high-value invoices might follow a different, more stringent approval path. It is also used in compliance analysis, for example, checking if high-value invoices bypass required approval steps. Why it matters It enables value-based analysis, helping to prioritize high-value invoices and understand how invoice amount impacts process flow and compliance. Where to get This is the 'Gross invoice amount' field (RMWWR) from the invoice document header table, RBKP. Examples 1500.7512500.00850.20 | |||
| Payment Block Reason PaymentBlockReason | A code indicating the reason why an invoice is blocked from payment. | ||
| Description When an invoice has a discrepancy or requires further investigation, a payment block is applied. The Payment Block Reason code specifies why the block was set, for example, due to a quantity variance, price variance, or a manual block. This attribute is essential for the 'Payment Block Resolution Duration' dashboard. Analyzing the frequency and duration of blocks by reason helps to identify the root causes of payment delays. For instance, if 'Price Discrepancy' is the most common reason for long blocks, it points to a potential issue in master data or the purchase order process that needs to be addressed. Why it matters It explains why invoices are delayed, enabling root cause analysis of payment blocks and helping to prioritize process improvement efforts. Where to get The payment block reason can be found at the item level in table RSEG (field SPGRS) or in the accounting document table BSEG (field ZLSPR). Examples RIM | |||
| Payment Due Date PaymentDueDate | The date by which the invoice payment is due to the vendor, according to the payment terms. | ||
| Description The Payment Due Date is calculated based on the invoice's baseline date and the agreed payment terms. It represents the deadline for making the payment to avoid being late and potentially incurring penalties or damaging vendor relationships. This attribute is crucial for performance and compliance KPIs like the 'On-Time Payment Rate' and 'Cash Discount Opportunity Loss'. By comparing the actual payment date (Clearing Date) to the Payment Due Date, the analysis can automatically determine if a payment was on time, early, or late. It is a foundational element for the Payment Terms Adherence dashboard. Why it matters It serves as the baseline for measuring on-time payment performance and identifying opportunities for capturing early payment discounts. Where to get This date is often calculated. The baseline date for payment (ZFBDT) is in table BSEG. The due date logic also depends on payment terms (BSEG-ZTERM). Examples 2023-04-192023-05-052023-05-11 | |||
| Posting Date PostingDate | The date on which the invoice was officially posted to the financial ledgers. | ||
| Description The Posting Date is a key date in the accounting process. It determines the fiscal period in which the invoice expense is recognized in the General Ledger. It is typically set by the accounts payable clerk during invoice processing. In process analysis, the 'Invoice Posted' activity, marked by this date, is a major milestone. The duration from invoice receipt to the Posting Date is a critical component of the overall cycle time. This date is also fundamental for financial reporting and throughput analysis, such as tracking the volume of invoices posted per week or month. Why it matters It marks a critical milestone in the process, determines the financial period for the transaction, and is a key component of cycle time calculation. Where to get This is the 'Posting Date' field (BUDAT) from the invoice document header table, RBKP. Examples 2023-03-202023-04-052023-04-11 | |||
| Purchase Order Number PurchaseOrderNumber | The identifier for the Purchase Order (PO) against which the invoice is matched. | ||
| Description The Purchase Order Number links an invoice to the original procurement document. This is fundamental for three-way matching (PO, Goods Receipt, Invoice) and for analyzing the efficiency of the PO-backed invoice process. This attribute is critical for dashboards like the 'Invoice-PO Matching Discrepancy Rate'. It allows for segmenting the process into PO-invoices versus non-PO invoices, which often have very different processing paths and complexities. Analyzing issues related to specific POs can help diagnose upstream problems in the procurement process. Why it matters It connects the invoice to the procurement process, enabling analysis of PO vs. non-PO invoices and identifying matching discrepancies. Where to get This is typically found at the line item level. The 'Purchase Order Number' (EBELN) is in the invoice item table, RSEG. It may need to be aggregated to the header level. Examples 450001756345000175644500017565 | |||
| User Name UserName | The SAP user ID of the person who executed the activity. | ||
| Description The User Name attribute identifies the specific individual responsible for performing a given activity in the process. This is typically the SAP username logged with the transaction or change event. This attribute is crucial for performance analysis at the user or team level. It helps answer questions like 'Who are the fastest approvers?' or 'Which users generate the most rework?'. It is used in dashboards to analyze workload distribution, identify training needs, and understand variations in performance across different employees. Why it matters It allows for analysis of performance and workload by individual or team, helping to identify top performers, training opportunities, and resource imbalances. Where to get This is the 'Changed By' field (USERNAME) from the change document header table, CDHDR. For creation events, it can be the 'Entered by' field (ERNAM) in tables like RBKP. Examples JSMITHBWILSONCHEN | |||
| Vendor Number VendorNumber | A unique identifier for the vendor or supplier who submitted the invoice. | ||
| Description The Vendor Number is the master data key that identifies the supplier. This links the invoice transaction to a specific business partner, enabling analysis based on vendor characteristics. Analyzing the process by Vendor Number can reveal important insights into supplier relationships and performance. For example, it can help identify which vendors consistently submit problematic invoices that lead to payment blocks or discrepancies, or which vendors' invoices are processed most efficiently. This information is valuable for vendor management and strategic sourcing initiatives. Why it matters It enables vendor-specific analysis, helping to identify patterns, issues, or efficiencies associated with particular suppliers. Where to get This is the 'Invoicing Party' field (LIFNR) from the invoice document header table, RBKP. Examples 100345100876200112 | |||
| Company Code CompanyCode | The identifier for the legal entity or company for which the invoice is being processed. | ||
| Description The Company Code is a fundamental organizational unit in SAP Financials, representing an independent legal entity. All financial transactions, including invoices, are posted to a specific company code. This attribute allows for process analysis to be segmented by legal entity. It is crucial for comparing process performance, compliance, and efficiency across different companies within a corporate group. Dashboards can be filtered by Company Code to provide a company-specific view of invoice processing KPIs. Why it matters It enables process comparison and performance benchmarking across different legal entities within an organization. Where to get This is the 'Company Code' field (BUKRS) from the invoice document header table, RBKP. Examples 10002000US01 | |||
| Currency Currency | The currency code for the invoice amount. | ||
| Description The Currency attribute specifies the currency in which the invoice amount is denominated, for example, USD, EUR, or JPY. This attribute provides essential context for the Invoice Amount. It allows for correct interpretation and aggregation of financial data, especially in global organizations dealing with multiple currencies. Analysis can be filtered by currency to compare processing efficiency or issues across different currency zones. For meaningful financial aggregation, amounts may need to be converted to a single reporting currency. Why it matters It provides necessary context for any financial amounts, ensuring accurate interpretation and enabling currency-based filtering and analysis. Where to get This is the 'Currency Key' field (WAERS) from the invoice document header table, RBKP. Examples USDEURGBP | |||
| Document Type DocumentType | A code that classifies the accounting document, for example, as a vendor invoice or credit memo. | ||
| Description The Document Type is used to categorize different kinds of business transactions in SAP. For invoice processing, common types include 'RE' for standard invoices or 'KG' for vendor credit memos. The document type controls aspects of the posting, such as the number range used. In analysis, this attribute allows for filtering the process to specific transaction types. For example, the process for handling a credit memo can be significantly different from that of a standard invoice. Separating these flows using the Document Type provides a more accurate and meaningful process view. Why it matters It allows for the separation and analysis of different business transactions, such as invoices versus credit memos, which follow different processes. Where to get This is the 'Document Type' field (BLART) from the invoice document header table, RBKP. Examples REKRKG | |||
| End Time EndTime | The timestamp indicating when an activity was completed. For instantaneous events, this is the same as the Start Time. | ||
| Description The End Time attribute marks the completion of a specific activity. For many events in SAP, which are logged as single points in time, the End Time will be identical to the Start Time. However, for activities that have a measurable duration, like an approval step that is actively being worked on, it can represent the conclusion of that work. In process analysis, having a distinct End Time allows for the measurement of activity processing time, separate from the waiting time that precedes it. This helps differentiate how long an activity takes to execute versus how long a case waits for that activity to begin, providing deeper insights into resource efficiency. Why it matters It enables the calculation of activity processing time, distinguishing it from the waiting time between activities and improving bottleneck analysis. Where to get This is often the same as the Start Time, derived from CDHDR-UDATE and CDHDR-UTIME. In some cases, it can be derived from workflow logs that explicitly record the start and end of a task. Examples 2023-03-15T10:35:10Z2023-03-16T14:10:00Z2023-03-28T09:02:45Z | |||
| General Ledger Account GeneralLedgerAccount | The G/L account number to which the invoice expense or cost is posted. | ||
| Description The General Ledger (G/L) Account is the destination account in the chart of accounts where the financial impact of the invoice is recorded. This is a critical piece of data for financial reporting and cost management. For process mining, analyzing the G/L account provides a financial dimension to the process flow. The 'General Ledger Account Usage Analysis' dashboard can reveal patterns in spending, identify potential miscoding of invoices, and ensure costs are being allocated to the correct departments or projects. It helps bridge the gap between process execution and financial impact. Why it matters It adds a financial dimension to the process, allowing for analysis of cost allocation, spending patterns, and potential invoice miscoding. Where to get This is found at the line item level. The 'G/L Account Number' (HKONT) is in the invoice item table RSEG for PO invoices or BSEG for direct FI invoices. Examples 630000655100741000 | |||
| Is Cash Discount Lost IsCashDiscountLost | A calculated flag that indicates if an available cash discount was missed. | ||
| Description This is a boolean attribute calculated based on payment terms and the actual payment date. It is set to true if the 'Payment Terms' offered a discount for early payment and the 'Clearing Date' was after the discount period expired. This directly measures financial loss due to process inefficiencies. This attribute is the foundation of the 'Cash Discount Opportunity Loss' dashboard. It allows for easy quantification of the financial impact of processing delays. By filtering for cases where this flag is true, analysts can investigate the specific process variants and bottlenecks that most frequently lead to missed discounts, providing a strong business case for process improvement. Why it matters It directly quantifies the financial loss from process delays, creating a compelling case for optimizing the invoice processing workflow. Where to get This attribute is not in SAP. It is calculated during data transformation by interpreting the 'PaymentTerms' and comparing the 'ClearingDate' to the discount due date. Examples truefalse | |||
| Is Overdue IsOverdue | A calculated flag that indicates whether the invoice was paid after its payment due date. | ||
| Description This is a boolean attribute calculated by comparing the 'Clearing Date' (actual payment date) with the 'Payment Due Date'. If the clearing date is after the due date, the flag is true; otherwise, it is false. This provides a simple, direct measure of on-time payment performance for each invoice. This attribute simplifies analysis and visualization in dashboards. It allows for easy filtering and aggregation to calculate the 'On-Time Payment Rate' KPI. Users can quickly segment the process to compare the process flows of overdue invoices versus those paid on time, potentially revealing the process patterns that lead to late payments. Why it matters It simplifies the analysis of on-time payment performance and allows for easy comparison between on-time and late invoice processes. Where to get This attribute is not in SAP. It is calculated during data transformation using the formula: ClearingDate > PaymentDueDate. Examples truefalse | |||
| Last Data Update LastDataUpdate | Timestamp indicating when the data for the process was last refreshed from the source system. | ||
| Description This attribute records the date and time of the most recent data extraction or update. It applies to the entire dataset rather than individual events, providing a clear indication of the data's freshness. This is a critical metadata attribute for dashboard users and analysts. It helps them understand the time period covered by the analysis and ensures they are making decisions based on current information. It is typically displayed prominently on dashboards to inform users of the data's recency. Why it matters It informs users about the freshness of the data, ensuring that analysis and decisions are based on up-to-date information. Where to get This value is generated and injected into the dataset by the data extraction or ETL tool at the time of the data refresh. Examples 2024-05-20T08:00:00Z2024-05-21T08:00:00Z2024-05-22T08:00:00Z | |||
| Payment Terms PaymentTerms | The code defining the payment terms agreed upon with the vendor, such as discount periods and due dates. | ||
| Description Payment Terms define the rules for when an invoice must be paid and what, if any, cash discounts are available for early payment. Examples include 'Net 30 days' or '2% 10, Net 30', meaning a 2% discount if paid in 10 days, otherwise the full amount is due in 30 days. This attribute is the foundation for the 'Cash Discount Opportunity Loss' dashboard and the 'Cash Discount Capture Rate' KPI. The analysis uses the payment terms in conjunction with the posting and payment dates to determine if a discount was available and if it was successfully taken. It is also key for the Payment Terms Adherence dashboard. Why it matters It is essential for analyzing cash discount capture rates and understanding the financial impact of process delays. Where to get This is the 'Terms of Payment Key' field (ZTERM) from the invoice document header table, RBKP. Examples Z0010001NT30 | |||
| Processing Time ProcessingTime | The duration of time spent on a specific activity. | ||
| Description Processing Time measures the time it takes to execute an activity, from its start to its end. It is calculated as the difference between the End Time and the Start Time of an activity. This is distinct from cycle time, which includes the waiting time between activities. Analyzing processing time helps to understand the actual effort or touch time for different steps. It can pinpoint activities that are resource-intensive or inefficient. For example, a long 'Invoice Data Captured' processing time could indicate a complex invoice or an inefficient data entry process. This metric is valuable for resource planning and automation initiatives. Why it matters It measures the actual work duration for an activity, helping to identify resource-intensive steps and distinguish between active work time and idle waiting time. Where to get This attribute is not in SAP. It is calculated during data transformation using the formula: EndTime - StartTime. Examples PT5M10SPT2H15MPT30S | |||
| Rejection Reason RejectionReason | A code or text explaining why an invoice was rejected during the approval workflow. | ||
| Description When an approver rejects an invoice, they ideally provide a reason for the rejection. This could be a standardized code or a free-text comment indicating issues like 'Incorrect PO number', 'Duplicate Invoice', or 'Amount incorrect'. This data is vital for the 'Invoice Rejection Reasons & Trends' dashboard. By analyzing the frequency of different rejection reasons, the business can identify common problems and implement corrective actions. For example, if 'Incorrect PO number' is a frequent reason, it might indicate a need for better communication with vendors or training for data entry staff. This analysis is key to reducing process rework. Why it matters It provides the root cause for rejections, enabling targeted process improvements to reduce rework and improve first-time-right rates. Where to get This information is often not stored in a single, standard field. It might be found in workflow container logs, long text fields associated with the document, or specific fields in a custom workflow solution. Examples DUPLICATE_INVWRONG_AMTNO_PO_MATCH | |||
| Source System SourceSystem | Identifies the specific source system from which the data was extracted. | ||
| Description The Source System attribute indicates the origin of the event data, for example, a specific SAP ECC instance name. This is particularly important in environments with multiple ERP systems or when data is combined from different sources. In analysis, this attribute helps differentiate processes and performance across various systems, regions, or business units that might be running on separate instances. It ensures data lineage is clear and allows for system-specific filtering and analysis. Why it matters It provides crucial context in multi-system landscapes, allowing for proper data segregation and system-specific performance analysis. Where to get This is typically a static value added during the data extraction process, representing the SAP System ID (TADIR-SRCSYSTEM) or a manually assigned identifier for the specific SAP instance. Examples SAPECC_PROD_EUECC_US_FINSAP_ERP_6_EHP8 | |||
Purchase to Pay - Invoice Processing Activities
| Activity | Description | ||
|---|---|---|---|
| Invoice Cleared | This activity marks the final step in a successful invoice lifecycle, where the open liability is cleared by a payment document. This signifies that payment has been executed. | ||
| Why it matters As the primary end event, this is crucial for calculating the total end-to-end cycle time. It confirms the successful completion of the process and is used to measure on-time payment performance. Where to get This is an explicit event recorded in the invoice line item table BSEG. The clearing date is stored in field AUGDT, and the clearing document number in AUGBL. Capture Use the clearing date (BSEG-AUGDT) from the line item of the invoice document. Event type explicit | |||
| Invoice Data Captured | Marks the initial creation of the invoice document in SAP, either as a parked or fully posted document. This is typically the first recorded event in the system for an invoice's lifecycle and serves as the process start time. | ||
| Why it matters This activity is the primary start point for measuring the end-to-end invoice processing cycle time. Analyzing the duration from this point helps identify delays in the initial data entry and document creation phase. Where to get The creation timestamp is captured in the SAP table BKPF, field CPUDT (Date on Which Accounting Document Was Entered) and CPUTM (Time of Entry). Capture Use the document creation timestamp from the BKPF table header (CPUDT). Event type explicit | |||
| Invoice Posted | This is a key financial event where the invoice is officially recorded in the general ledger, creating a liability. This moves the document from a temporary (parked) state to a permanent accounting entry. | ||
| Why it matters Posting is a major milestone that confirms the validity of the invoice. It is a prerequisite for payment and a key indicator of processing throughput. Where to get This is an explicit event recorded in the document header table BKPF. The timestamp is the posting date, BKPF-BUDAT. The document will no longer have a 'parked' status. Capture Use the posting date (BKPF-BUDAT) for documents that are not parked (BKPF-BSTAT is blank or ' '). Event type explicit | |||
| Invoice Reversed | Represents the cancellation of a posted invoice document. A reversal document is created to negate the financial impact of the original invoice. | ||
| Why it matters This activity highlights a significant exception and rework path. Analyzing the frequency and reasons for reversals can uncover systemic issues in the invoice validation and posting process. Where to get This is an explicit event recorded in the document header table BKPF. The header of the reversed document contains the reversal document number (STBLG) and fiscal year (STJAH). Capture Identify documents where BKPF-STBLG is populated. The event timestamp is the posting date of the reversal document. Event type explicit | |||
| Payment Block Set | This activity occurs when a block is placed on an invoice line item, preventing it from being paid. Blocks can be set automatically due to discrepancies in three-way matching or manually for various reasons. | ||
| Why it matters This event is critical for measuring the Payment Block Resolution Duration and identifying the root causes of payment delays. It highlights issues with pricing, quantity, or required approvals. Where to get This is an explicit event that can be tracked through change document logs (tables CDHDR and CDPOS) for the BSEG table, field ZLSPR (Payment Block Key). Capture Timestamp from change documents (CDHDR) when the value of BSEG-ZLSPR changes from blank to non-blank. Event type explicit | |||
| Invoice Approved | Signifies that the invoice has been formally approved by the designated authority, allowing it to proceed to posting and payment. This is often the concluding step of a workflow. | ||
| Why it matters This milestone concludes the approval cycle time measurement. It unblocks the process, allowing for timely payment and helping to analyze workload distribution among approvers. Where to get This is typically captured from SAP Business Workflow tables by identifying the completion of an approval task. Alternatively, it can be inferred from the release of an approval-related payment block. Capture Timestamp of the completed approval step in workflow logs or the removal of a specific payment block. Event type inferred | |||
| Invoice Becomes Overdue | A calculated event that occurs when the current date passes the invoice's net due date and the invoice has not yet been paid. The due date is determined from payment terms and the baseline date. | ||
| Why it matters This activity is essential for monitoring the On-Time Payment Rate KPI. It proactively flags invoices at risk of late payment, which can harm vendor relationships and incur penalties. Where to get This event is calculated by comparing the current date against the net due date. The due date is derived from the baseline date (BSEG-ZFBDT) and payment terms (BSEG-ZTERM). Capture Event is triggered when Event type calculated | |||
| Invoice Parked | Indicates that an invoice has been entered into SAP but has not yet been posted to the general ledger. This is a temporary state allowing for review, correction, or approval before financial posting. | ||
| Why it matters Tracking when invoices are parked and for how long highlights bottlenecks in the pre-posting validation and approval process. It separates data entry time from financial processing time. Where to get This is inferred from the document status in table BKPF, field BSTAT. A value of 'V' (Parked Document) or 'W' (Parked Document with Change Release) indicates a parked state. Capture Identify documents where the status field BKPF-BSTAT is 'V'. The event timestamp is the creation date BKPF-CPUDT. Event type inferred | |||
| Invoice Rejected | Indicates that an invoice has been rejected during the approval process. This action typically requires correction and resubmission, creating a rework loop. | ||
| Why it matters Tracking rejections is crucial for identifying common reasons for failure, such as incorrect data or policy violations. It helps quantify rework and pinpoint areas for process improvement or vendor education. Where to get This event is usually found in SAP Business Workflow logs as a rejection step. It can also be inferred from specific status changes or notes added to the invoice document. Capture Timestamp of the rejection step in workflow logs or a document status change indicating rejection. Event type inferred | |||
| Invoice Sent For Approval | Represents the point where an invoice is submitted into a formal approval workflow. The capture mechanism is highly dependent on the specific SAP Workflow or third-party system implementation. | ||
| Why it matters This activity starts the clock for the Invoice Approval Cycle Time KPI. It is essential for identifying delays in the approval chain and analyzing approver performance. Where to get This event is typically captured from SAP Business Workflow tables (e.g., SWW_WI2OBJ, SWWLOG) by identifying the start of a specific approval task. In simpler scenarios, it may be inferred from a status change in a custom field. Capture Requires analysis of SAP workflow logs or custom status fields linked to the invoice document. Event type inferred | |||
| Payment Block Released | Represents the removal of a payment block from an invoice line item, allowing it to proceed to the payment run. This signifies that a previously identified issue has been resolved. | ||
| Why it matters This activity concludes the measurement of block duration. Analyzing the time between a block being set and released reveals the efficiency of the issue resolution process. Where to get This event is tracked through change document logs (tables CDHDR and CDPOS) for the BSEG table, field ZLSPR (Payment Block Key), when the block is removed. Capture Timestamp from change documents (CDHDR) when the value of BSEG-ZLSPR changes from non-blank to blank. Event type explicit | |||
Extraction Guides
Steps
- Create the ABAP Program: Use transaction
SE38orSE80to create a new executable program, for example,Z_PM_INVOICE_EXTRACT. Provide a suitable title and set the type to 'Executable Program'. - Define the Selection Screen: In the program, define a selection screen to allow users to filter the data. Key parameters should include Company Code (
BUKRS), Fiscal Year (GJAHR), Posting Date Range (BUDAT), and a parameter for the output file path on the application server. - Declare Data Structures: Define an internal table structure that will hold the final event log. This structure must include all required and recommended attributes:
InvoiceNumber,Activity,EventTime,UserName,VendorNumber,PurchaseOrderNumber,InvoiceAmount,PostingDate,PaymentDueDate,PaymentBlockReason, andClearingDate. - Implement Data Selection Logic: Write the core ABAP logic to select invoice data. The approach involves multiple selections that are combined into the final event log table.
- First, select header and item data from primary invoice tables
BKPF,BSEG,RBKP, andRSEGbased on the selection screen criteria. - For each invoice, generate the base events like 'Invoice Data Captured' (from creation timestamp) and 'Invoice Posted' (from posting timestamp).
- Query change document tables
CDHDRandCDPOSto find changes related to payment blocks (ZLSPRfield inBSEG). For each relevant change, create 'Payment Block Set' and 'Payment Block Released' events. - Identify 'Invoice Cleared' events by checking for a clearing document (
AUGBL) and clearing date (AUGDT) in tableBSEG. - Identify 'Invoice Reversed' events by checking for a reversal document (
STBLG) in theBKPFheader. - Implement custom logic to capture workflow events ('Invoice Sent For Approval', 'Approved', 'Rejected'). This part is highly customer-specific and requires adapting the code to your workflow's tables or status fields.
- First, select header and item data from primary invoice tables
- Generate Calculated Events: Within the program logic, calculate the
Invoice Becomes Overdueevent. This is derived by comparing the invoice payment due date (PaymentDueDate) with the current date for all unpaid invoices. If the due date is in the past, create an event with theEventTimeset to the due date. - Populate the Event Log Table: As you gather data for each invoice from the different sources, format it and append new rows to the final internal event log table, one row per activity.
- Export the Data to a File: Use the
OPEN DATASET,TRANSFER, andCLOSE DATASETstatements to write the contents of the final internal table to a flat file on the SAP application server path specified on the selection screen. Use a consistent separator, like a semicolon or tab, to create a CSV file. - Schedule the Extraction: For regular data extraction, create a variant for the program with the desired selection criteria and schedule it to run as a background job using transaction
SM36. - Retrieve the Output File: Access the SAP application server directory using transaction
AL11to locate the generated file. Use transactionCG3Yto download the file from the application server to your local machine. - Prepare for Upload: Before uploading to a process mining tool, open the CSV file to verify the headers are correct, the data format is consistent (especially for timestamps), and the separator is as expected. Ensure the file is saved with UTF-8 encoding.
Configuration
- Selection Criteria: The ABAP report should include a comprehensive selection screen. The most important filters are:
Company Code (BUKRS): To limit the extraction to specific legal entities.Posting Date (BUDAT): To define the time frame for the extraction. It is recommended to extract data in manageable chunks, for example, 3 to 6 months at a time.Document Type (BLART): To include only relevant invoice document types, such as 'RE' for logistics invoices and 'KR' for vendor invoices.
- Output File Path: A mandatory parameter to specify the full path and filename on the SAP application server where the output file will be created. The user running the report needs write authorization to this directory.
- Performance Considerations: For large datasets, the report should be executed as a background job during off-peak hours to avoid performance degradation of the system. The logic should select only the required fields from tables and utilize standard SAP database indexes where possible.
- Prerequisites and Authorizations: The user or service account running this extraction requires:
- ABAP report execution permissions (part of
S_PROGRAM). - Read access to financial and logistics tables including
BKPF,BSEG,RBKP,RSEG,CDHDR, andCDPOS. - Authorization to write files to the specified application server directory (
S_DATASET). - Access to transactions
SE38,SM36,AL11, andCG3Yfor development, scheduling, and file retrieval.
- ABAP report execution permissions (part of
a Sample Query abap
REPORT Z_PM_INVOICE_EXTRACT.
*&---------------------------------------------------------------------*
*& Tables for Selection Screen
*&---------------------------------------------------------------------*
TABLES: BKPF, RBKP.
*&---------------------------------------------------------------------*
*& Data Declarations
*&---------------------------------------------------------------------*
TYPES: BEGIN OF ty_event_log,
InvoiceNumber TYPE belnr_v,
Activity TYPE string,
EventTime TYPE timestamp,
UserName TYPE uname,
VendorNumber TYPE lifnr,
PurchaseOrderNumber TYPE ebeln,
InvoiceAmount TYPE wrbtr,
PostingDate TYPE budat,
PaymentDueDate TYPE faedt,
PaymentBlockReason TYPE rstgr,
ClearingDate TYPE augdt,
END OF ty_event_log.
DATA: gt_event_log TYPE TABLE OF ty_event_log,
gs_event_log TYPE ty_event_log.
DATA: lt_bkpf TYPE TABLE OF bkpf,
ls_bkpf TYPE bkpf,
lt_bseg TYPE TABLE OF bseg,
ls_bseg TYPE bseg.
DATA: lt_rbkp TYPE TABLE OF rbkp,
ls_rbkp TYPE rbkp.
*&---------------------------------------------------------------------*
*& Selection Screen
*&---------------------------------------------------------------------*
SELECT-OPTIONS: s_bukrs FOR bkpf-bukrs OBLIGATORY,
s_gjahr FOR bkpf-gjahr OBLIGATORY,
s_budat FOR bkpf-budat.
PARAMETERS: p_fpath TYPE string OBLIGATORY DEFAULT '/usr/sap/tmp/invoice_events.csv'.
*&---------------------------------------------------------------------*
*& Start of Program Logic
*&---------------------------------------------------------------------*
START-OF-SELECTION.
" Select FI Invoices (e.g., Doc Type KR)
SELECT * FROM bkpf INTO TABLE lt_bkpf
WHERE bukrs IN s_bukrs
AND gjahr IN s_gjahr
AND budat IN s_budat
AND blart = 'KR'.
" Select MM Invoices
SELECT * FROM rbkp INTO TABLE lt_rbkp
WHERE bukrs IN s_bukrs
AND gjahr IN s_gjahr
AND budat IN s_budat.
* --- Process FI Invoices ---
LOOP AT lt_bkpf INTO ls_bkpf.
CLEAR gs_event_log.
gs_event_log-InvoiceNumber = ls_bkpf-belnr.
gs_event_log-PostingDate = ls_bkpf-budat.
SELECT SINGLE * FROM bseg INTO ls_bseg
WHERE bukrs = ls_bkpf-bukrs
AND belnr = ls_bkpf-belnr
AND gjahr = ls_bkpf-gjahr
AND koart = 'K'. " Vendor Line Item
IF sy-subrc = 0.
gs_event_log-VendorNumber = ls_bseg-lifnr.
gs_event_log-InvoiceAmount = ls_bseg-wrbtr.
gs_event_log-ClearingDate = ls_bseg-augdt.
" Calculate Due Date
CALL FUNCTION 'DETERMINE_DUE_DATE'
EXPORTING
i_bseg = ls_bseg
IMPORTING
e_faedt = gs_event_log-PaymentDueDate.
ENDIF.
" Activity: Invoice Data Captured
gs_event_log-Activity = 'Invoice Data Captured'.
CONVERT DATE ls_bkpf-cpudt TIME ls_bkpf-cputm INTO TIME STAMP gs_event_log-EventTime TIME ZONE sy-zonlo.
gs_event_log-UserName = ls_bkpf-usnam.
APPEND gs_event_log TO gt_event_log.
" Activity: Invoice Parked (if BSTAT = 'V')
IF ls_bkpf-bstat = 'V'.
gs_event_log-Activity = 'Invoice Parked'.
APPEND gs_event_log TO gt_event_log.
ENDIF.
" Activity: Invoice Posted
gs_event_log-Activity = 'Invoice Posted'.
CONVERT DATE ls_bkpf-budat TIME ls_bkpf-cputm INTO TIME STAMP gs_event_log-EventTime TIME ZONE sy-zonlo.
gs_event_log-UserName = ls_bkpf-usnam.
APPEND gs_event_log TO gt_event_log.
" Activity: Invoice Cleared
IF ls_bseg-augbl IS NOT INITIAL.
gs_event_log-Activity = 'Invoice Cleared'.
CONVERT DATE ls_bseg-augdt INTO TIME STAMP gs_event_log-EventTime TIME ZONE sy-zonlo.
gs_event_log-UserName = ls_bseg-usnam_cl.
APPEND gs_event_log TO gt_event_log.
ENDIF.
" Activity: Invoice Becomes Overdue
IF gs_event_log-PaymentDueDate IS NOT INITIAL AND gs_event_log-PaymentDueDate < sy-datum AND ls_bseg-augbl IS INITIAL.
gs_event_log-Activity = 'Invoice Becomes Overdue'.
CONVERT DATE gs_event_log-PaymentDueDate INTO TIME STAMP gs_event_log-EventTime TIME ZONE sy-zonlo.
gs_event_log-UserName = 'SYSTEM'.
APPEND gs_event_log TO gt_event_log.
ENDIF.
" Activity: Invoice Reversed
IF ls_bkpf-stblg IS NOT INITIAL.
DATA: ls_rev_bkpf TYPE bkpf.
SELECT SINGLE budat, usnam FROM bkpf INTO ls_rev_bkpf
WHERE belnr = ls_bkpf-stblg AND bukrs = ls_bkpf-bukrs AND gjahr = ls_bkpf-gjahr.
IF sy-subrc = 0.
gs_event_log-Activity = 'Invoice Reversed'.
CONVERT DATE ls_rev_bkpf-budat INTO TIME STAMP gs_event_log-EventTime TIME ZONE sy-zonlo.
gs_event_log-UserName = ls_rev_bkpf-usnam.
APPEND gs_event_log TO gt_event_log.
ENDIF.
ENDIF.
ENDLOOP.
* --- NOTE: The logic for MM invoices (from lt_rbkp) would be similar, joining RBKP with RSEG.
* --- NOTE: The logic for Payment Blocks and Workflow events requires reading change documents (CDHDR/CDPOS)
* --- or custom workflow tables. Below is a conceptual example for payment blocks.
* --- Conceptual Example for 'Payment Block Set' / 'Released' using Change Docs
* DATA: lt_cdhdr TYPE TABLE OF cdhdr, ls_cdhdr TYPE cdhdr,
* lt_cdpos TYPE TABLE OF cdpos, ls_cdpos TYPE cdpos.
* SELECT * FROM cdhdr INTO TABLE lt_cdhdr
* WHERE objectclas = 'BELEG' AND objectid IN (SELECT belnr FROM bkpf WHERE ...).
* LOOP AT lt_cdhdr.
* SELECT * FROM cdpos INTO TABLE lt_cdpos
* WHERE changenr = ls_cdhdr-changenr AND tabname = 'BSEG' AND fname = 'ZLSPR'.
* LOOP AT lt_cdpos.
* "... logic to create 'Payment Block Set' (if VALUE_NEW is not blank)
* "... or 'Payment Block Released' (if VALUE_NEW is blank) events.
* ENDLOOP.
* ENDLOOP.
* --- Conceptual Example for Workflow events ('Sent For Approval', 'Approved', 'Rejected')
* --- This part MUST be customized based on your specific workflow implementation (e.g., OpenText VIM, SAP WF).
* --- You would query the relevant workflow tables or status change tables here.
*&---------------------------------------------------------------------*
*& Write to File
*&---------------------------------------------------------------------*
END-OF-SELECTION.
DATA: lv_string TYPE string,
lv_header TYPE string.
" Create Header
lv_header = 'InvoiceNumber;Activity;EventTime;UserName;VendorNumber;PurchaseOrderNumber;InvoiceAmount;PostingDate;PaymentDueDate;PaymentBlockReason;ClearingDate'.
OPEN DATASET p_fpath FOR OUTPUT IN TEXT MODE ENCODING UTF-8.
IF sy-subrc = 0.
TRANSFER lv_header TO p_fpath.
LOOP AT gt_event_log INTO gs_event_log.
CONCATENATE gs_event_log-InvoiceNumber
gs_event_log-Activity
gs_event_log-EventTime
gs_event_log-UserName
gs_event_log-VendorNumber
gs_event_log-PurchaseOrderNumber
gs_event_log-InvoiceAmount
gs_event_log-PostingDate
gs_event_log-PaymentDueDate
gs_event_log-PaymentBlockReason
gs_event_log-ClearingDate
INTO lv_string SEPARATED BY ';'.
TRANSFER lv_string TO p_fpath.
ENDLOOP.
CLOSE DATASET p_fpath.
ELSE.
MESSAGE 'Error opening file.' TYPE 'E'.
ENDIF.