Skip to content

This web application showcases an extension to an SAP S/4HANA Cloud system. It allows users to read and write their working time in a fast and efficient way.

License

Notifications You must be signed in to change notification settings

SAP-samples/s4hana-cloud-ext-timesheet

REUSE status

S/4HANA Cloud extensions - Quick Time Entry for SAP S/4HANA Time Recording (SAP S/4HANA Cloud SDK)

This web application showcases an extension to an SAP S/4HANA Cloud system. It allows users to read and write their working time in a fast and efficient way.

NOTE: This app is based on and explained in detail in the Set-upGuide_Timesheet. There, you will find more details on the end to end steps of the business event handling scenario example, e.g.:

  • Connection setup of the SAP S/4HANA Cloud system and SAP Cloud Platform (via a communication arrangement)
  • Adaption and deployment
  • Identity Provider

The following README only shows a basic overview

Set-up Instructions Guide

https://help.sap.com/viewer/11a6aeea94214fae9fe26afbdb9291fc/SHIP/en-US

Requirements

  1. We assume that you have access to an SAP S/4HANA Cloud system and an SAP Business Technology Platform account.

  2. Install JDK8, Maven and Git.

  3. You've downloaded and installed the Node Js Command Line Interface, which is available on the Node JS.

  4. You've downloaded and installed the service management plug-in for Cloud Foundry tools.

  5. You've downloaded and installed the Cloud MTA Build Tool (MBT), which is available on SAP Build solutions for multitarget applications MBT.

  6. (Optional) To use an integrated development environment such as Eclipse, refer to the tutorial about how to configure an Eclipse IDE for Java development on SAP Business Technology Platform.

Lastly, Prepare your S/4HANA Cloud system according to the Set-upGuide_Timesheet.

Connect it to your S/4HANA Cloud system

In this scenario, a Java application in front with a SAPUI5 application it is used to read and write timesheet data from SAP S/4HANA Cloud System. For that purpose, we use standard, resource-based APIs of SAP S/4HANA.

To allow inbound communication to the SAP S/4HANA tenant, we need to create a communication arrangement first. The communication arrangement defines which system (communication system) and which user can call which APIs (communication scenarios). In this example, you create a communication arrangement and allow access to the standard Manage Workforce Timesheet API (SAP_COM_0027) using a technical user.

NOTE: Please follow the steps described in the Set-upGuide_Timesheet to set up a communication system, communication arrangements and communication user in your S/4HANA tenant.

Downloading the Code

To download this project run this command.

git clone https://github.com/SAP-samples/s4hana-cloud-ext-timesheet.git
cd s4hana-cloud-ext-timesheet

Or if you want to clone the single branch only:

git clone -b timesheet-cf --single-branch git://github.com/SAP-samples/s4hana-cloud-ext-timesheet.git
cd s4hana-cloud-ext-timesheet

Build it

To build this project to a deployable .mtar, run the below command in s4hana-cloud-ext-timesheet folder.

mbt build

You can adopt the project deployment using mta.yaml file. It has deployment details of each module.

Build Result: "../mta_archives/time-sheet_0.0.1.mtar" is created.

Deploy to SAP Business Technology Platform

  1. Go to the command console.
  2. Switch to the application folder (..\timesheet-cf) of the project structure.
  3. Use the Cloud Foundry command cf login to log in to your Cloud Foundry account:
  4. Enter the API endpoint you want to connect to. You can see this value in the API Endpoint field in your subaccount.
  5. Enter your user name (your p-user) and password.
  6. Push the mtar build applications to the cloud using this command: cf deploy mta_archives/time-sheet_0.0.1.mtar
  7. you can get the application's URL using the command cf apps.

NOTE: Before you can start the application, you need to create a destination first. Refer to the next section.

Create a Destination

Destinations are used for the outbound communication of your application to a remote system (which is, in this case, the SAP S/4HANA Cloud system). To create a destination, you enter a name, the URL of the SAP S/4HANA Cloud system, the authentication type, and some other configuration data. Maintain the properties as follows:

Property Value
Name S4HANA_CLOUD
Type http
Description <e.g. the name of your communication arrangement>
URL <the base URL to your S/4HANA Cloud system; note the “-api”; e.g. https://myXXXXXX-api.s4hana.ondemand.com>
Proxy type Internet
Authentication BasicAuthentication
User <the user you created; e.g. TIMESHEET>
Password <the password you created>

NOTE: The name of the destination should be exactly “S4HANA_CLOUD”. The user and password depend on the communication system and user that have been created in your SAP S/4HANA Cloud system. The URL depends on the communication arrangement created in your SAP S/4HANA Cloud system.

Troubleshooting

In case you hit the error page, please go through the exception
trace for more details. 

cf logs <application name> --recent

**Known Exceptions:**
ODataException connectivity : Re-check your Destinations S4HANA_CLOUD and the S/4HANA System.
FileNotFoundException : Make sure that you don't have directory names that contain whitespaces in the project path. eg. "s4 cld ext timesheet"

If you work with your [SAP Business Technology Platform Trial account](https://account.hanatrial.ondemand.com/), 
you must add the following 2 properties to the destination so that the connection to SAP S/4HANA Cloud works:  

  proxyHost =	proxy-trial.od.sap.biz  
  proxyPort =	8080

Limitations / Disclaimer

Note: This sample code is primarily for illustration purposes and is not intended for productive usage. It solely shows basic interaction with an S/4HANA Cloud system. Topics like authentication, error handling, transactional correctness, security, caching, tests were omitted on purpose for the sake of simplicity. For detailed information on development on the SAP Cloud Platform, please consult https://www.sap.com/developer.html

How to obtain support

SAP does not offer any official support for the sample code (see the SAP SAMPLE CODE LICENSE AGREEMENT on GitHub). However, if you have any problems, Create an issue in this repository, if you find a bug or have questions about the content.

For additional support, ask a question in SAP Community.

Contributing

If you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses the standard DCO text of the Linux Foundation.

Copyright and License

Copyright (c) 2023 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.

About

This web application showcases an extension to an SAP S/4HANA Cloud system. It allows users to read and write their working time in a fast and efficient way.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published