Code translation method based on SAP and JAVA software systems and related equipment thereof

By using code translation methods between SAP and JAVA software systems, the JAVA interface entity-class code is automatically generated, which solves the repeated communication and modification problems caused by inconsistency between the two parties in the existing technology, and improves the efficiency and accuracy of data exchange.

CN119536746APending Publication Date: 2025-02-28SHENZHEN LANYOU TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411606667.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-12
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

There is a problem of data exchange technology between the existing SAP and JAVA software systems inconsistent with both parties, resulting in repeated communication, repeated modification of interface codes and repeated joint commissioning and testing.

Method used

Provide a code translation method based on SAP and JAVA software systems. By reading the ABAP variables of the SAP system, judging its data type, and generating JAVA entity class code, including the main entity class and the child entity class, output to a text file to realize the automatic generation of JAVA interface entity class code.

Benefits of technology

It solves the problem of developers repeatedly communicating and confirming the interface and repeatedly modifying the JAVA code, improves the efficiency and accuracy of data exchange, and reduces development time and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119536746A_ABST
    Figure CN119536746A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data exchange between an SAP system and JAVA software, and provides a code translation method based on an SAP and JAVA software system and related equipment thereof.The code translation method comprises the steps that when an ABAP code of the SAP system needs to be translated into a JAVA language, an ABAP variable of the SAP system is read, the data type of the ABAP variable is judged according to the read ABAP variable, and according to the data type of the ABAP variable, the code of the SAP system is translated into the JAVA language. According to the method, JAVA entity class codes are generated, the JAVA entity class codes comprise a JAVA main entity class code and a plurality of JAVA sub-entity class codes, and the JAVA main entity class code and the plurality of JAVA sub-entity class codes are used for being output into a text file, so that when an SAP system and a JAVA system use a common interface to carry out data exchange, after the SAP determines an interface, the JAVA entity class codes are output into the text file, and the JAVA entity class codes are output into the text file. The JAVA interface entity class code can be accurately and automatically generated, and the problem that developers repeatedly communicate and confirm the interface and repeatedly modify the JAVA code is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data exchange between SAP and JAVA software systems, and more specifically, to a code translation method based on SAP and JAVA software systems and related equipment. Background Art

[0002] SAP's SAP software system often needs to exchange data with the JAVA software system. Under normal circumstances, the two systems agree on the data content to be exchanged, and then develop the two systems separately according to the data content, and finally conduct interface joint debugging and testing. During the interface joint debugging, the JAVA software sends data packets to SAP according to certain rules. According to the text documents agreed by both parties, JAVA develops the corresponding code. However, the developed JAVA code cannot guarantee a one-time success rate, and inconsistencies between the two parties often occur, resulting in repeated communication, modification of interface code, and repeated joint debugging and testing.

[0003] In summary, there are inconsistencies in the data exchange technology between the existing SAP and JAVA software systems, resulting in technical problems such as repeated communication, repeated modification of interface codes, and repeated joint debugging and testing. Summary of the invention

[0004] The technical problem to be solved by the present invention is that, in view of the shortcomings of the above technical solutions, a code translation method based on SAP and JAVA software systems and related equipment are provided, so that when the SAP system uses a public interface to exchange data with the JAVA system, after SAP determines the interface, the JAVA interface entity class code can be accurately and automatically generated, thereby solving the problem of developers repeatedly communicating and confirming the interface and repeatedly modifying the JAVA code.

[0005] In a first aspect, the present invention provides a code translation method based on SAP and JAVA software system, comprising the following steps:

[0006] S101. When the ABAP code of the SAP system needs to be translated into the JAVA language, the ABAP variables of the SAP system are read;

[0007] S102, judging the data type of the ABAP variable according to the read ABAP variable;

[0008] S103. Generate JAVA entity class code according to the data type of the ABAP variable, wherein the JAVA entity class code includes a JAVA main entity class code and multiple JAVA sub-entity class codes, and the one JAVA main entity class code and the multiple JAVA sub-entity class codes are used to be output to a text file.

