Intelligent interrogation method and system based on operating data of SAP system

By combining ETL tools and parameterized SQL framework templates with large language models, the data structure and permission adaptation issues in the SAP system were resolved, enabling accurate, stable, and secure enterprise business data analysis and improving data analysis efficiency and security.

CN122633716APending Publication Date: 2026-08-25INTELLIGENT ELECTRONIC DATA SERVICES
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610715747.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-22
Publication Date
2026-08-25

AI Technical Summary

Technical Problem

Existing intelligent query technology cannot adapt to the unique data structure, complex permission system and professional business logic of the SAP system environment, resulting in insufficient query accuracy and poor security, making it difficult to achieve accurate, stable and secure enterprise business data analysis.

Method used

Data is extracted using ETL tools and converted into columnar storage. A parameterized SQL framework template is configured, and permission mappings between personnel roles, tools, and data are set. Semantic parsing and permission verification are performed using a large language model to generate accurate structured query statements.

Benefits of technology

It improved the accuracy and stability of SAP system intelligent data query, ensured the security of data access, adapted to SAP system changes, and improved the efficiency of business data analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122633716A_ABST
    Figure CN122633716A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of enterprise resource planning data analysis, and provides a business data intelligent query method and system based on an SAP system, wherein original data is extracted from the SAP system through an ETL tool, and is loaded into a business index database after preprocessing; a parameterized SQL framework template is preset for a high-frequency business scenario, and the name and business description thereof are vectorized and coded, and are stored in a tool (tools) vector database; a personnel role is established, a domain access permission is configured for an intelligent agent, and a fine-grained access permission based on the personnel role is set for a tool (tools) component; a user query request is received, a SQL framework template with the highest semantic similarity is searched from the tool (tools) vector database, parameter filling and logic verification are performed, a structured query statement is generated, a query is executed after a permission filtering condition is dynamically injected according to the fine-grained access permission, and a result is returned. The application improves the accuracy, stability and security of intelligent query.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of enterprise resource planning data analysis technology, and provides a method and system for intelligent data analysis of business data based on the SAP system. Background Technology

[0002] The core of intelligent query systems lies in translating human natural language into a structured query language (SQL) that databases can recognize. While this concept seems simple, its practical implementation faces numerous challenges. Even though large language models like GPT-4 demonstrate exceptional capabilities in understanding and generating human language, accurately translating complex, ambiguous, or subtle questions into executable SQL code remains a formidable task. Early attempts often failed due to generating grammatically incorrect queries and misinterpreting user intent.

[0003] SAP Enterprise Resource Planning (ERP) system, as a complex enterprise resource planning system, supports core business management such as finance, supply chain, production, and sales. Its database table structure is often opaque and difficult to understand for non-technical users and external systems. SAP's database design is highly complex, containing numerous custom tables, views, indexes, and relationships. These structures are primarily optimized to support SAP's business logic rather than direct data access. For enterprise operational data analysis, achieving accurate and stable intelligent data analysis based on the SAP system faces numerous technical challenges.

[0004] Currently, some related technical solutions have been applied in the field of enterprise data analysis. For example, the patent application (publication number: CN119396859A) filed by Kingdee Software (China) Co., Ltd. for "Large Language Model Data Analysis Method, Device, Computer Equipment and Storage Medium" is applied to enterprise resource planning systems. It obtains the data information to be analyzed, matches target data indicators with a pre-set data indicator set, and then derives the data analysis results. However, this solution mainly focuses on general ERP systems and has not been optimized for the unique data structure and business logic of SAP systems. For example, the complex cost accounting logic of the financial module and the multi-level product structure data of the material management module in SAP systems cannot be fully utilized by this technology for accurate analysis using SAP's specific data dictionary and business rules. It also struggles to generate accurate and effective analysis results when faced with complex queries involving SAP-specific business concepts.

[0005] For example, the patent application (publication number: CN119884166A) filed by Beijing Zhipu Huazhang Technology Co., Ltd., entitled "A Method, Device and Storage Medium for Enterprise Intelligent Data Query Implementation," uses concurrent intent recognition to break down user queries into multiple dimensions, including entities, indicators, attributes, and time. Corresponding intent recognition models are then used to extract these elements and generate SQL query statements. While this solution improves the system's responsiveness to complex and fuzzy queries to some extent, it is not specifically designed for SAP systems. SAP's permission system is extremely complex, setting permissions based on organizational structure, user roles, data objects, and other dimensions. This technology lacks adaptation to such a complex permission system, failing to ensure that users can accurately and securely access data according to their permissions within the SAP system environment. When handling sensitive data queries across company codes and business departments, it struggles to accurately match SAP permission rules, potentially leading to data leakage risks or errors due to insufficient query permissions.

