Overview
As an independent system, SAP mainly interacts with external systems in the following two ways:
Direct connection to the underlying database
Data calls through the dedicated SAP Remote Function Call (RFC) interface
Therefore, when you design reports that use data from an SAP system in FineReport, you can retrieve data by directly connecting to the database or by using the RFC interface.
Common relational databases for SAP systems include Oracle and DB2. FineReport can directly connect to the database used by the SAP system through the Java Database Connectivity (JDBC) API to retrieve data. However, this method requires report designers to fully understand the SAP system database, and this database must allow access from other systems. You are advised to use the SAP Dataset plugin to connect to the SAP system with an SAP account and retrieve data.
Note: This document uses an example to describe how to write Java files to retrieve data through the dedicated SAP RFC interface.
Implementation Method
First, use a Java class file to establish a connection to SAP. Then, use the class dataset interface to convert the data retrieved through RFC into a virtual two-dimensional table. Finally, use the virtual table as the data source for report creation.
Procedure
Adding SAP JAR Files
Linux:
Download SAP JAR files from SAP Software Download Center.
| JDK Bit Version | SAP JAR File Location |
|---|---|
32-bit | Place sapjco3.jar in the Tomcat installation directory\lib path. Place libsapjco3.so in the Java installation directory\jre\bin path. Place libsapjco3.so in the usr\lib path. If Linux is 64-bit, place it in the usr\lib64 path. |
64-bit | Place sapjco3.jar in the Tomcat installation directory\lib path. Place libsapjco3.so in the Java installation directory\jre\bin path. Place libsapjco3.so in the usr\lib64 path. |
Note:Windows:
Download SAP JAR files from SAP Software Download Center.
| JDK Bit Version | JDK Version | File | SAP File Location |
|---|---|---|---|
32-bit | JDK 1.8 with an update release of 8u102 or later | sapjco2_window_32bit | Place sapjco.jar in the Tomcat installation directory\lib path. Place librfc32.dll in the C:\Windows\System32 path. Place sapjcorfc.dll in the C:\Windows\System32 path. |
64-bit | JDK 1.8 with an update release of 8u102 or later. | sapjco2_window_32bit | Place sapjco.jar in the Tomcat installation directory\lib path. Place librfc32.dll in the C:\Windows\System32 path. Place sapjcorfc.dll in the C:\Windows\System32 path. |
Connecting to SAP
Use the ConnectSAPServer class to establish a connection to SAP systems. Click to download the ConnectSAPServer class file: ConnectSAPServer.java.zip
Note: For details about the connection procedure, see Compiling a Java Program.

Defining a Class Dataset
After the database is connected, define a class dataset. Then, use the class dataset interface to convert the data into a virtual table.
Click to download the ParamSAPDataTest class file: ParamSAPDataTest.java.zip
If you need to replace the class file, delete the generated ABAP_AS_WITH_POOL.jcoDestination file at the same time.

Configuring a Class Dataset
1. Copy the compiled ParamSAPDataTest.class class file to the /webroot/WEB-INF/classes/com/fr/data path of the project.
Note: 2. Create a template, click the
icon above Template Dataset, select Class to open the Class Dataset window, and select the required class file.
3. After you complete the configuration, a class dataset is successfully created in the designer, as shown in the following figure.
Note: 
Summary
Using the RFC interface prevents issues caused by direct connections to the SAP system database. RFC parameters and table-calling methods are also well documented online or provided by SAP vendors. However, this method requires class files to retrieve data, which can be cumbersome when many reports are involved. To implement effects such as chart linkage, you need to define parameters in the class, making later modifications inconvenient. Therefore, this method is suitable for technical personnel with Java development experience.