[0009] Further, when it is determined that the data type of the ABAP variable is a field, a private variable code of the JAVA class instance is generated according to the field.

[0010] Further, when it is determined that the data type of the ABAP variable is a structure, a private variable code of the JAVA class instance is generated according to the structure, and the private variable code uses the structure name as the data type.

[0011] Further, when it is determined that the data type of the ABAP variable is a structure, the ABAP variable is assigned to step S101, and the logic of steps S101 to S103 is recursively executed.

[0012] Further, when it is determined that the data type of the ABAP variable is an internal table, a private variable code of the JAVA class instance is generated according to the internal table, and the private variable code uses the internal table name set as the data type.

[0013] Further, when it is determined that the data type of the ABAP variable is an internal table, the ABAP variable is assigned to step S101, and the logic of steps S101 to S103 is recursively executed.

[0014] Furthermore, after all steps are executed, the first entity class code generated is the java main entity class code, and the java entity class code generated later is the java child entity class code. The java main entity class code and the java child entity class code are output to the text file, and the java main entity class is the main entry for structured data.

[0015] In a second aspect, the present invention provides a code translation device based on SAP and JAVA software systems, wherein the code translation device based on SAP and JAVA software systems applies any of the above-mentioned code translation methods based on SAP and JAVA software systems, and the code translation device based on SAP and JAVA software systems comprises:

[0016] An ABAP variable reading module, used for reading the ABAP variables of the SAP system when the ABAP code of the SAP system needs to be translated into the JAVA language;

[0017] An ABAP variable determination module, used for determining the data type of the ABAP variable according to the read ABAP variable;

[0018] The JAVA entity class code generation module is used to generate JAVA entity class code according to the data type of the ABAP variable, wherein the JAVA entity class code includes a JAVA main entity class code and multiple JAVA sub-entity class codes, and the one JAVA main entity class code and multiple JAVA sub-entity class codes are used to be output to a text file.

[0019] In a third aspect, the present invention provides a code translator based on SAP and JAVA software systems, wherein the code translator based on SAP and JAVA software systems applies any of the above-mentioned code translation methods based on SAP and JAVA software systems.

[0020] In a fourth aspect, the present invention provides a computer device, comprising: a processor, a memory and a computer program; the memory is used to store the computer program; the processor is used to execute the computer program stored in the memory to implement any of the above-mentioned code translation methods based on SAP and JAVA software systems.

[0021] Compared with the prior art, the present invention has the following beneficial effects:

[0022] The present invention provides a code translation method based on SAP and JAVA software system and related equipment thereof. When the ABAP code of the SAP system needs to be translated into JAVA language, the ABAP variable of the SAP system is read, the data type of the ABAP variable is judged according to the read ABAP variable, and the JAVA entity class code is generated according to the data type of the ABAP variable. The JAVA entity class code includes a JAVA main entity class code and a plurality of JAVA sub-entity class codes. The one JAVA main entity class code and the plurality of JAVA sub-entity class codes are used to be output to a text file, so that when the SAP system uses a public interface to exchange data with the JAVA system, after SAP determines the interface, the JAVA interface entity class code can be accurately and automatically generated, thereby solving the problem that developers repeatedly communicate and confirm the interface and repeatedly modify the JAVA code. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 It is a flow chart of the code translation method based on SAP and JAVA software system of the present invention;

[0024] Figure 2 It is a structural schematic diagram of a code translation device based on SAP and JAVA software system of the present invention;

[0025] Figure 3 is a schematic diagram of an architecture of a computer device of the present invention;

[0026] Figure 4 It is a system architecture diagram of the code translator based on SAP and JAVA software systems of the present invention. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0028] It should be noted that if the terms "first", "second", etc. appear in the specification and claims of the present invention and the above-mentioned drawings, their purpose is to distinguish similar objects, and they are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein.

[0029] Embodiment 1

