SAP MM reservation list change history recording method and system
By customizing the history table in the SAP system and recording the change data of reserved documents, the problem of lack of reserved document change history in the SAP system is solved, and detailed traceability and efficient query of reserved document changes are realized, which improves the transparency and traceability of material management.
Patent Information
- Application Number
- CN202411751123.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-04-25
AI Technical Summary
The SAP system lacks logging and query functions in the addition, modification and deletion of reserved documents, which makes it impossible for users to effectively trace and query the change history of reserved documents.
By customizing the history table in the SAP system, using transaction code to maintain the reserved order information, and triggering the operation of obtaining the change data, the change data is logged and updated the history table, and a query interface is provided for users to filter and view history.
It realizes a detailed historical record of operations such as adding, modifying, and deleting reserved documents, improves the transparency and traceability of material management, and improves query efficiency and targeting.
Smart Images

Figure CN119884194A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of material management reserved document change history recording technology, and in particular to a SAP MM reserved document change history recording method. Background Art
[0002] SAP, short for "System Applications and Products", is the software name of SAP's product - enterprise management solution. As a very important module in SAP supply chain management, the MM module is mainly responsible for functions related to material management, supporting procurement, inventory management, MRP, supplier evaluation, etc. involved in daily business. A reservation is a request made to the warehouse, requiring the warehouse to keep the material ready for delivery on a certain date in the future and for a certain purpose. Material Requirement Planning (MRP) refers to the planning of each item as the planning object based on the subordinate and quantity relationship of items at each level of the product structure, with the completion period as the time basis, and the order of the planned time of each item is distinguished according to the length of the lead time. It is a material planning management model within an industrial manufacturing enterprise.
[0003] The purpose of a reservation document is to ensure that materials are available when they are needed. It can be used to simplify and speed up the delivery process and make advance preparations. At the same time, reservation documents will be considered by material requirements planning (MRP) to facilitate timely acquisition of required materials when they are shipped out of the warehouse. The reservation document consists of a header and details. The header contains the creator, movement type, and account assignment; the details include material, quantity, plant, inventory location, batch, goods movement indicator, last posting indicator, deletion indicator, demand date, etc. Reservation document creation is divided into automatic reservation and manual creation. Automatic reservation is triggered by related requirements such as planned independent requirements, production orders, WBS elements, etc. Users cannot directly modify the system's automatic creation of reservations. They must modify the transaction object document that triggers the reservation to indirectly modify the reservation.
[0004] However, the SAP system does not provide log recording and query functions for the addition, modification and deletion of reservations. For example, if the material requirement quantity in a reservation line item is changed from 10PC to 9PC, the corresponding change history cannot be found in the many menus in transaction code MB23.
[0005] According to the query of SAP official NOTE: 1927840, there is no log for updating the reserved change MB22 in the SAP standard function design. The old and new line item data information in the table RESB can be obtained through the Function module EXIT_SAPMM07R_001 in the user exit Enhancement MBCF0007, which is convenient for users to customize table records and queries. The SAP standard order change log tables are CDHDR and CDPOS. If these two tables are used as log records, the query performance and experience will be relatively poor due to the large amount of data in these two tables. Among them, Function module EXIT_SAPMM07R_001 contains the data structure of newly added and modified reserved line items (TI_RESB_NEW), the data structure of reserved line items before change (TI_RESB_OLD), and the data structure of new reserved line items (TI_RESB_ADDED). Summary of the invention
[0006] Purpose of the invention: The purpose of the present invention is to provide a method for recording the history of changes to SAP MM reserved documents. Without affecting the standard functions, when a user operates transaction code MB22 to modify a reserved document, it automatically triggers the recording of detailed user operation histories such as adding, modifying, and deleting reserved documents, and provides a convenient query interface to facilitate flexible screening and viewing of historical records, thereby improving the transparency and traceability of material management.
[0007] Technical solution: A method for changing the history of a SAP MM reservation order includes the following steps:
[0008] Customize history tables in SAP system;
[0009] Use the transaction code of the SAP system to maintain the reservation order information, and add, modify and delete the reservation order;
[0010] Trigger the operation of obtaining changed data and log the changed data;
[0011] Update history records in custom history tables;
[0012] Query the reservation order change history.
[0013] Furthermore, the customized history table is a customized ZCDHDR&ZCDPOS table with reference to the standard order log table CDHDR&CDPOS.
[0014] Furthermore, the ZCDHDR&ZCDPOS table changes the document object to the default "RESERVATION", changes the document object value to equal the reserved document number, changes the document number to a custom serial number, the user name is the operating user account, the change date is the current system date, the change time is the current system time, the transaction code is the function code corresponding to the user operation business, the table name is the storage table corresponding to the modified field value, the changed table record code is the reserved order number plus the four-digit serial code, the field name is changed to the modified field, the new value of the changed field is the value after the change, and the old value of the changed field is the value before the change.
[0015] Furthermore, when the user changes a reserved document, it is first necessary to determine whether the transaction code is the set default value; if so, determine whether the data structure of the new reserved line item is empty. If not, record the movement type and the reserved document code value; if the movement type is empty and the data structure of the newly added and modified reserved line items is not empty, record the movement type and the reserved document code value; when the table structure TI_RESB_ADDED or TI_RESB_NEW is not empty, record the change voucher header data value, including the reserved code, system operation user, operation transaction code, operation date, and operation time.
[0016] Furthermore, when the user inserts data and the table structure TI_RESB_ADDED is not empty, the voucher item data value is recorded.
[0017] Furthermore, when the user hits the delete mark and the table structure TI_RESB_NEW is not empty, the voucher item data value is recorded.
[0018] Furthermore, the transaction code defaults to MB22.
[0019] A SAP MM reservation order change history recording system includes a custom history table module, a change data module, a log recording module, an update history recording module and a query module;
[0020] The custom history table module customizes the history table in the SAP system;
[0021] The data change module uses the transaction code of the SAP system to maintain the reservation order information and add, modify and delete the reservation order;
[0022] The log recording module triggers the operation of obtaining the changed data and logs the changed data;
[0023] The update history record module updates the history records in the custom history record table;
[0024] The query module queries the reservation order change history record.
[0025] An electronic device comprises a processor and a memory; the memory is used to store a computer program, and the computer program is run by the processor to execute a method for recording a history of changes to a SAP MM reservation order.
[0026] A computer storage medium stores a computer program, which is run by a processor to execute a SAP MM reservation order change history recording method.
[0027] Beneficial effects: By adopting SAP standard enhancements (such as BAdI, User Exits, and Enhancements), we avoid directly modifying the core code and ensure the stability and security of the system. Self-built tables store change history information, which not only reduces data redundancy, but also greatly improves the pertinence and efficiency of queries, allowing users to quickly obtain the required information when they need to trace the change history of reserved documents. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 is a flow chart of the method of the present invention;
[0029] Figure 2 This is the SAP ABAP data dictionary architecture diagram;
[0030] Figure 3 The flowchart of updating and maintaining data by using the SAP ABAP data dictionary in an embodiment of the present invention. DETAILED DESCRIPTION
[0031] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.
[0032] like Figure 1 As shown, the present invention provides a technical solution:
[0033] A method for changing a SAP MM reservation order history record includes the following steps:
[0034] Customize history tables in SAP system;
[0035] Use the transaction code of the SAP system to maintain the reservation order information, and add, modify and delete the reservation order;
[0036] Trigger the operation of obtaining changed data and log the changed data;
[0037] Update history records in custom history tables;
[0038] Query the reservation order change history.
[0039] Preferably, the custom change history record table is specifically:
[0040] Customize ZCDHDR&ZCDPOS table with reference to standard order log table CDHDR&CDPOS, the client (MANDANT) defaults to "800", the document object (OBJECTCLAS) defaults to "RESERVATION", the document object value (OBJECTID) is changed to the reserved document number, the document number (CHANGENR) is changed to the custom serial number, the user name (USERNAME) is the operating user account (SY-UNAME), the change date (UDATE) is the current system date, and the change time (UTIME) is At the current time of the system, the transaction code (TCODE) is the function code corresponding to the user's operation business, the default is "MB22", the table name (TABNAME) is the storage table corresponding to the modified field value, the changed table record code (TABKEY) is the reserved order number plus the four-digit serial code, the modified field name (FNAME) is the modified field, the modification type (CHNGIND) value is (U-update, I-insert, E-delete single field document, D-delete identifier), the new value of the changed field (VALUE_NEW) is the value after the change, and the old value of the changed field (VALUE_OLD) is the value before the change. The self-built table is as follows:
[0041]
[0042]
[0043] Preferably, the operations of adding, modifying and deleting are specifically:
[0044] When the user changes the reserved document, first determine whether the transaction code (SY-TCODE) is "MB22". If so, determine whether the new reserved line item data structure (TI_RESB_ADDED) is empty. If not, record the movement type (BWART) and the reserved document code (RSNUM) values; if the movement type (BWART) is empty and the new and modified reserved line item data structure (TI_RESB_NEW) is not empty, record the movement type (BWART) and the reserved document code (RSNUM) values. When the table structure TI_RESB_ADDED or TI_RESB_NEW is not empty, record the change document header data value, including the reserved code (RSNUM), system operation user (SY-UNAME), operation transaction code (SY-TCODE), operation date (SY-DATUM), operation time (SY-UZEIT), etc.
[0045] When the user inserts data, if the table structure TI_RESB_ADDED is not empty, the voucher item data value is recorded, including the change table (TABNAME) is "RESB". If the material code TI_RESB_ADDED-MATNR is not empty, the change field (FNAME) is "MATNR". At this time, the new value (VALUE_NEW) of the change field is recorded as TI_RESB_ADDED-MATNR, and the modification type (CHNGIND) is "I". If the required quantity TI_RESB_ADDED-ERFMG is not empty, the change field (FNAME) is "ERFMG". At this time, the new value (VALUE_NEW) of the change field is recorded as TI_RESB_ADDED-MATNR. UE_NEW) is TI_RESB_ADDED-FNAME, and the modification type (CHNGIND) is "I"; if the factory TI_RESB_ADDED-WERKS is not empty, the change field (FNAME) is "WERKS". At this time, the new value (VALUE_NEW) of the change field is recorded as TI_RESB_ADDED-WERKS, and the modification type (CHNGIND) is "I"; if the inventory location TI_RESB_ADDED-LGORT is not empty, the change field (FNAME) is "LGORT". At this time, the new value (VALUE_NEW) of the change field is recorded as TI_RESB_ADDED ED-LGORT, the modification type (CHNGIND) is "I"; if the batch code TI_RESB_ADDED-CHARG is not empty, the change field (FNAME) is "CHARG". At this time, the new value (VALUE_NEW) of the record change field is TI_RESB_ADDED-CHARG, and the modification type (CHNGIND) is "I"; if the goods movement indicator TI_RESB_ADDED-XWAOK is not empty, the change field (FNAME) is "XWAOK". At this time, the new value (VALUE_NEW) of the record change field is TI_RESB_ADDED-XWAOK, and the modification type (CHNGIND) is "I"; if the last posting indicator TI_RESB_ADDED-KZEAR is not empty, the change field (FNAME) is "KZEAR". At this time, the new value (VALUE_NEW) of the record change field is TI_RESB_ADDED-KZEAR, and the modification type (CHNGIND) is "I"; if the deletion indicator TI_RESB_ADDED-XLOEK is not empty, the change field (FNAME) is "XLOEK". At this time, the new value (VALUE_NEW) of the record change field is TI_RESB_ADDED-XLOEK, and the modification type (CHNGIND) is "I".
[0046] When the user clicks the delete mark and the table structure TI_RESB_NEW is not empty, the voucher item data value is recorded, including the change table (TABNAME) is "RESB". If TI_RESB_NEW-XLOEK is "X", when the old table structure material code TI_RESB_OLD-MATNR is not equal to the new table structure material code TI_RESB_ADDED-MATNR, the change field (FNAME) is "MATNR". At this time, the old value of the change field (VALUE_OLD) is recorded as TI_RESB_OLD-MATNR, and the new value of the change field (VALUE_NEW) is recorded as TI_RESB_ADDED-MATN. R, the modification type (CHNGIND) is "D"; when the old table structure demand quantity TI_RESB_OLD-ERFMG is not equal to the new table structure demand quantity TI_RESB_ADDED-ERFMG, the change field (FNAME) is "ERFMG", at this time, the old value (VALUE_OLD) of the record change field is TI_RESB_OLD-ERFMG, the new value (VALUE_NEW) of the record change field is TI_RESB_ADDED-ERFMG, and the modification type (CHNGIND) is "D"; when the old table structure factory TI_RESB_OLD-WERKS is not equal to the new table structure factory TI_RESB_ADDED-ERFMG. DED-WERKS, the change field (FNAME) is "WERKS", at this time, the old value (VALUE_OLD) of the record change field is TI_RESB_OLD-WERKS, the new value (VALUE_NEW) of the record change field is TI_RESB_ADDED-WERKS, and the modification type (CHNGIND) is "D"; when the old table structure inventory location TI_RESB_OLD-LGORT is not equal to the new table structure inventory location TI_RESB_ADDED-LGORT, the change field (FNAME) is "LGORT", at this time, the old value (VALUE_OLD) of the record change field is TI_RESB_OLD D-LGORT, the new value (VALUE_NEW) of the record change field is TI_RESB_ADDED-LGORT, and the modification type (CHNGIND) is "D"; when the old table structure batch TI_RESB_OLD-CHARG is not equal to the new table structure batch TI_RESB_ADDED-CHARG, the change field (FNAME) is "CHARG", at this time the old value (VALUE_OLD) of the record change field is TI_RESB_OLD-CHARG, the new value (VALUE_NEW) of the record change field is TI_RESB_ADDED-CHARG, and the modification type (CHNGIND) is "D";When the goods movement indicator TI_RESB_OLD-XWAOK of the old table structure is not equal to the goods movement indicator TI_RESB_ADDED-XWAOK of the new table structure, the change field (FNAME) is "XWAOK". At this time, the old value (VALUE_OLD) of the record change field is TI_RESB_OLD-XWAOK, the new value (VALUE_NEW) of the record change field is TI_RESB_ADDED-XWAOK, and the modification type (CHNGIND) is "D"; when the final delivery indicator TI_RESB_OLD-KZEAR of the old table structure is not equal to the final delivery indicator TI_RESB_ADDED-KZEAR of the new table structure, the change field (FNAME) is "KZEAR". At this time, the record change word The old value of the segment (VALUE_OLD) is TI_RESB_OLD-KZEAR, the new value of the record change field (VALUE_NEW) is TI_RESB_ADDED-KZEAR, and the modification type (CHNGIND) is "D"; when the old table structure deletion identifier TI_RESB_OLD-XLOEK is not equal to the new table structure deletion identifier TI_RESB_ADDED-XLOEK, the change field (FNAME) is "XLOEK". At this time, the old value of the record change field (VALUE_OLD) is TI_RESB_OLD-XLOEK, the new value of the record change field (VALUE_NEW) is TI_RESB_ADDED-XLOEK, and the modification type (CHNGIND) is "D". If TI_RESB_NEW-XLOEK is "empty", when the old table structure material code TI_RESB_OLD-MATNR is not equal to the new table structure material code TI_RESB_ADDED-MATNR, the change field (FNAME) is "MATNR", at this time, the old value of the record change field (VALUE_OLD) is TI_RESB_OLD-MATNR, the new value of the record change field (VALUE_NEW) is TI_RESB_ADDED-MATNR, and the modification type (C HNGIND) is "U"; when the old table structure demand quantity TI_RESB_OLD-ERFMG is not equal to the new table structure demand quantity TI_RESB_ADDED-ERFMG, the change field (FNAME) is "ERFMG", at this time, the old value of the record change field (VALUE_OLD) is TI_RESB_OLD-ERFMG, the new value of the record change field (VALUE_NEW) is TI_RESB_ADDED-ERFMG, and the modification type (CHNGIND) is "U";When the old table structure factory TI_RESB_OLD-WERKS is not equal to the new table structure factory TI_RESB_ADDED-WERKS, the change field (FNAME) is "WERKS", and the old value (VALUE_OLD) of the record change field is TI_RESB_OLD-WERKS, the new value (VALUE_NEW) of the record change field is TI_RESB_ADDED-WERKS, and the modification type (CHNGIND) is "U"; when the old table structure inventory location TI_RESB_OLD-LGORT is not equal to the new table structure inventory location TI_RESB_ADDED -LGORT, the change field (FNAME) is "LGORT", at this time, the old value (VALUE_OLD) of the record change field is TI_RESB_OLD-LGORT, the new value (VALUE_NEW) of the record change field is TI_RESB_ADDED-LGORT, and the modification type (CHNGIND) is "U"; when the old table structure batch TI_RESB_OLD-CHARG is not equal to the new table structure batch TI_RESB_ADDED-CHARG, the change field (FNAME) is "CHARG", at this time, the old value (VALUE_O LD) is TI_RESB_OLD-CHARG, the new value of the record change field (VALUE_NEW) is TI_RESB_ADDED-CHARG, and the modification type (CHNGIND) is "U"; when the old table structure goods movement identifier TI_RESB_OLD-XWAOK is not equal to the new table structure goods movement identifier TI_RESB_ADDED-XWAOK, the change field (FNAME) is "XWAOK", at this time the old value of the record change field (VALUE_OLD) is TI_RESB_OLD-XWAOK, the new value of the record change field (VALUE_NEW) is W) is TI_RESB_ADDED-XWAOK, and the modification type (CHNGIND) is "U"; when the final delivery identifier TI_RESB_OLD-KZEAR of the old table structure is not equal to the final delivery identifier TI_RESB_ADDED-KZEAR of the new table structure, the change field (FNAME) is "KZEAR", at this time, the old value (VALUE_OLD) of the record change field is TI_RESB_OLD-KZEAR, the new value (VALUE_NEW) of the record change field is TI_RESB_ADDED-KZEAR, and the modification type (CHNGIND) is "U";When the old table structure deletion identifier TI_RESB_OLD-XLOEK is not equal to the new table structure deletion identifier TI_RESB_ADDED-XLOEK, the change field (FNAME) is "XLOEK", the old value of the record change field (VALUE_OLD) is TI_RESB_OLD-XLOEK, the new value of the record change field (VALUE_NEW) is TI_RESB_ADDED-XLOEK, and the modification type (CHNGIND) is "U". ;
[0047] Preferably, the data is updated and maintained using the SAP ABAP data dictionary;
[0048] ABAP is SAP's proprietary development language, which has unparalleled advantages in enterprise-level applications such as large data volume processing, complex business flow, high concurrency, and transaction management. Unlike other open platform languages on the market, SAP is designed to process enterprise data and business logic, which inevitably requires dealing with databases. SAP is cross-database and can support most mainstream databases on the market, such as Hana, Oracle, DB2, MySql, Sqlserver, etc. It defines and manages data objects through the ABAP data dictionary, generally called transparent tables. SAP will create tables with the same structure as transparent tables from the underlying database. Common database objects include tablespaces, tables, fields, indexes, etc. In addition to these, the ABAP dictionary also has some original concepts of its own, mainly domains, data elements, structures, transparent tables, table types, etc. See the SAP ABAP data dictionary architecture diagram. Figure 2 Combined with the SAP ABAP data dictionary for database management capabilities and reserved document change history business requirements, the specific method is shown in Figure 3 .
[0049] The present invention implements a SAP MM reserved document change history recording method, which avoids directly modifying the core code by adopting SAP standard enhancements (such as BAdI, User Exits, and Enhancements), thereby ensuring the stability and security of the system. This method follows SAP best business practices, avoids upgrade compatibility issues, and ensures the stability and security of the system. Self-built tables store change history information. Compared with relying only on the log tables inside the SAP system (these tables may contain a large amount of information that is not specific to the reserved document changes, resulting in low query efficiency), self-built tables can design data structures according to actual needs and only store key information related to the reserved document changes. This not only reduces data redundancy, but also greatly improves the pertinence and efficiency of queries, so that users can quickly obtain the required information when they need to trace the reserved document change history. In summary, the SAP MM reserved document change history recording method of the present invention fully considers the stability, security, flexibility, and user experience of the system in the implementation process, and provides an efficient, reliable, and easy-to-use solution for enterprises.
Claims
1. A method for recording a change history of a SAP MM reservation order, characterized in that: The following steps are involved: Customize history tables in SAP system; Use the transaction code of the SAP system to maintain the reservation order information, and add, modify and delete the reservation order; Trigger the operation of obtaining changed data and log the changed data; Update history records in custom history tables; Query the reservation order change history.
2. A method for recording a history of SAP MM reservation order changes according to claim 1, characterized in that: The customized history record table is a customized ZCDHDR&ZCDPOS table based on the standard order log table CDHDR&CDPOS.
3. A method for recording a history of SAP MM reservation order changes according to claim 2, characterized in that: The ZCDHDR&ZCDPOS table changes the document object to the default "RESERVATION", changes the document object value to the reserved document number, changes the document number to a custom serial number, the user name is the operating user account, the change date is the current system date, the change time is the current system time, the transaction code is the function code corresponding to the user operation business, the table name is the storage table corresponding to the modified field value, the changed table record code is the reserved order number plus the four-digit serial code, the field name is changed to the modified field, the new value of the changed field is the value after the change, and the old value of the changed field is the value before the change.
4. The method for recording a change history of a SAP MM reservation order according to claim 1, characterized in that: When the user changes a reserved document, it is first necessary to determine whether the transaction code is the set default value; if so, determine whether the data structure of the new reserved line item is empty. If not, record the movement type and the reserved document code value; if the movement type is empty and the data structure of the newly added and modified reserved line items is not empty, record the movement type and the reserved document code value; when the table structure TI_RESB_ADDED or TI_RESB_NEW is not empty, record the change voucher header data value, including the reserved code, system operation user, operation transaction code, operation date, and operation time.
5. A method for recording a history record of a SAP MM reservation order change according to claim 4, characterized in that: When the user inserts data and the table structure TI_RESB_ADDED is not empty, the voucher item data value is recorded.
6. A method for recording a history of SAP MM reservation order changes according to claim 4, characterized in that: When the user clicks the delete mark and the table structure TI_RESB_NEW is not empty, the voucher item data value is recorded.
7. A method for recording a history of SAP MM reservation order changes according to claim 1, characterized in that: The transaction code defaults to MB22.
8. A SAP MM reservation order change history recording system, characterized in that: Includes custom history table module, change data module, log record module, update history module and query module; The custom history table module customizes the history table in the SAP system; The data change module uses the transaction code of the SAP system to maintain the reservation order information and add, modify and delete the reservation order; The log recording module triggers the operation of obtaining the changed data and logs the changed data; The update history record module updates the history records in the custom history record table; The query module queries the reservation order change history record.
9. An electronic device, characterized in that: The method comprises a processor and a memory; the memory is used to store a computer program, and the computer program is executed by the processor to perform the method according to any one of claims 1 to 7.
10. A computer storage medium, characterized in that: The computer storage medium stores a computer program, which is executed by a processor to perform the method according to any one of claims 1 to 7.
Citation Information
Cited By
Financial business data automatic processing method and system
CN121146907A
A method and system for automatic processing of financial service data
CN121146907B