[0006] Furthermore, while some intelligent data analysis products on the market currently support natural language conversational data analysis and can connect to multiple data sources, they still have the following technical shortcomings when targeting SAP systems: First, they lack the ability to analyze professional domain indicator systems. Traditional natural language to SQL technology has not pre-analyzed the complex indicator systems of the three major financial statements (balance sheet, income statement, and cash flow statement) and human resources, resulting in fundamental obstacles to semantic parsing. Second, the limitations of the technical approach lead to insufficient accuracy and reliability. Relying solely on the natural language to SQL technology approach lacks domain knowledge enhancement mechanisms, resulting in poor performance in complex business scenarios. The accuracy of existing models on multiple industry standard natural language to SQL benchmark tests is generally unsatisfactory. Third, there is a disconnect between business semantics and the underlying system logic. Existing technologies have not built industry-specific data dictionaries and prompt word systems, making it difficult to understand the precise meaning of enterprise-level business terms. Moreover, most existing solutions have not introduced retrieval enhancement and knowledge-enhancing agent technology and function call technology, failing to effectively utilize domain knowledge to improve the accuracy and efficiency of analysis.

[0007] Therefore, how to achieve accurate, stable, and secure intelligent data analysis for enterprise business data, taking into account the special data structure and business rules of SAP systems, has become a technical problem that urgently needs to be solved in this field. Summary of the Invention

[0008] This invention addresses the shortcomings of existing intelligent data query technologies in SAP Enterprise Resource Planning (ERP) systems, which are unable to adapt to SAP's unique data structure, complex permission system, and professional business logic. It provides an intelligent data query method and system that can accurately, stably, and securely analyze enterprise business data.

[0009] This invention provides an intelligent data query method for operational data based on the SAP system, comprising the following steps: Step S1: Extract raw data from the SAP Enterprise Resource Planning system using the Extract-Transform-Load (ETL) tool, and load it into the business indicator library after row and column transformation, data cleaning and data transformation. Step S2: Based on the frequently used SQL statements in the business scenario, configure several parameterized SQL framework templates, and vectorize the names and business descriptions of the SQL framework templates and store them in the tools vector library; Step S3: Establish personnel roles, configure domain access permissions for agents, and set fine-grained access permissions based on personnel roles for tools components in the tools vector library, forming a permission mapping relationship between personnel roles, tools, and data; Step S4: Based on the received user query requests expressed in natural language, retrieve one or more SQL framework templates with the highest semantic similarity from the tools vector library, use a large language model to fill parameters and perform logical validation on the retrieved SQL framework templates, generate an executable structured query statement, dynamically inject permission filtering conditions into the structured query statement according to the fine-grained access permissions, generate the final query statement and execute it in the business indicator library, and return the query results.

[0010] Furthermore, step S1 further includes: Relational row-based data in the SAP Enterprise Resource Planning system is restructured into column-based data through row-column reconstruction. Establish mapping rules between coding and business semantics to convert abstract code in the SAP Enterprise Resource Planning system into textual descriptions that can be directly displayed.

[0011] Furthermore, the parameter model of the SQL framework template should at least include the tool name, parameter name, and business description. The parameter name should include variable placeholders for dynamic population, and the variable placeholders should at least include time range, organizational dimension, and indicator type.

[0012] Furthermore, fine-grained access permissions based on user roles are set for the tools components in the tools vector library, specifically including: Assign a set of callable tools components to different personnel roles; Embed data range restriction rules in the execution layer of the tools component to control the range of data returned by the query results through dimension fields.

[0013] Furthermore, step S4 further includes: The user's query request is vectorized, and a similarity search is performed in the tools vector library to extract the preset table association logic and parameter format in the matching SQL framework template, thus transforming unstructured questions into semi-structured instructions. The large language model is invoked, and the retrieved SQL framework template and semi-structured instructions are combined to complete parameters and perform logical verification, generating a preliminary structured query statement. After generating the initial structured query statement but before execution, permission filtering conditions based on organization dimension are injected according to the role-based fine-grained access permissions, and the user's query permissions for the target data are verified in real time.

[0014] Furthermore, it also includes a dynamic adaptation step: when the SAP Enterprise Resource Planning system is upgraded or custom business indicators are changed, the indicator definitions in the business indicator library or the SQL framework templates in the tools vector library are updated without code through the visual tool management platform, and the updated content is automatically synchronized to the tools vector library.

[0015] Furthermore, user query requests expressed in natural language are processed by a semantic parsing engine before retrieval. Through regular expression matching and named entity recognition, the queries are parsed into a standardized query skeleton consisting of indicator type, time dimension, organizational dimension, and filtering conditions.

[0016] Furthermore, prior to step S1, there is a step of constructing a domain-specific knowledge graph, which includes: The indicator system layer includes the core indicators of the three major financial statements and human resources, their calculation formulas, data source tables, and SAP Enterprise Resource Planning system field mappings; The data model layer includes table relationships, field business meanings, and SQL dialect characteristics in the SAP Enterprise Resource Planning system's data dictionary; The rules engine layer includes predefined permission rules and business logic rules; The knowledge graph is used to provide a basis for verification in the logical verification in step S4.

[0017] Furthermore, an executable structured query statement is generated as an SQL statement. After generation and before execution, it is also validated by a built-in syntax validator to check whether the join conditions or grouping fields in the SQL statement are correct. If the validation passes, it is executed; otherwise, an error message is returned.

