Skip to content

Commit

Permalink
fix(commit): execute commit transaction function (#5)
Browse files Browse the repository at this point in the history
* When Commit on success is true execute the `BAPI_TRANSACTION_COMMIT`
function

Closes STUDIO-3757
  • Loading branch information
rbioteau committed Feb 25, 2021
1 parent 8206b5c commit c902f7a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 11

- name: Build and test
env:
Expand Down
6 changes: 3 additions & 3 deletions bonita-connector-sap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven-assembly-plugin.version>3.1.1</maven-assembly-plugin.version>
<groovy-maven-plugin.version>2.1.1</groovy-maven-plugin.version>
<groovy-all.version>2.4.16</groovy-all.version>
<groovy.version>3.0.7</groovy.version>
<maven-surefire-plugin.version>3.0.0-M4</maven-surefire-plugin.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
<maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version>
Expand Down Expand Up @@ -192,8 +192,8 @@
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy-all.version}</version>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
</dependency>
</dependencies>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public class SAPCallFunction extends AbstractConnector {
public static final String OUTPUT_TABLE = "output_table";
public static final String OUTPUT_STRUCTURE = "output_structure";
public static final String OUTPUT_SINGLE = "output_single";


private static final String COMMIT_FUNCTION_NAME = "BAPI_TRANSACTION_COMMIT";

static {
INPUT_PARAMETER_TYPES.add(TABLE_INPUT);
Expand Down Expand Up @@ -147,6 +150,20 @@ private void callJCOFunction() throws ConnectorException {
} catch (JCoException e) {
throw new ConnectorException("Failed to execute function", e);
}
Boolean commitOnSuccess = (Boolean) getInputParameter(COMMIT_ON_SUCCESS, false);
if(commitOnSuccess) {
try {
commit();
} catch (JCoException e) {
throw new ConnectorException("Failed to commit the transaction.", e);
}
}
}

private void commit() throws JCoException {
JCoFunction commitFunction = destination.getRepository().getFunction(COMMIT_FUNCTION_NAME);
commitFunction.getImportParameterList().setValue("WAIT", "X");
commitFunction.execute(destination);
}

private List<Serializable> fillBonitaResultWithJCOCallResult(final JCoParameterList tableParameterList) {
Expand Down
2 changes: 2 additions & 0 deletions sapjco-api/src/main/java/com/sap/conn/jco/JCoRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
public interface JCoRepository {

JCoFunctionTemplate getFunctionTemplate(String functionName) throws JCoException;

JCoFunction getFunction(String functionName) throws JCoException;

}

0 comments on commit c902f7a

Please sign in to comment.