[0030] See also Figure 1-Figure 4 The present embodiment provides a code translation method based on SAP and JAVA software systems, including steps S101, S102 and S103. When the ABAP code of the SAP system needs to be translated into JAVA language, the ABAP variable of the SAP system is read, the data type of the ABAP variable is judged according to the read ABAP variable, and the JAVA entity class code is generated according to the data type of the ABAP variable. The JAVA entity class code includes a JAVA main entity class code and multiple JAVA sub-entity class codes. The one JAVA main entity class code and the multiple JAVA sub-entity class codes are used to be output to a text file, so that when the SAP system uses a public interface to exchange data with the JAVA system, after SAP determines the interface, the JAVA interface entity class code can be accurately and automatically generated, thereby solving the problem of developers repeatedly communicating and confirming the interface and repeatedly modifying the JAVA code.

[0031] It should be noted that in the code translation method based on SAP and JAVA software system, step S101, step S102 and step S103 can be run on a computer device. As the execution subject of all or part of the steps in the code translation method based on SAP and JAVA software system, the computer device can execute step S101, step S102 and step S103 in this embodiment, and can also run part or all of the steps of the method involved below. The computer device may include a memory, a processor, and a network interface that are interconnected through a system bus. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a programmable gate array (Field-Programmable Gate Array, FPGA), a digital processor (Digital Signal Processor, DSP), an embedded device, etc. The computer device can be a computing device such as a smart phone, a smart wearable device, etc. The computer device can interact with the user through a keyboard, a mouse, a remote control, a touchpad or a voice control device. The memory includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory can be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the memory can also be an external storage device of a computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory can also include both the internal storage unit of the computer device and its external storage device.

[0032] It should be noted that the interface development between SAP and Java systems is usually done manually. Both systems will confirm the data content and format to be exchanged based on text documents, and Java developers will write code based on the documents, and then repeatedly test and modify it during interface joint debugging. This process is prone to errors caused by inconsistent understanding of data structure or data type, and requires multiple communications, modifications, and retesting. Due to manual processing, there are many inconsistencies between the developed Java code and the SAP interface, resulting in joint debugging failures. Both systems need to communicate and modify the interface code repeatedly, which increases development time and maintenance costs.

[0033] Step S101, when the ABAP code of the SAP system needs to be translated into the JAVA language, the ABAP variables of the SAP system are read. The ABAP variables in the SAP system define the structure and type of data, such as the field name, data type (such as integer, string, floating point number, etc.), field length, etc. of the data. By reading the ABAP variables of the SAP system, it is ensured that the information required for Java code generation is directly extracted from the SAP system, rather than based on manual documents. It can be understood that ABAP (Advanced Business Application Programming) is a programming language used by the SAP system, which is used to define the data structure and business logic in the SAP system. The data definition in the ABAP language is similar to variables in other programming languages, and is used to store the basic unit of data, including basic types (integer, character, date, etc.) and structure types (composite data types containing multiple fields). Through step S101, manual translation and misunderstanding of data definition can be avoided, because the data structure and type information are directly extracted from the SAP system, and do not rely on text documents, thereby reducing errors caused by inconsistent manually defined data structures.

[0034] Step S102, according to the ABAP variable read, the data type of the ABAP variable is judged. In this step, the data type of the ABAP variable read is judged so as to match the corresponding Java data type when the Java code is generated. For example, the ABAP variable type of SAP may be a structure type, a character type, an integer type, etc., which need to be represented by a corresponding class, a string, and an integer variable in Java. Among them, the data type refers to the type and format of the data that the variable can store. In SAP, the data type may be a basic type (such as a character type, an integer type) or a composite type (such as a structure type), and there are corresponding basic data types and classes in Java. The structure type refers to a data type containing multiple fields. The structure type of SAP is similar to a class in Java, containing multiple fields with different data types. In this step, by automatically judging the data type of the ABAP variable, it is ensured that each ABAP variable can accurately match the corresponding data type in the Java code, thereby reducing the inconsistency caused by manual conversion of data types and ensuring that the data structure is seamlessly matched between SAP and Java.