[0018] An intelligent data query system for SAP systems, comprising methods for intelligent data querying based on SAP systems, including: The data preprocessing module extracts raw data from the SAP Enterprise Resource Planning system using the Extract-Transform-Load (ETL) tool, and loads it into the business indicator library after row and column transformation, data cleaning, and data transformation. The tool predefined module is used to configure several parameterized SQL framework templates based on frequently used SQL statements in business scenarios, and to vectorize the names and business descriptions of the SQL framework templates and store them in the tool vector library. The permission pre-configuration module is used to establish personnel roles, configure domain access permissions for agents, and set fine-grained access permissions based on personnel roles for tool components in the tool vector library, forming a permission mapping relationship between personnel roles, tools, and data. The intelligent query execution module is used to retrieve one or more SQL framework templates with the highest semantic similarity from the tools vector library based on the received user query requests expressed in natural language. It then uses a large language model to fill in parameters and perform logical validation on the retrieved SQL framework templates, generating an executable structured query statement. Based on the fine-grained access permissions, it dynamically injects permission filtering conditions into the structured query statement, generates the final query statement, executes it in the business indicator library, and returns the query results.

[0019] Compared with existing technologies, this invention has the following advantages: By pre-configuring parameterized SQL framework templates and then filling in the parameters, it adapts to the unique data structure and business logic of the SAP system, avoiding syntax errors and table join errors that are prone to occur when directly generating SQL from large language models, thus ensuring the accuracy of query results; by setting a three-level fine-grained permission mapping of personnel roles, tools, and data, it adapts to the complex permission system of the SAP system, strictly controlling the data access scope of different roles, preventing unauthorized data access, and ensuring the security of data access; through predefined indicators and templates, it can support rapid configuration updates after SAP system changes, with strong adaptability and stable operation, efficiently meeting the rapid query needs of different roles in the enterprise for business data, eliminating the need for technical personnel to repeatedly write data retrieval SQL, and significantly improving the efficiency of business data analysis. Attached Figure Description

[0020] Figure 1 This is a schematic diagram illustrating the steps of the intelligent data query method for business data based on the SAP system according to the present invention.

[0021] Figure 2 This is a schematic diagram of the domain-specific knowledge graph structure constructed in this invention.

[0022] Figure 3 This is a schematic diagram of the intelligent data query system for business data based on the SAP system of the present invention. Detailed Implementation

[0023] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. This section describes the working principle and technical effects of the present invention by way of embodiments, but the scope of protection of the present invention is not limited to these embodiments.

[0024] This embodiment provides an intelligent data query system for business operations based on the SAP system, such as... Figure 3 As shown, the system includes a data preprocessing module, a tool predefinition module, a permission preconfiguration module, and an intelligent query execution module. Correspondingly, as... Figure 1 As shown, the intelligent data query method provided in this embodiment includes a preset stage and an execution stage: the preset stage includes three steps: data preprocessing, tool predefinition, and permission preconfiguration, which can be executed in parallel or in any order during system initialization; the execution stage is the intelligent data query execution step, which is performed after the preset stage is completed.

[0025] This embodiment addresses the problems of semantic parsing difficulties, low accuracy, and insufficient access control inherent in traditional Natural Language to Structured Query Language (NL2SQL) technology within the SAP Enterprise Resource Planning (ERP) system environment. It proposes a three-tier architecture solution: domain knowledge pre-construction, Retrieval Enhanced Generation (RAG) enhanced reasoning, and function call tooling. Its core working principle is as follows: First, through data preprocessing and tool predefinition, the complex business logic and SQL writing experience of the SAP system are transformed into reusable parameterized templates, which are then vectorized and stored. This design transforms the traditional model of generating SQL from scratch into an engineering-oriented model of retrieving templates and filling parameters, fundamentally reducing the uncertainty of directly generating SQL from large models.

[0026] Second, when a user initiates a query request, the system first performs semantic parsing on the natural language question, extracting key elements such as indicator type, time dimension, organizational dimension, and filtering conditions to form a standardized query skeleton. Then, through vector similarity retrieval, it quickly matches the closest SQL framework template from the tools vector library.

[0027] Third, the retrieved templates and query skeletons are input into the large language model, which only needs to complete parameter filling and partial logic verification, rather than generating the full SQL. This design effectively constrains the performance space of the large model and avoids the generation of erroneous SQL due to incorrect model inference.

[0028] Fourth, after the SQL is generated but before execution, the system dynamically injects permission filtering conditions based on the pre-configured three-tier permission mapping relationship of personnel roles, tools, and data, and calls SAP permission functions in real time for runtime verification to ensure that the query results meet the enterprise's data security compliance requirements.

[0029] Through the coordinated work of the above four stages, this embodiment realizes a closed-loop process of retrieval, filling, validation and injection from natural language to executable SQL, which significantly improves the accuracy, stability and security of SAP system intelligent query.

