sap4j

Interactions with SAP made dead easy.

License

License

GroupId

GroupId

com.sap4j
ArtifactId

ArtifactId

sap4j
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

sap4j
Interactions with SAP made dead easy.

Download sap4j

How to add to project

<!-- https://jarcasting.com/artifacts/com.sap4j/sap4j/ -->
<dependency>
    <groupId>com.sap4j</groupId>
    <artifactId>sap4j</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.sap4j/sap4j/
implementation 'com.sap4j:sap4j:1.0.2'
// https://jarcasting.com/artifacts/com.sap4j/sap4j/
implementation ("com.sap4j:sap4j:1.0.2")
'com.sap4j:sap4j:jar:1.0.2'
<dependency org="com.sap4j" name="sap4j" rev="1.0.2">
  <artifact name="sap4j" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.sap4j', module='sap4j', version='1.0.2')
)
libraryDependencies += "com.sap4j" % "sap4j" % "1.0.2"
[com.sap4j/sap4j "1.0.2"]

Dependencies

compile (6)

Group / Artifact Type Version
org.apache.commons : commons-lang3 jar 3.9
log4j : log4j jar 1.2.17
net.jodah : failsafe jar 2.4.0
commons-io : commons-io jar 2.6
com.google.guava : guava jar 29.0-jre
com.google.code.gson : gson jar 2.8.6

provided (1)

Group / Artifact Type Version
com.sap.conn.jco » sapjco3 jar 3.0.14

test (4)

Group / Artifact Type Version
junit : junit jar 4.13.1
org.mockito : mockito-core jar 1.10.19
org.powermock : powermock-module-junit4 jar 1.6.2
org.powermock : powermock-api-mockito jar 1.6.2

Project Modules

There are no modules declared in this project.

sap4j

We make SAP interactions dead easy :)

Download

sap4j is available on Maven central repository.

<dependency>
    <groupId>com.sap4j</groupId>
    <artifactId>sap4j</artifactId>
    <version>1.0.2</version>
</dependency>

Features

  • Clean and intuitive DSL to describe connections, queries and iterate results.
  • Maintain multiple SAP connections, query tables and BAPI functions while retrieving all results with same interface.
  • Includes circuit breaker pattern, to avoid overhelming SAP server when query execution issues arise.
  • Provide means to define throttling policies for queries execution.

Usage Examples

Properties properties = new Properties();
properties.setProperty("username", "xxx");
properties.setProperty("password", "xxx");

SAPConnection connection =
    SAPConnectionBuilder.getInstance()
       .withLanguage(ISO639LanguageCode.EN)
       .withAsHost("somehost")
       .withClient("001")
       .withSysnr("01")
       .withPoolCapacity(3)
       .withCredential(SAPCredential.fromProperties(properties))
       .build();

// Instantiate executor for given connection
SAPQueryExecutor executor = SAPQueryExecutor.forConnection(connection, throttlingPolicy, circuitBreaker);

// Write some query
SAPQuery query = SAPQueryBuilder.queryFunction("BAPI_MATERIAL_STOCK_REQ_LIST")
    .withQueryCondition("MATERIAL", "XAEA12")
    .withQueryCondition("GET_IND_LINES", "X")
    .fromTable("MRP_IND_LINES").build();
    
// Execute query
Map<String, Iterator<SAPResultRow>> results = executor.execute(query);
// Retrieve results
Iterator<SAPResultRow> rows = results.get("MRP_IND_LINES");

// Iterate and process results
while(rows.hasNext()){
    StringBuilder builder = new StringBuilder();
    Map<String, String> values = rows.next().getColumnValues(); // process results
    for(String key : values.keySet()){
        builder.append(String.format("'%s', ", values.get(key)));
    }
    System.out.println(builder.toString());
}

Limitations

At the current stage, the library provides means to read data. Executions to write data into SAP were not developed yet. We do not deal with queries caching: this should be handled on server side, to ensure data consisenty.

Recommendations

To ensure optimal queries, please check query conditions target indexed fields. More details on how to ensure high performance can be found in the following SAP document. We specifically advice "Section 5.5: SQL Tuning Guidelines". The rest of the document provides an overview on inner workings of relational DBs, providing details regarding queries optimization, compilation and execution; useful information on how to debug queries performance issues.

Versions

Version
1.0.2
1.0.1
1.0.0