[0035] Step S103, according to the data type of the ABAP variable, generate JAVA entity class code, the JAVA entity class code includes a JAVA main entity class code and multiple JAVA sub-entity class codes, and the one JAVA main entity class code and multiple JAVA sub-entity class codes are used to output to a text file. In this step, according to the data type determined in step S102, a Java entity class code corresponding to the SAP data structure is generated. These Java codes will include a main entity class and multiple sub-entity classes, covering the ABAP variables in the SAP system. The generated Java entity class code will be output to a text file so that Java developers can use it directly. Among them, an entity class is a class in Java, which is usually used to encapsulate the attributes of a database table or data structure. In this step, the entity class is used to encapsulate SAP data structures and variables so that the Java system can directly use these data structures. The main entity class includes the main data structure, and the sub-entity class corresponds to the sub-data type of the composite structure. For example, if a composite data structure is defined in SAP, the Java code will generate a main entity class and multiple sub-classes to reflect this structure. In the generated Java code, each field of the SAP structure type is converted into a private variable (field) in Java to encapsulate and protect the data. These private variables usually correspond to ABAP fields. In this step, the generated Java entity class code directly reflects the ABAP structure in the SAP system, which can ensure the matching of the data structure. By outputting to a text file, Java developers can directly integrate these codes, avoid the process of manually writing Java entity classes, and reduce the inconsistencies that may arise in interface joint debugging.

[0036] In some preferred embodiments, when it is determined that the data type of the ABAP variable is a field, a private variable code of a JAVA class instance is generated according to the field. It should be noted that each field in the ABAP code usually has a specific name, data type and purpose. By directly mapping these fields to private variables in the Java class, it can be ensured that the SAP data structure is accurately restored on the Java side. Moreover, each ABAP field has a specific meaning in the SAP system. Converting it to a private variable in Java can retain these semantic information, so that the Java program can accurately understand and use the meaning of each field when processing data. Using private variables (private) in Java classes is a good encapsulation practice. After converting the ABAP field to a private variable in Java, direct access to the data can be restricted, and the encapsulation of the code can be enhanced. Using private variables can protect data, avoid being directly modified outside the class, and prevent improper operation of data. When automatically generating Java code, the ABAP field is directly converted into a Java private variable to avoid errors in manually written code. The consistency of the Java code and the SAP data structure is guaranteed, thereby reducing the inconsistency problem that occurs during interface joint debugging. When the data structures of SAP and Java systems are consistent, the data formats of both systems can be quickly matched during interface joint debugging, reducing the number of communications and modifications caused by differences in data structures, thereby improving the efficiency of joint debugging tests.

[0037] In some preferred embodiments, when it is determined that the data type of the ABAP variable is a structure, a private variable code of a JAVA class instance is generated according to the structure, and the private variable code uses the structure name as the data type. In some preferred embodiments, when it is determined that the data type of the ABAP variable is a structure, the ABAP variable is assigned to step S101, and the logic of steps S101 to S103 is recursively executed. It should be noted that the ABAP structure in SAP may contain other structure types (nested structures), and these nested structures must be accurately represented in data exchange. By recursively executing steps S101 to S103, the solution can go deep into each nested structure layer by layer, convert it into a Java class in turn, and ensure that the complex nested structure in ABAP is completely restored on the Java side. When the ABAP variable is a structure type, a Java private variable code is generated according to the structure name, and a corresponding Java class is further generated to implement layer-by-layer parsing of the structure, so that each nested level has a corresponding class representation in Java and can be accurately referenced. In addition, using the ABAP structure name directly as the data type of the Java variable can ensure the consistency of data types on both ends and avoid errors caused by manually defining and mapping Java classes, because the name and type of each nested structure are consistent with those in ABAP. When SAP and Java systems exchange data, the data format of the nested structure is often a difficulty in interface debugging. The recursively generated nested Java class structure ensures that the data types between SAP and Java are completely consistent, reducing inconsistencies in interface joint debugging, and facilitating smoother data exchange and interface joint debugging.