[0030] I. Pre-setting stage, including the following operational steps: (I) Data Preprocessing: This step aims to build a high-quality data foundation for intelligent data query scenarios, solving the problems of opaque underlying database and table structures and difficulties in direct data access in the SAP ERP system; specifically including: Raw data is extracted from the SAP ERP system using ETL tools. ETL tools connect to the SAP ERP system via SAP's standard Remote Function Call (RFC) interface or directly read the SAP HANA database via ODBC drivers, acquiring raw business data in batches according to preset extraction strategies (such as full extraction or incremental extraction). For core tables with hundreds of millions of records (such as the financial accounting table ACDOCA and the material document table MSEG), the system adopts a timestamp-based incremental extraction strategy: each table maintains a maximum timestamp field for the last extraction (such as "last modified time"), and each extraction only retrieves records added or modified after that timestamp. To ensure the atomicity and consistency of data reconstruction, the ETL tool introduces a lightweight transaction mechanism, specifically including: reading all incremental data within the same database transaction to ensure the read dataset is consistent at any given time; rolling back all transformation operations in the current batch and recording the breakpoint location if any errors occur during the transformation process; and adopting a strategy of "writing a temporary table first, verifying it, and then atomically exchanging it" to avoid incomplete or partially updated data in the business indicator database.

[0031] After extraction, the original data undergoes row and column transformation, data cleaning, and data conversion. The order of these three operations can be adjusted according to the characteristics of the data source and processing requirements. For example, data cleaning can be performed first to remove invalid data, followed by row and column transformation to reduce the amount of data to be converted. In this embodiment, row and column transformation is performed first to unify the data format, followed by data cleaning and data conversion.

[0032] (1) Row-column conversion: Data in SAP ERP systems usually adopts a relational row storage structure, with each record corresponding to a row of data. In the NL2SQL scenario, row storage increases the logical nesting complexity of query conditions. This step converts row-stored data into column-stored data through row-column structure reconstruction, so that each field can be directly used as a SELECT item or WHERE condition in subsequent queries without the need for multi-level nested subqueries. This increases the semantic direct matching of query fields and simplifies the logical hierarchy of query conditions. In specific implementation, column-stored engines supported by the business indicator library, such as ClickHouse or SAP HANA column tables, can be used.

[0033] (2) Data cleaning: There are problems such as null values ​​and semantic ambiguity in the original data. For example, the financial statements often contain fields with vague expressions such as "of which" and "total". If these expressions are kept directly, they may cause query logic errors. This step implements data completion and standardization repair, removes invalid data in the "of which" row field, and clearly maps the "total" field to specific indicators such as "cumulative operating income this year" to ensure the consistency and accuracy of the data.

[0034] (3) Data conversion: Data in SAP ERP systems is often stored in the form of codes, such as gender codes and department codes. These codes are not readable by end users. This step establishes a mapping rule between codes and business semantics, converting abstract codes into textual expressions that can be directly displayed. For example, gender codes are converted into "male" or "female", and department codes are converted into specific department names such as "Technology Research Institute" and "Finance Department", thereby improving the data understanding efficiency of end users.

[0035] After the above processing, the data is loaded into the business indicator database. As a data mart, the business indicator database allows for moderate data redundancy, weakens functional dependency rules, and is more in line with the high-frequency and flexible query needs in intelligent data query scenarios. Through this step, a transparent data transmission link is built from the underlying system to the analysis layer.

[0036] (ii) Tool predefinition: This step transforms the experience of business experts in writing SQL statements into reusable template assets, thereby improving the accuracy and efficiency of SQL generation in intelligent query scenarios.

[0037] First, it's important to clarify that the operational indicator database constructed in step S1 has a different table structure than the original SAP database. The operational indicator database uses columnar storage, semantic field names, and has undergone data cleaning and encoding conversion (e.g., converting "Geschlecht" to "Gender"). Therefore, all SQL framework templates configured in this step are directly written for the table structure and field semantics of the operational indicator database, not for the original SAP tables. For example, in the operational indicator database, the fields in the financial voucher table are "Company Code," "Profit Center," and "Amount_Fixed Currency." The templates directly use these field names, without needing to use, and cannot use, the original SAP field names such as "BUKRS," "PRCTR," and "HSL." This ensures that the SQL statements generated in step S4 can be executed directly in the operational indicator database without any rewriting.

[0038] Specifically, based on frequently used SQL statements in business scenarios, several parameterized SQL framework templates are configured. Each template contains dynamically populated variable placeholders, whose types include at least time range, organizational dimension, and indicator type. The parameter model of each template includes at least the tool name, parameter name, and business description. For example, for the scenario of "querying monthly sales revenue by company code", the template directly references the "sales revenue fact table", "company code dimension table", and "time dimension table" from the business indicator library, and pre-defines the relationship logic between these tables. After retrieving the template, the intelligent query system populates the data according to the parameter values ​​parsed from the user request to generate a complete SQL statement.

