{"id":26714644,"url":"https://github.com/dbosoft/saphub","last_synced_at":"2025-03-27T13:41:54.445Z","repository":{"id":42388297,"uuid":"364941040","full_name":"dbosoft/SAPHub","owner":"dbosoft","description":"A sample implementation how to build reliable and scaleable SAP integrated microservices with Hosuto and YaNco.","archived":false,"fork":false,"pushed_at":"2024-03-16T23:48:06.000Z","size":615,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-03-17T05:26:24.109Z","etag":null,"topics":["bapi","hosuto","microservice","rfc","sap","sap-integration","yanco"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dbosoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-05-06T14:37:29.000Z","updated_at":"2024-01-12T18:19:44.000Z","dependencies_parsed_at":"2024-03-17T02:05:43.237Z","dependency_job_id":null,"html_url":"https://github.com/dbosoft/SAPHub","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbosoft%2FSAPHub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbosoft%2FSAPHub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbosoft%2FSAPHub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbosoft%2FSAPHub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dbosoft","download_url":"https://codeload.github.com/dbosoft/SAPHub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245857468,"owners_count":20683915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bapi","hosuto","microservice","rfc","sap","sap-integration","yanco"],"created_at":"2025-03-27T13:41:53.701Z","updated_at":"2025-03-27T13:41:54.439Z","avatar_url":"https://github.com/dbosoft.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SAPHub\nThis is a sample application to demonstrate how you can combine [Hosuto](https://github.com/dbosoft/Hosuto) and [YaNco](https://github.com/dbosoft/YaNco) to build a reliable and scaleable service with SAP backend integration.\n\n\n# Requirements\n\nBeside of cloning this repo please consider following requirements:\n\n* **Visual Studio 2019**  \n  It is strongly recommended to use at least Visual Studio 2019 16.8.4 to build/run the applications.   \n  If you would like to try the docker or azure integration also the docker/azure tools have to be installed.\n\n* **.NET SDK 8.0 (x64)**  \n  If you have no Visual Studio installed you will need at least a standalone .NET 8.0 SDK. You can obtain the .NET SDK 8.0 x64 from here:   \n  https://dotnet.microsoft.com/en-us/download/dotnet/8.0 \n\n* **SAP RFC SDK**  \n  Please note that to build and run this project you have to download the SAP Netweaver RFC SDK from the SAP Support Portal.\n  We recommend to use the [Setup Script](#Quickstart) to download the SDK.\n\n  See the requirements section of YaNco how to obtain the SDK *manually*:  \n  https://github.com/dbosoft/YaNco#platforms--prerequisites   \n  You have to download both the Windows_X64 and Linux_x64 Netweaver RFC SDK binaries.\n  Copy them to repos nwrfcsdk directory.\n\n\n* **Azure account**  \n  To run only locally no azure account is required. \n  However to scale out API module with [CosmosDB](https://azure.microsoft.com/de-de/services/cosmos-db/) or to use [Azure Service Bus](https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview) or Azure Storage account you require a azure account ([free accounts available](https://azure.microsoft.com/en-us/free) for dev purposes).\n\n\n# Usage\nThis sample uses [Hosuto](https://github.com/dbosoft/Hosuto) for building microservices that can be either combined in one process or run standalone. \nSo the application can be either be fully distributed (and scaled) or run as a single process.  \nHosuto calls the implementation part **Module**, and the host of modules **ModulesHost**. We will here use **App** as name for the application that runs the ModulesHost.\n\n## Quickstart\n\nFor getting started with SAPHub we recommend to run the automatic setup script after cloning this repository. \n\n``` shell\ngit clone https://github.com/dbosoft/SAPHub.git\ncd SAPHub\nPowerShell -Command .\\setup.ps1\n```\nThe script will guide you through the steps to download the SAP NW RFC SDK and to configure the connection to the SAP System. \n\nThis video shows how to use the script: https://youtu.be/FG2KOWbJ42c\n\n**Update:** Due to changes SAP has made to the logon process, it is no longer possible to download the SDK automatically with the setup script. The script has been updated to guide you through the download but the video is outdated for this part. \n\n  \n## Apps\n\nThe SAPHub comes with 4 pre-build applications.  \nThey can be used to read a SAP systems company codes (if this is not exciting enough for you just imagine that you could also place a sales order instead). \n\n### SAPHub.Server\n  \nThis is the \"all-in-one\" server, that  runs the UI Module, API Module and SAP Connector Module in one process.  \nIt requires no additional message exchange system and runs as a console app (only Windows).   \n\n**Quickstart:**  \nAfter running the setup script (see [Quickstart](#Quickstart) you can run script `Start-SAPHubServer` to build and run this app. \n\nTo run this application from Visual Studio first configure the SAP connection settings in your user secrets ([see below](#sap-connection)) on project **SAPHub.Server**.  \nThen start **SAPHub.Server** project - a browser should be opened automatically on http://localhost:5000 where you can see the UI.  \nFor swagger UI open http://localhost:5000/api/swagger.\n\n\n\u0026nbsp;\n\n### SAPHub.ApiEndpoint\n  \nThe API Endpoint runs only the API Module in a aspnetcore environment. You can host it in a container or on a hyperscaler like AWS/Azure. \nTo communicate with the SAP Connector Module it requires a message exchange system to be set up. To scale horizontally you have to set up a Cosmos DB (see below).\n\n**Quickstart:**  \nYou can start this app together with SAPHub.Connector and RabbitMq as message exchange using docker compose. See [Quickstart for SAPHub.SAPConnector](#saphubsapconnector). \nFor other setups please check [configuration](#configuration) section below. \n\n\u0026nbsp;\n\n### SAPHub.SAPConnector\n  \nThe SAPConnector Service runs only the SAPConnector Module. \nIt can run separated from all other components and needs only network access to the message exchange and to the SAP system.\nTo communicate with the API Module it requires a message exchange to be set up ([see below](#message-exchanges)).\n\n**Quickstart:**  \nYou can start this app together with SAPHub.UI, SAPHub.ApiEndpoint and RabbitMq as message exchange using docker compose.  \n1. Configure the SAP connection settings in your user secrets ([see below](#sap-connection)) on project **SAPHub.SAPConnector**.  \n2. Open a command prompt in project directory.\n3. Run command `docker-compose up`.  \n\nThis will automatically start docker containers running rabbitmq, SAPHub.ApiEndpoint and SAPHub.SAPConnector.\n\nFor other setups please check [configuration](#configuration) section below.  \n\n\u0026nbsp;\n\n### SAPHub.UI\nThe standalone UI application is work-in-progress. It can be started, but will not work in docker currently. Please check later again. \n\n\u0026nbsp;\n\n## Modules\n\n## UI Module\nThe UI module implements a Blazor based application that demonstrates how the API could be used to request data asynchronously from the SAP System.\n\n\u0026nbsp;\n\n![UI screenshot](https://raw.githubusercontent.com/dbosoft/SAPHub/main/.github/saphub_ui.gif)\n\n\n**Scaling**  \nThe UI module can be scaled freely. However you have to consider CORS and load balancing the endpoint address for users and the API endpoint addresses.\nTherefore, if you scale out the UI, place it behind a load balancer and configure endpoint addresses to the load balancer.\n\n### API Module\n\nThe sample provides a REST API to read company code records from the SAP backend asynchronously. \n\n![swagger screenshot](https://raw.githubusercontent.com/dbosoft/SAPHub/main/.github/swagger.png)\n\n**Requests / Responses**  \nA request of `/companycode` will not directly return the company code data, but responds with a `Operation` record. The record contains the operation id. \nThis operation id can be used to query the status of operation on `/operation/\u003coperationId\u003e`. \n\n*Query response:*\n``` json\n{\n\"id\": \"49d017f5-4a1b-4d32-aee2-5986daa7f211\",\n\"status\":0\n}\n```\n\nOnce it is finished the data can be requested with `/companycode/result/\u003coperationId\u003e`\n\n**Message Flow**  \n1. For each request the API module first creates a record for the operation in it's state store. \n2. Then it sends the operation to the SAP Connector queue for processing. \n3. When a SAP Connector reports status change events, it updates the state of operation in it's state store. \n\n**Scaling**  \nTo scale the API Module horizontally you have to enable the cosmos db storage.  \nReason: when a SAP Connector sends a status event update only one API Endpoint will process the changes and update it's state store. Therefore all API Module instances have to use the same state store.  \nAlso you have to place it behind a load balancer and configure endpoint addresses to the load balancer.\n\n\u0026nbsp;\n\n### SAP Connector Module\n\nThe SAP connector module will be used to establish the connection to the SAP system. For development we used our internal ERP EHP 8 IDES system, but it should work with almost any ERP or S/4 system.\n\n**Message Flow**  \n1. For each operation recieved the SAP Connector will establish a connection to the SAP system to retrieve the data (2 requests max. in parallel). \n2. Then it sends a operation update event with result or error state. \n\n**Scaling**  \nThe SAP Connector can be scaled freely.  \nKeep in mind that each SAP Connector will use up to 3 connections (2 processors, 1 for metadata) at same time to backend, so do not overload the backend SAP system with to many connectors. \n\n\u0026nbsp;\n\n## Configuration\n\nThe apps are configured by .NET configuration settings.\nFollowing methods for setting the config are supported:\n- [User Secrets](https://blog.elmah.io/asp-net-core-not-that-secret-user-secrets-explained/)  \n  This is the prefered method, as it will automatically be used in Visual Studio and containers.\n\n- [appsetings.json](https://github.com/dbosoft/SAPHub/blob/main/src/SAPHub.Server/appsettings.json)\n\n- Environment Variables  \n  You can also use environment variables prefixed with *SAPHUB_* to set configuration settings. For example the bus type: \n  `SAPHUB_BUS__TYPE=rabbitmq`\n\nThe following settings are required/supported in the apps:\n\n* SAPHub.Server:\n  - SAP Connection (required)\n  - Message Exchange (optional)\n  - Data Exchange (optional)\n  - CosmosDb (optional)\n  - URL endpoints (optional)\n\n* SAPHub.ApiEndpoint:\n  - Message Exchange (required)\n  - Data Exchange (required)\n  - CosmosDb (optional, required to scale)\n  - URL endpoints (required)\n\n* SAPHub.UI:\n  - URL endpoints (required)  \n\n* SAPHub.SAPConnector:\n  - Message Exchange (required)\n  - Data Exchange (required)\n  - SAP Connection (required)\n\n### URL Endpoint configuration\n\nTo configure where the UI module can find the API and to enable CORS from the UI module you have to configure these URLs in both modules. \n\n- endpoints::default  \n  This is the default (base) url that will be used if a relative path is defined, or path is not definied. \n\n- endpoints::api  \n  URL of API endpoint  \n\n- endpoints::ui  \n  URL of UI\n\nThis is the default configuration of SAPHub.Server:\n\n``` json\n{\n  \"endpoints\": {\n    \"default\": \"http://localhost:5000\",\n    \"api\": \"http://localhost:5000/api\"\n  }\n}\n```\n\n\n### SAP Connection\nFor the SAP Connector Module you have to configure the SAP connection.\n\n**Configuration:**\n\n``` json\n{\n    \"saprfc\": {\n        \"ashost\": \"\u003cyour SAP system hostname\u003e\",\n        \"sysnr\": \"\u003cSAP system No\u003e\",\n        \"client\": \"\u003cSAP Client No\u003e\",\n        \"user\": \"\u003cUserName\u003e\",\n        \"passwd\": \"\u003cPassword\u003e\",\n        \"lang\": \"EN\"\n    }\n}\n```\n\n\n### Message Exchanges\nThe API Module and the SAP Connector module communicate asynchronously via a message exchange. The following messages exchanges are supported:\n\n- **In-Memory**  \n  Supports only the communication between modules hosted in same process.\n  \n  The in-memory exchange is automatically used in the SAPHub.Server app and only makes sense if you run one single instance of SAPHub.Server.\n\n  **Configuration**: \n\n  ``` json\n  { \"bus\" : { \"type\" : \"inmemory\" } }\n  ``` \n\n- **Azure Storage Account**  \n  Uses Azure Storage Account Queues as message exchange.\n\n  **Configuration**:\n\n  ``` json\n  { \"bus\" : { \"type\" : \"azurestorage\", \"connectionstring\": \"\" } }\n  ``` \n\n- **Azure Service Bus**  \n  Uses a Azure Service Bus as message exchange. \n  \n  **Configuration**: \n\n  ``` json\n  { \"bus\" : { \"type\" : \"azureservicebus\", \"connectionstring\": \"\" } }\n  ``` \n\n- **RabbitMq**  \n  Uses RabbitMq as message exchange. \n  \n  **Configuration**: \n\n  ``` json\n  { \"bus\" : { \"type\" : \"rabbitmq\", \"connectionstring\": \"\" } }\n  ``` \n\n### Data Exchanges\nTo transfer large data (results) between the API module and the SAP connector a data exchange is required. The following data exchanges are supported:\n\n- **In-Memory**  \n  Supports only the communication between modules hosted in same process.\n\n  The in-memory exchange is automatically used in the SAPHub.Server app and only makes sense if you run one single instance of SAPHub.Server.\n\n  **Configuration**:\n\n  ``` json\n  { \"databus\" : { \"type\" : \"inmemory\" } }\n  ``` \n\n- **Azure Storage Account**  \n  Uses Azure Storage Account Blobs as data exchange.\n\n  **Configuration**:\n\n  ``` json\n  { \"databus\" : { \"type\" : \"azurestorage\", \"connectionstring\": \"\", \"container\": \"saphub\" } }\n  ``` \n\n- **File System**  \n  Uses a path on the filesystem as data exchange (makes only sense if SAP Connector and API Module could access the path.\n\n  **Configuration**:\n\n  ``` json\n  { \"databus\" : { \"type\" : \"filesystem\", \"path\": \"\\\\\\\\somehost\\\\some_share\" } }\n  ``` \n\n\n### Azure Cosmos DB\nTo scale out the API Module (by starting multiple SAPHub.APIEndpoint or SAPHub.Server apps) you have to enable the Azure Cosmos DB as shared DB storage for the API endpoints. \n\nPlease note that you can also use the CosmosDB emulator to run this locally. \n\n  **Configuration**: \n\n  ``` json\n  { \"cosmosdb\" : { \"databaseName\" : \"\u003cyour_db_name\u003e\", \"connectionstring\": \"\" } }\n  ``` \n\n\u0026nbsp;\n\n# Contribute\nEven if this is only a sample implementation we will continue to maintain it as reference architecture. You are welcome to contribute enhancements or to report issues. \n\n\n# License\nThe code of this sample is licensed under the MIT License - see the LICENSE file for details. Feel free to use it in any application.\n\n# Trademark notice\nSAP, Netweaver are trademarks of SAP SE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbosoft%2Fsaphub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbosoft%2Fsaphub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbosoft%2Fsaphub/lists"}