Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Latest commit

 

History

History
111 lines (96 loc) · 5.49 KB

README.md

File metadata and controls

111 lines (96 loc) · 5.49 KB

Deprecation Notice

This public repository is read-only and no longer maintained.


REUSE status License: Apache2

A Decoupled Approach for SAP Business ByDesign Event Handling

Description

This application produces events based on SAP Business ByDesign objects' changes. It works by pulling data, every minute, from OData services and checking if there were changes. It has a serverless, loosely coupled architecture and has been implemented using AWS Serverless Application Model.

Requirments

Deployment

Clone or download this repository:

git clone https://github.com/B1SA/byd-delta-events.git

Update the environment variables located on the template.yaml file. The minimum requirement is the BYD credentials.

From its root folder, build and deploy it to your account.

sam build
sam deploy --guided

For details on how to deploy/test it locally check README-SAM

Enhancement

You can easily enhance this solution to support more SAP Business ByDesign objects or to implement new subscribers that will receive the events

Adding Business Objects

1 - Add the new object OData endpoint details on the env variables for the get-byd-objects functions on template.yaml

NOTE: the OData service must expose at least the Object ID, LastChangeDateTime and CreationDateTime attributes

Environment:
       Variables:
         #ByD Details
         BYD_ODATA: "https://my000000.sapbydesign.com/sap/byd/odata/cust/v1"
         BYD_AUTH: "user:password base64 encoded"
         BYD_NEWOBJECT: "/newObject/newObjectCollection"
         BYD_NEWOBJECT_ID: "ID"

2 - Create a new promise to invoke the new object service in the get-byd-objects function:

let NewObject = function (lastRun) {
    return new Promise(function (resolve, reject) {
        console.log("Retrieving ByD New Objects")
        getBydObject(lastRun, process.env.BYD_NEWOBJECT, process.env.BYD_NEWOBJECT_ID).then((data) => {
            console.log(data.length + "ByD New Objects Retrieved")
            resolve(data)
        })
    })
}

3 - Add the call for the NewObject promise to the getBydObjectsPromises array

const getBydObjectsPromises = [ SalesInvoices(data.lastRun.S), 
                                Customers(data.lastRun.S),
                                SalesOrders(data.lastRun.S),
                                ServiceOrders(data.lastRun.S),
                                NewObject(data.lastRun.S)]

A practical example in this commit

Adding new Subscribers

To add a new subscriber to to the notification system, do the following on the template.yaml file:

1 - Add the new subscriber details (in this case a new Lambda Function)

#New Subscriber Function
NewSubscriberFunction:
  Type: AWS::Serverless::Function 
  Properties:
    CodeUri: new-subscriber-function/
    Handler: app.lambdaHandler
    Runtime: nodejs12.x

2 - Add the new function as a subscriber to the existing SNS topic BydEventTopic

    Subscription:
      - Protocol: lambda
        Endpoint: !GetAtt NewSubscriberFunction.Arn

3 - Define a new invoke permission for the new function

NewSubscriberFunctionInvokePermission:
 Type: 'AWS::Lambda::Permission'
 Properties:
   Action: 'lambda:InvokeFunction'
   FunctionName: !Ref NewSubscriberFunction
   Principal: sns.amazonaws.com   

A practical example of those changes can be found in here

4 - The last step is to implement the New Subscriber's function as shown on this commit

5 - Redeploy the app

Support and Contributions

This repository is provided "as-is". No support is available. Feel free to open issues or provide pull requests.

License

Copyright (c) 2020 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.