[0039] Then, the name and business description of each SQL framework template are vectorized and encoded. In this embodiment, the embedding model uses bge-large-zh-v1.5. The input text is a string concatenated with the tool name and business description. Specifically, for example, if the tool name is "Revenue Query Template" and the business description is "used to retrieve the operating revenue data of each business unit within a certain time period," then the concatenated string would be: Tool Name: Revenue Query Template; Business Description: Used to retrieve the operating revenue data of each business unit within a certain time period. This string is directly used as the input to the embedding model without any additional processing. The system performs word segmentation or preprocessing, outputting a 1024-dimensional floating-point vector. The output vector undergoes L2 normalization before storage to facilitate subsequent retrieval using cosine similarity. The vectorized data is stored in a tools vector library implemented using the Faiss library, with IndexFlatIP (inner product index) as the index type. Cosine similarity calculation is supported. During retrieval, the vector of the user's question is multiplied by the inner product of all template vectors in the library, sorted by similarity from highest to lowest, and the Top-K results are returned. The default K value is 3, which can be adjusted based on the actual recall rate.

[0040] Through this step, the SQL generation mode of intelligent querying is transformed from full generation based on raw semantics to an engineered mode that combines template retrieval with parameter filling, which greatly reduces the generation complexity and dependence on model reasoning ability.

[0041] (iii) Permission pre-configuration: This step is to build a multi-level permission control system to ensure data access security in intelligent data query scenarios.

[0042] First, establish personnel roles. Based on the organizational structure and business functions, classify role types according to departmental attributes and permission levels, such as ordinary employees, department heads, and financial specialists. Each role corresponds to a set of functional permissions. For example, the financial role can access the cash flow query function, while ordinary employees only have basic data viewing permissions.

[0043] Next, configure domain access permissions for the agent. The agent is a proxy module responsible for handling query requests in a specific business domain. In this step, create dedicated agents according to business segments (such as the financial intelligent query agent and the human resources data analysis agent) and restrict them to responding to query requests in specific domains. At the same time, control the access permissions of the agent through role matching. Only users with the role of financial specialist can call the financial intelligent query agent, and unauthorized roles cannot trigger this function.

[0044] Next, fine-grained access permissions based on user roles are set for each tool component in the tools vector library. Different user roles are assigned a set of tools components that can be invoked. For example, department heads can use tools with aggregation calculation logic, while ordinary employees can only invoke basic query tools. Data range restriction rules are embedded in the execution layer of the tools components. The range of data returned by the query results is controlled by dimension fields (such as company code, factory, department), such as limiting the visibility of data to the department itself.

[0045] Through the above configuration, a permission mapping relationship between personnel roles, tools, and data is formed. This mapping relationship can be stored in a permission table in a relational database. This table contains the following fields: role ID, tool ID, and allowed data dimension conditions. When the system receives a user request, it queries the permission table based on the user's role ID to obtain the list of tools that the role can call and the corresponding data range conditions, and dynamically generates permission filtering clauses. This achieves a security protection network that is vertically layered by role and horizontally divided by business domain.

[0046] The second stage, the execution stage, is the core execution process. It receives user query requests expressed in natural language and returns the query results.

[0047] (a) Request reception and parsing: The system receives user requests in natural language, such as "What was the operating profit of each department in North China in the first quarter of 2024?".

[0048] Before the retrieval, the request is processed by the semantic parsing engine. The semantic parsing engine uses regular expression matching and named entity recognition technology to parse the user request into a standardized query skeleton consisting of indicator type, time dimension, organizational dimension and filtering conditions. If there is a vague expression in the user request (such as "last month"), the engine automatically converts it to the previous natural month of the current month.

[0049] (ii) Vector retrieval and template matching: The user's query request is vectorized (or its key elements are vectorized after parsing). The same embedding model as the tool's predefined steps is used to convert it into a query vector. Then, similarity retrieval is performed in the tool's vector library. The cosine similarity between the query vector and each template vector is calculated. When multiple templates with similarity exceeding a preset threshold are retrieved, for example, the preset threshold can be set to 0.8, meaning that a match is considered successful only when the similarity is greater than 0.8. This threshold can be adjusted according to the actual application scenario: it can be set to 0.9 in high-accuracy scenarios such as financial analysis, and to 0.7 in high-recall scenarios such as exploratory analysis. The system prioritizes the template with the highest similarity. If the highest similarity is lower than the threshold, the top few templates are taken and given to the large language model for comprehensive judgment or the user is asked to further clarify. For example, in the financial analysis scenario, the threshold can be set higher to pursue high accuracy; in the exploratory analysis scenario, the threshold can be set lower to expand the recall range. The retrieved templates contain preset table association logic and parameter formats.

[0050] (III) Parameter filling and logical verification: The retrieved SQL framework template and semi-structured instructions (i.e., standardized query skeleton) are input into the large language model. In this embodiment, the large language model adopts the DeepSeek-V3 model and runs through local deployment. When calling, the temperature parameter is set to a low value (the value range is 0 to 1. The lower the value, the lower the randomness of the generated result and the higher the determinism. In this embodiment, the temperature parameter is set to 0.1) to ensure that the generated result has low randomness and improves the determinism of the SQL statement. The large language model fills the variable placeholders in the template with parameters. For example, the time range placeholder is filled with a specific date, and the organization dimension placeholder is filled with the corresponding SAP organization code. The large language model performs logical verification on the filled statement.