[0038] In some preferred embodiments, when it is determined that the data type of the ABAP variable is an internal table, a private variable code of a JAVA class instance is generated according to the internal table, and the private variable code uses an internal table name set as a data type. In some preferred embodiments, when it is determined that the data type of the ABAP variable is an internal table, the ABAP variable is assigned to step S101, and the logic of steps S101 to S103 is recursively executed. It should be noted that in the SAP system, the internal table is an important data structure, similar to a dynamic array or table, for storing a group of data rows of the same structure. Internal tables are very common in SAP's business logic and data processing scenarios, so the data structure of the internal table must be accurately mapped in the Java code to maintain data consistency and integrity. Internal tables usually contain multiple data rows of the same type. In Java, a collection (such as List or Set) is a standard data structure for processing multiple rows of data. Converting the ABAP internal table to a Java collection type can accurately reflect the data characteristics of the SAP internal table, so that the Java code can effectively process multiple rows of data. SAP internal tables are dynamic and can store any number of data rows. Mapping the internal table to a Java collection type (such as List) can achieve the same dynamics, allowing data entries in the collection to be dynamically added or deleted. Using a collection type can maintain the flexibility of the internal table and ensure that the Java side can efficiently handle different numbers of data rows. In a complex SAP system, the internal table may contain a nested structure, for example, each row of data in an internal table contains another internal table. Recursively executing steps S101 to S103 can deeply parse the nested internal table structure and convert it layer by layer into a collection in a Java collection to ensure the complete representation of the nested structure in Java. In the Java code, using the internal table name as the data type of the collection can make the generated code more readable. Directly using the internal table name as the data type of the Java collection can ensure that the data structure in the Java code is consistent with the SAP system, reducing misunderstandings or confusion about the meaning of the structure. In interface joint debugging, semantic consistency can reduce errors caused by misunderstandings and ensure seamless conversion of data between SAP and Java systems.

[0039] In some preferred embodiments, after all steps are executed, the first generated entity class code is the Java main entity class code, and the Java entity class code generated later is the Java sub-entity class code. The Java main entity class code and the Java sub-entity class code are output to the text file, and the Java main entity class is the main entry when the structured data is present. It should be noted that in the generated Java code, the first entity class, as the main entity class, assumes the role of the main entry for data access. Through the main entity class, an external system or application can access all the contents in the entire data structure. The main entity class centrally manages data and can organize all substructures and fields hierarchically to form a clear hierarchical structure. The generated sub-entity class code is used to represent the nested structure type and the inner table type. Separating these sub-entity classes from the main entity class can ensure that each substructure is an independent class, which is convenient for subsequent calls. The clear hierarchical structure makes the main entity class the root node of all structured data, which is convenient for access and calling of other modules. Distinguishing the main entity class from the sub-entity class can greatly enhance the readability of the code. The main entity class, as the entry point for the overall data, intuitively presents all important fields and nested relationships, while the sub-entity class is used to specifically describe each layer of the structure. Such structured code is easier to understand and maintain, and developers can quickly locate the main entry and specific data structure. If subsequent requirements change, they only need to be adjusted in specific sub-entity classes without having to significantly modify the main entity class code. The main entity class, as an entry point, provides a unified access interface, while the sub-entity class, as a modular unit, is easy to maintain and expand independently, reducing the coupling of the code. In data exchange between systems, a unified data entry point is usually required to facilitate interface calls and data transmission. As the main entry point for structured data, the main entity class can encapsulate all fields of the entire data structure, allowing external systems to perform data operations directly through the main entity class, thereby reducing the complexity of data access. In the process of interface joint debugging, the entire data structure can be directly verified and managed through the main entity class, while the sub-entity class only needs to be checked layer by layer according to the call of the main entity class. This layered approach makes interface joint debugging more organized, and external systems only need to perform joint debugging on the main entity class, reducing the complex understanding of the code structure and improving joint debugging efficiency.

