Calling BAPIs under Cloud Foundry using the following:
- Spring Boot 2.7.x
- web
- tomcat 9.0
- looging
- devtools
- XS2 security
- CF Service Instances
- application logs: application-logs
- XSUAA: jco-xsuaa --> Created with security/xs-security.json
- Connectivity: connectivity-service
- Destination: destination-service
- Java Development Kit: 1.8
- Don't try to compile the source code with a JDK different than 1.8 (preferably with use sapjvm_8)
- In order to enable JCO, thus MUST be packaged as a WAR file
- Don't try to update the pom file with Spring Boot 3.x. Version 3.x requires Tomcat 10 (mandatory). And Tomcat 10 isn't available on SAP Java Build Pack (current version is sap_java_buildpack_1_87)
- You can't distribute the JCO libraries via custom maven dependency in your pom file. JCO requires installation of OS libraries - which can only be made available via Buildpack. Unless you want to fork and customize your own version of the Java Buildpack from Cloud Foundry, chances are you are stuck with SAP's Buildpack.
- Clone App to a folder with your preferred Git Client.
- Create the CF services described above (destination, connectivity and xsuaa). To create each service instance, go to the sub-account's "Space" menu and select "Services" --> Service Market Place". Then select the desired service type and click on "Instances" to be able to add. Then click on the "New Instance" button. Pay attention to the xsuaa which requires the plan type to be "Application" and the contents of the xs-security.json (provided in the cloned project under the folder security). Make any adjustments on the file according to your needs (new roles & scopes) to be verified later under the REST controller.
cd security
cf create-service xsuaa application jco-xsuaa -c xs-security.json
cf create-service connectivity lite connectivity-service
cf create-service destination lite destination-service
cf create-service application-logs lite log-service
On the space menu select "Services" --> "Service Instances" and click on the destination service. Then on the menu select "Destinations". Each destination listed here will be available only to the space. If you wish to share a destination between spaces, you may create it at the sub-account level. The system will try to find a destination first at the space level. Therefore, destinations with the same name at the sub-account level will be ignored. Click on the button "New Destination" and add a destination to your ABAP system. Don't forget to enter:
- jco.client.ashost
- jco.client.client
- jco.client.sysnr
- jco.client.lang
- jco.destination.pool_capacity
Take note of the Destination name you used here, we will have to use the same name under our code.
- Create a role template via Cloud Cockpit under Sub-Account Menu "Security" --> "Role Collections". Click on the "New Role Collection" button and give it a name of your preference. Once created click on the name's link to assign new roles to it. Click on the "Add Role" button and choose one of the roles you listed on the xs-security.json file (the sample here will list a role named all for xs-app-name cct-jco).
- Under the cockpit go back to the sub-account and click on the "Trust Configuration" item under the menu "Security". Click on the name of your account's IdP. Enter the e-mail address of the user that will be allowed to use this application and click on the button "Show Assignments" (if this is the first time a user is assigned a Role Collection the system will propmt you to add the user. If this is the case, click "Add User"). Click on the button "Add Role Collection" and select the one you created on the previous step.
- Open the CallBAPI class under /src/com/sap/gs/cct/tsconnector and adapt line 29 to reflect the Destination name you took note from a previous step.
JCoDestination destination = JCoDestinationManager.getDestination("<destination_name>");
- Create The war file. Run maven command line with the following arguments:
mvn clean install
-
Adjust the routes for the application under the manifest.yml (pay attention to the CF landscape domain for each URL used)
-
Goto your local application folder (C:...) and type:
C:\...> cf push
- Clone the app-router to a folder with your preferred Git Client. https://github.com/ivanmir/cct-approuter.git
Example call
via approuter:
https://cct-approuter.cfapps.us10.hana.ondemand.com
| WARNING: Don't call this app's URL directly as it expects users to be already authenticated. |
|---|