[0051] The logical verification rules include: (1) If the SQL statement contains the JOIN keyword, check whether there is a corresponding ON clause, and the fields involved in the ON clause must exist in the two tables involved in the connection; (2) If the SELECT clause contains aggregate functions, check whether all non-aggregate fields appear in the GROUP BY clause; (3) Check whether there are common logical errors such as filtering null values ​​of primary key fields in the WHERE clause.

[0052] During parameter filling and logical validation, a pre-built domain-specific knowledge graph can be used as the validation basis. The knowledge graph records the calculation formula for a certain indicator. If the generated SQL statement omits necessary table joins, the system will prompt for their supplementation. Logical validation includes dependency validation based on the knowledge graph: the abstract syntax tree of the generated SQL statement is compared with the data model layer in the knowledge graph. If the table join relationships used in the syntax tree fail to cover the necessary paths defined in the graph for extracting the target indicator, it is considered an omission. In this case, the system can automatically generate supplementary JOIN clauses or issue prompts containing correction suggestions to the user based on the predefined missing paths in the graph. When validation finds omissions or errors, the system returns a validation failure message to the large language model, which then regenerates the corrected SQL statement.

[0053] After the above processing, a preliminary SQL query statement is generated.

[0054] (iv) Permission filtering condition injection: Dynamic injection of permission filtering conditions is divided into two stages: The first stage is before SQL generation, the range of accessible data is pre-determined according to user roles, and the dimension conditions are given as parameters to the large model; The second stage is after SQL generation and before execution, static analysis is performed on the final SQL statement to confirm that its WHERE clause contains the necessary permission filtering conditions, and SAP permission functions are called for runtime verification.

[0055] Based on role-based fine-grained access permissions, the system injects organization-level permission filtering conditions into the SQL statement. For example, if the currently logged-in user's role only allows access to data with a specific company code, the intelligent query system automatically appends the corresponding company code filtering condition to the WHERE clause of the SQL statement. If the user's query data involves sensitive fields, the system calls SAP permission functions to verify in real time whether the user's role has the query permission for that field. After generating the initial structured query statement but before execution, organization-level permission filtering conditions are injected based on role-based fine-grained access permissions. According to the preset permission mapping relationship, permission filtering conditions corresponding to the user's role are generated. Runtime verification is performed using standard permission verification interfaces provided by the SAP system (such as the AUTHORITY_CHECK function or an equivalent custom permission verification function) to ensure that the user can only access data within their authorized scope. If permission verification fails, the system first parses the abstract syntax tree of the current SQL statement, extracts the specific data object that triggered the verification failure (such as company code, factory, cost center, account number, etc.), and records the object name and the corresponding permission deficiency reason in the log. The system then sends a clear access denied message to the user, informing them which data objects their current role does not have permission to access, for example: "You do not have permission to access the data for company code '1000'. Please contact the administrator to request permission." The system does not attempt to automatically correct or bypass permission restrictions to ensure data security.

[0056] (v) Syntax validation and execution: After injecting the permission filtering conditions, the final SQL statement is generated. This SQL statement needs to be validated by the built-in syntax validator. The syntax validator checks whether the join conditions in the SQL statement are missing, whether the grouping fields are correct, and whether there are any syntax errors. If the validation passes, the SQL statement is executed in the business indicator database. If the validation fails, an error message is returned, along with the error location and reason. The intelligent data system requests user confirmation before regenerating the statement.

[0057] (vi) Results return: After executing the query, the intelligent query system will return the query results to the user in structured or natural language form.

[0058] III. Preferred Implementation Methods Based on the above basic implementation method, this embodiment also provides a variety of preferred or alternative technical solutions.

[0059] (I) Regarding the preferred data preprocessing scheme, the preferred implementation of data preprocessing is row-to-column transformation, which specifically transforms the relational row-based data in the SAP ERP system into column-based data through row-to-column structure reconstruction. For example, in a financial voucher table, each row in the original row-based storage represents a voucher line item, containing fields such as voucher number, account, and amount. After conversion to column-based storage, the amount field is treated as a separate column, and an index relationship is established with the voucher number. This allows for direct aggregation of the amount column when querying the total amount of a certain account, without the need for row-by-row scanning.

[0060] Data cleaning should ideally include: removing invalid data from the "of which" row; explicitly mapping the "total" field to a specific indicator; and filling in null values ​​(e.g., by filling with zero or the average value).

[0061] The preferred data conversion method includes: establishing a mapping table between codes and business semantics; when loading into the business indicator database, storing the codes and corresponding text descriptions simultaneously for selection and display during subsequent queries.

[0062] (ii) Regarding the preferred solution for tool templates, as the preferred implementation of the SQL framework template parameter model, the parameter model of each template includes the tool name, parameter name and business description. The parameter name includes variable placeholders for dynamic filling. The placeholder types include time range, organizational dimension and indicator type.

[0063] The template also predefines table relationship logic. For example, for the "Operating Profit" query, the template predefines the connection conditions between the profit and loss statement table and the cost control scope table of the related financial module.