[0040] In some further embodiments, when generating JAVA entity class code, it includes creating java import code, and creating java import code specifically includes first referencing relevant class code that supports serialization to xml (for example, XmlElement, XmlElementWrapper, XmlRootElement, XmlAccessorType, XmlAccessType, Serializable, etc.); then introducing relevant class code of collection to support internal table; and then generating class annotation; when generating JAVA entity class code, it also includes creating java class definition, and the class name is ABAP variable structure type name or sub-structure type name or sub-internal table structure type name; when generating JAVA entity class code, it also includes creating java class variables, specifically including creating java class single field variables, creating java class structure variables, and creating java class internal table variables; when generating JAVA entity class code, it also includes creating java class constructor, specifically including creating basic constructor, adding structure instantiation code to the basic constructor, if it contains structure, adding instantiation code of all structure variables, adding internal table instantiation code to the constructor, if it contains internal table, adding instantiation code of all internal variables; when generating JAVA entity class code, it also includes creating java class get set method, specifically including creating java The getset method of a single field of a class is used to create a getset method of a Java class structure variable, and a getset method of a Java class internal table variable is created. It should be noted that in the present embodiment, relevant classes (such as XmlElement, XmlElementWrapper, XmlRootElement, XmlAccessorType, XmlAccessType, Serializable, etc.) that support XML serialization are referenced so that the generated Java class supports serializing data into XML format. This is crucial in data exchange because XML is a universal data exchange format and many systems (including SAP) support XML. Therefore, the serialization function facilitates data transmission between Java and SAP and enhances the interoperability of the system. In addition, the introduction of collection classes (such as List, ArrayList) is to support internal tables in ABAP. Internal tables are usually represented as collection types in Java. The introduction of collection classes ensures that Java code can dynamically process multiple rows of data and maintain the flexibility and dynamism of internal tables. This enables Java code to accurately and effectively reflect the SAP internal table structure. The automatically generated class annotations can provide information about class usage, structural sources, and data types.Class comments help developers quickly understand the functions of the code and the source of the data structure. Especially in large projects or team collaboration, comments facilitate subsequent maintenance and expansion, and reduce development errors caused by misunderstandings. Class comments can provide automated documentation support when generating code for subsequent reference. The comments can include data sources, structure descriptions, and descriptions of special fields, so that the generated code has its own documentation features, which facilitates code review and interface joint debugging. In addition, the generated Java class name is consistent with the structure type name of the ABAP variable, which helps the readability and understanding of the code. This naming method ensures that the Java code can accurately reflect the structure name in SAP, which helps to establish a clear mapping relationship between SAP and Java systems and reduce misunderstandings. Using the structure name as the Java class name can clarify the purpose and data content of the class, making the Java class more functionally consistent with the business logic. For example, the EmployeeStructure class clearly indicates that the data structure stores employee information, which makes it easier for developers to quickly identify its function from the naming. In addition, for each ABAP field, a corresponding variable is generated in the Java class, which can retain the field definition in the SAP system. Creating private variables for each field in Java can achieve encapsulation and enhance the security of data access. When encountering nested structures and internal tables, corresponding structure variables and internal table variables are generated. The nested structure is mapped to a structure type variable in the class, and the internal table is mapped to a collection type variable. This ensures that the complex data structures of the SAP system (such as nested structures and internal tables) are fully mapped on the Java side, ensuring the consistency and integrity of the data structure between the two systems. In addition, generating a basic constructor can provide default initialization logic for class instantiation. This ensures that when creating Java entity class objects, all fields and structure variables have appropriate default values ​​to prevent runtime errors caused by lack of initial values. Adding the instantiation logic of structure variables and internal table variables to the constructor enables the generated Java class to fully initialize the structure and internal table when it is created. By instantiating these nested structures and collections, the Java code can represent the complex data structures in SAP in a complete form, ensuring the integrity of the data structure. In addition, the getter / setter method for each field is generated to provide a standard access and modification interface. This method complies with the encapsulation principle of Java and ensures access control to private variables. The getter / setter method facilitates reading and writing data fields in the SAP system in Java, ensuring the security of data access. The getter / setter method of structure variables and internal table variables generates getter / setter methods for nested structures and internal tables, making it easier to access and operate complex structured data. For internal table type data, the generated getter method can return a collection object, allowing developers to traverse and modify the data.This approach makes Java code more flexible in handling complex data structures and ensures consistency in data operations. In addition, the generated Java entity class code complies with the design specifications of Java object-oriented programming, encapsulating each structure and internal table in their own class for easy independent management. This object-oriented design allows the code to be easily expanded when it needs to be expanded or a new structure is added without modifying the main class code. In addition, by introducing serialization-related classes, objects can be easily serialized into XML, which facilitates data transmission between systems. This object-oriented design also ensures that Java code is more flexible when interacting with other systems, which is conducive to the implementation of business logic and persistent storage of data. In addition, each generated Java entity class strictly corresponds to the ABAP structure from class name, variables, constructors to getter / setter methods, ensuring that the Java code is consistent with the SAP data structure. This ensures consistency in data transmission and storage during interface joint debugging and reduces errors caused by structure mismatch. The generated standardized Java code can reduce data errors in manual definition and mapping, making the data interface between Java code and SAP system more consistent. The standardized generation process greatly reduces the debugging workload of developers and improves the efficiency of interface joint debugging.