[0064] (III) Regarding the preferred scheme for permission configuration, as the preferred implementation of fine-grained access permissions, the fine-grained access permissions for tool components based on personnel roles include: (1) Assigning a set of tools components that can be called to different personnel roles. For example, the system administrator role can call all tools components, the financial analysis role can call the financial statement analysis tool, the account balance query tool, etc., the department manager role can call the department cost analysis tool, the department attendance statistics tool, and ordinary employees can only call the personal attendance query tool and the personal expense query tool; (2) Embedding data range restriction rules in the execution layer of the tool components. For example, for the department cost analysis tool, the system automatically adds department filtering conditions to the generated query statement when the tool is executed, based on the department code associated with the role of the currently logged-in user, to ensure that only data of this department is returned. The dimension fields can be company code, factory, department, cost center, profit center, etc.

[0065] (iv) Regarding the preferred scheme for knowledge graphs, before the data preprocessing step, a step of constructing a domain-specific knowledge graph may also be included, such as... Figure 2 As shown, this knowledge graph consists of three layers: Indicator System Layer: Organize the core indicators of the three major financial statements (balance sheet, income statement, and cash flow statement), clarify the calculation formula, data source table, and SAP system field mapping for each indicator, and define the organizational structure hierarchy, personnel status, and attendance rules in the human resources field to form a standardized business semantic library.

[0066] Data Model Layer: Parses the SAP data dictionary and builds a metadata knowledge base that includes table relationships, field business meanings, and SQL dialect characteristics, resolving the semantic gap problem caused by obscure table names in the SAP system.

[0067] Rule engine layer: Predefined permission rules and business logic rules form a dynamically updatable rule set.

[0068] Knowledge graphs can be stored and queried using graph databases. Indicator nodes in the indicator system layer are connected to table nodes and field nodes in the data model layer through relational edges. Rule nodes in the rule engine layer are connected to table nodes or field nodes through constraint relationships. During logical verification, the generated SQL statement is parsed into an abstract syntax tree. The table names and field names in the tree are traversed, and the graph is queried to see if there are corresponding nodes and correct associations. If not, the verification is marked as failed.

[0069] (v) Regarding the preferred solution for dynamic adaptation, when the SAP ERP system is upgraded or the enterprise's custom business indicators are changed, the administrator can update the indicator definitions in the business indicator library or the SQL framework templates in the tools vector library through the visual management platform without writing code. The system will automatically synchronize the updated content to the vector retrieval library and template library to ensure that the intelligent data query function is continuously available without downtime maintenance.

[0070] IV. Specific Application Example The technical solution of the present invention will be described below with reference to a specific application example.

[0071] Scenario: A large manufacturing company uses the SAP ERP system to manage financial and human resources data. Financial management personnel want to query the "net profit margin of each subsidiary in North China for the first quarter of 2024." The processing flow is as follows: Users can enter a natural language request through the intelligent question interface: "What was the net profit margin of each subsidiary in North China in the first quarter of 2024?" The semantic parsing engine resolves the request as follows: Metric type: "Net profit margin", Time dimension: "First quarter of 2024", Organization dimension: "Subsidiaries in North China".

[0072] The parsing results are vectorized, and similar templates are searched in the tools vector library. The "profit margin calculation tool" is matched. This template predefines the table association logic: associates the profit and loss statement account table and the cost control scope table, as well as the calculation formula: net profit divided by operating revenue and then multiplied by 100%.

[0073] The large language model populates the template with parameters: the time range is filled with the corresponding specific date intervals, the organizational dimension is filled with the list of subsidiary codes corresponding to the North China region, and a preliminary SQL statement is generated.

[0074] Permission verification: The current user role is a financial manager. The system automatically injects permission filtering conditions to limit the query results to include only the data of subsidiaries that the financial manager has permission to access. At the same time, it verifies in real time whether the user has permission to access the profit and loss statement items. If the verification is successful, the syntax validator checks the SQL statement to confirm that the join conditions and grouping fields are correct (grouped by subsidiary code). The verification is successful.

[0075] Execute the query and return the results: the net profit margin of each subsidiary is displayed in a table.

[0076] As can be seen from the above specific application examples, the present invention can accurately understand the user's natural language request, automatically complete steps such as semantic parsing, template matching, parameter filling, permission injection, and syntax verification, and finally return accurate query results, significantly improving the practicality and stability of intelligent querying in enterprise-level SAP systems.

[0077] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims and their equivalents, this invention is also intended to include these modifications and variations.

Claims

1. A method for intelligent data querying based on SAP system operating data, characterized in that: Includes the following steps: Step S1: Extract raw data from the SAP Enterprise Resource Planning system using the Extract-Transform-Load (ETL) tool, and load it into the business indicator library after row and column transformation, data cleaning and data transformation. Step S2: Based on the frequently used SQL statements in the business scenario, configure several parameterized SQL framework templates, and vectorize the names and business descriptions of the SQL framework templates and store them in the tools vector library; Step S3: Establish personnel roles, configure domain access permissions for agents, and set fine-grained access permissions based on personnel roles for tools components in the tools vector library, forming a permission mapping relationship between personnel roles, tools, and data; Step S4: Based on the received user query requests expressed in natural language, retrieve one or more SQL framework templates with the highest semantic similarity from the tools vector library, use a large language model to fill parameters and perform logical validation on the retrieved SQL framework templates, generate an executable structured query statement, dynamically inject permission filtering conditions into the structured query statement according to the fine-grained access permissions, generate the final query statement and execute it in the business indicator library, and return the query results.

2. The intelligent data query method for operational data based on the SAP system according to claim 1, characterized in that, Step S1 further includes: Relational row-based data in the SAP Enterprise Resource Planning system is restructured into column-based data through row-column reconstruction. Establish mapping rules between coding and business semantics to convert abstract code in the SAP Enterprise Resource Planning system into textual descriptions that can be directly displayed.

3. The intelligent data query method for operational data based on the SAP system according to claim 1, characterized in that, The parameter model of the SQL framework template should include at least the tool name, parameter name, and business description. The parameter name should include variable placeholders for dynamic population. The variable placeholders should include at least the time range, organizational dimension, and indicator type.

4. The intelligent data query method for operational data based on the SAP system according to claim 1, characterized in that, Set fine-grained access permissions for tools components in the tools vector library based on user roles, specifically including: Assign a set of callable tools components to different personnel roles; Embed data range restriction rules in the execution layer of the tools component to control the range of data returned by the query results through dimension fields.

5. The intelligent data query method for operational data based on the SAP system according to claim 1, characterized in that, Step S4 further includes: The user's query request is vectorized, and a similarity search is performed in the tools vector library to extract the preset table association logic and parameter format in the matching SQL framework template, thus transforming unstructured questions into semi-structured instructions. The large language model is invoked, and the retrieved SQL framework template and semi-structured instructions are combined to complete parameters and perform logical verification, generating a preliminary structured query statement. After generating the initial structured query statement but before execution, permission filtering conditions based on organization dimension are injected according to the role-based fine-grained access permissions, and the user's query permissions for the target data are verified in real time.

6. The intelligent data query method for operational data based on the SAP system according to claim 1, characterized in that, It also includes a dynamic adaptation step: when the SAP Enterprise Resource Planning system is upgraded or custom business indicators are changed, the indicator definitions in the business indicator library or the SQL framework templates in the tools vector library are updated without code through the visual tool management platform, and the updated content is automatically synchronized to the tools vector library.

7. The intelligent data query method for operational data based on the SAP system according to claim 1, characterized in that, Before retrieval, user queries expressed in natural language are processed by a semantic parsing engine. Through regular expression matching and named entity recognition, the queries are parsed into a standardized query skeleton consisting of indicator type, time dimension, organizational dimension, and filtering conditions.

8. The intelligent data query method for operational data based on the SAP system according to claim 1, characterized in that, Before step S1, there is also a step of constructing a domain-specific knowledge graph, which includes: The indicator system layer includes the core indicators of the three major financial statements and human resources, their calculation formulas, data source tables, and SAP Enterprise Resource Planning system field mappings; The data model layer includes table relationships, field business meanings, and SQL dialect characteristics in the SAP Enterprise Resource Planning system's data dictionary; The rules engine layer includes predefined permission rules and business logic rules; The knowledge graph is used to provide a basis for verification in the logical verification in step S4.

9. The intelligent data query method for operational data based on the SAP system according to claim 1, characterized in that, The generated executable structured query statement is an SQL statement. After generation and before execution, it is also validated by the built-in syntax validator to check whether the join conditions or grouping fields in the SQL statement are correct. If the validation passes, it is executed; otherwise, an error message is returned.

10. An intelligent data query system for business operations based on the SAP system, characterized in that: The method for intelligent data querying based on SAP system as described in any one of claims 1 to 9 includes: The data preprocessing module extracts raw data from the SAP Enterprise Resource Planning system using the Extract-Transform-Load (ETL) tool, and loads it into the business indicator library after row and column transformation, data cleaning, and data transformation. The tools predefined module is used to configure several parameterized SQL framework templates based on frequently used SQL statements in business scenarios, and to vectorize the names and business descriptions of the SQL framework templates and store them in the tools vector library. The permission pre-configuration module is used to establish personnel roles, configure domain access permissions for agents, and set fine-grained access permissions based on personnel roles for tool components in the tool vector library, forming a permission mapping relationship between personnel roles, tools, and data. The intelligent query execution module is used to retrieve one or more SQL framework templates with the highest semantic similarity from the tools vector library based on the received user query requests expressed in natural language. It then uses a large language model to fill in parameters and perform logical validation on the retrieved SQL framework templates, generating an executable structured query statement. Based on the fine-grained access permissions, it dynamically injects permission filtering conditions into the structured query statement, generates the final query statement, executes it in the business indicator library, and returns the query results.

Citation Information

Patent Citations

  • Large language model data analysis method and device, computer equipment and storage medium

    CN119396859A

  • Enterprise intelligent number asking implementation method and device and storage medium

    CN119884166A