[0041] Embodiment 2

[0042] See also Figure 1-Figure 4 This embodiment provides a code translation device based on SAP and JAVA software systems. The code translation device based on SAP and JAVA software systems applies the code translation method based on SAP and JAVA software systems described in any of the above embodiments. The code translation device based on SAP and JAVA software systems includes:

[0043] An ABAP variable reading module, used for reading the ABAP variables of the SAP system when the ABAP code of the SAP system needs to be translated into the JAVA language;

[0044] An ABAP variable determination module, used for determining the data type of the ABAP variable according to the read ABAP variable;

[0045] The JAVA entity class code generation module is used to generate JAVA entity class code according to the data type of the ABAP variable, wherein the JAVA entity class code includes a JAVA main entity class code and multiple JAVA sub-entity class codes, and the one JAVA main entity class code and multiple JAVA sub-entity class codes are used to be output to a text file.

[0046] It should be noted that, in this embodiment, when the ABAP code of the SAP system needs to be translated into JAVA language, the ABAP variable of the SAP system is read, and the data type of the ABAP variable is determined according to the read ABAP variable. According to the data type of the ABAP variable, a JAVA entity class code is generated, and the JAVA entity class code includes a JAVA main entity class code and multiple JAVA sub-entity class codes, and the one JAVA main entity class code and the multiple JAVA sub-entity class codes are used to output to a text file, so that when the SAP system uses a public interface to exchange data with the JAVA system, after SAP determines the interface, the JAVA interface entity class code can be accurately and automatically generated, thereby solving the problem of developers repeatedly communicating and confirming the interface and repeatedly modifying the JAVA code.

[0047] Embodiment 3

[0048] See also Figure 1-Figure 4 The present embodiment provides a code translator based on SAP and JAVA software systems. The code translator based on SAP and JAVA software systems applies the code translation method based on SAP and JAVA software systems described in any of the above embodiments. When the ABAP code of the SAP system needs to be translated into JAVA language, the ABAP variable of the SAP system is read, and the data type of the ABAP variable is judged according to the read ABAP variable. According to the data type of the ABAP variable, a JAVA entity class code is generated. The JAVA entity class code includes a JAVA main entity class code and multiple JAVA sub-entity class codes. The one JAVA main entity class code and the multiple JAVA sub-entity class codes are used to be output to a text file, so that when the SAP system uses a public interface to exchange data with the JAVA system, after SAP determines the interface, the JAVA interface entity class code can be accurately and automatically generated, thereby solving the problem of developers repeatedly communicating and confirming the interface and repeatedly modifying the JAVA code.

[0049] Embodiment 4

[0050] See also Figure 1-Figure 4The present embodiment provides a computer device, comprising: a processor, a memory and a computer program; the memory is used to store the computer program; the processor is used to execute the computer program stored in the memory, so as to implement the code translation method based on SAP and JAVA software system described in any of the above embodiments, by reading the ABAP variable of the SAP system when it is necessary to translate the ABAP code of the SAP system into JAVA language, judging the data type of the ABAP variable according to the read ABAP variable, and generating JAVA entity class code according to the data type of the ABAP variable, the JAVA entity class code comprising a JAVA main entity class code and multiple JAVA sub-entity class codes, the one JAVA main entity class code and the multiple JAVA sub-entity class codes are used to output to a text file, so that when the SAP system uses a public interface to exchange data with the JAVA system, after SAP determines the interface, the JAVA interface entity class code can be accurately and automatically generated, so as to solve the problem that developers repeatedly communicate and confirm the interface and repeatedly modify the JAVA code.

[0051] It should be noted that the related equipment of the code translation method based on SAP and JAVA software system includes but is not limited to the code translation device, translator and computer equipment based on SAP and JAVA software system in the above embodiments.

[0052] It should be pointed out that the above embodiments are only preferred specific implementation modes of the present invention, and the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention. The protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A code translation method based on SAP and JAVA software system, characterized in that: The following steps are involved: S101. When the ABAP code of the SAP system needs to be translated into the JAVA language, the ABAP variables of the SAP system are read; S102, judging the data type of the ABAP variable according to the read ABAP variable; S103. Generate JAVA entity class code according to the data type of the ABAP variable, wherein the JAVA entity class code includes a JAVA main entity class code and multiple JAVA sub-entity class codes, and the one JAVA main entity class code and the multiple JAVA sub-entity class codes are used to be output to a text file.

2. The code translation method based on SAP and JAVA software system as claimed in claim 1, characterized in that: When it is determined that the data type of the ABAP variable is a field, a private variable code of the JAVA class instance is generated according to the field.

3. The code translation method based on SAP and JAVA software system as claimed in claim 1, characterized in that: When it is determined that the data type of the ABAP variable is a structure, a private variable code of a JAVA class instance is generated according to the structure, and the private variable code uses the structure name as the data type.

4. The code translation method based on SAP and JAVA software system as claimed in claim 3, characterized in that: When it is determined that the data type of the ABAP variable is a structure, the ABAP variable is assigned to step S101, and the logic of steps S101 to S103 is recursively executed.

5. The code translation method based on SAP and JAVA software system as claimed in claim 1, characterized in that: When it is determined that the data type of the ABAP variable is an internal table, a private variable code of the JAVA class instance is generated according to the internal table, and the private variable code uses the internal table name set as the data type.

6. The code translation method based on SAP and JAVA software system as claimed in claim 5, characterized in that: When it is determined that the data type of the ABAP variable is an internal table, the ABAP variable is assigned to step S101, and the logic of steps S101 to S103 is recursively executed.

7. The code translation method based on SAP and JAVA software system according to any one of claims 1 to 6, characterized in that: After all steps are executed, the first entity class code generated is the java main entity class code, and the java entity class code generated later is the java child entity class code. The java main entity class code and the java child entity class code are output to the text file. The java main entity class is the main entry for structured data.

8. A code translation device based on SAP and JAVA software system, characterized in that: The code translation device based on SAP and JAVA software system applies the code translation method based on SAP and JAVA software system as described in any one of claims 1 to 7, and the code translation device based on SAP and JAVA software system includes: An ABAP variable reading module, used for reading the ABAP variables of the SAP system when the ABAP code of the SAP system needs to be translated into the JAVA language; An ABAP variable determination module, used for determining the data type of the ABAP variable according to the read ABAP variable; The JAVA entity class code generation module is used to generate JAVA entity class code according to the data type of the ABAP variable, wherein the JAVA entity class code includes a JAVA main entity class code and multiple JAVA sub-entity class codes, and the one JAVA main entity class code and multiple JAVA sub-entity class codes are used to be output to a text file.

9. A code translator based on SAP and JAVA software system, characterized in that: The code translator based on SAP and JAVA software system applies the code translation method based on SAP and JAVA software system as described in any one of claims 1-7.

10. A computer device, characterized in that: include: A processor, a memory and a computer program; the memory is used to store the computer program; The processor is used to execute the computer program stored in the memory to implement the code translation method based on SAP and JAVA software system according to any one of claims 1 to 7.