Technical Articles
SAP Commissions – CAP – Consuming Files based – Part 1
Previous article – Introducing CAP to SAP Commissions
This article describes how to consume file based approach using with CAP (Cloud Application Programming) for end users to see the report.
There are several ways we can make use of CAP Application for the end users to see the real data.
- Download raw data from Commissions workspace as File Based Approach (below described)
- Pull data from Commissions API as automated Based Approach ( Next Blog)
- Connecting to Commissions Database ( Under restriction from SAP Commissions Product)
High Level Flow
Prerequisites
The following are prerequisite tasks that must be completed before proceeding with this task:
- Developing in Local – Visual Studio Code with Nodejs Installed or SAP BTP Business Application Studio – Preinstalled CDS
- SAP Commissions Portal access for Payment’s workspace
- NPM Packages required
- Deploying to Cloud Foundry (cf) – SAP BTP Trail or Global Account
Select CAP Project from the template and Click Start
Provide the Project Name and fill rest of the details as shown (1, 2, 3, 4)
npm i -g @sap/cds-dk
As you can see we have 3 major folders
- app
- db
- srv
Execute below commands which will create
mkdir db/data
touch db/data/payout-reports.csv
touch db/schema.cds
touch srv/cat-service.cds
Let’s start with the DB Folder: It contains the Database Entity which is based on CDS Model. The design-time artefacts declared in this file will be converted to run-time, physical artefacts in the database. In this example, the entities will become tables.
db/schema.cds
namespace payout;
entity reports {
key ID : Integer;
Participant : localized String(111);
Position : localized String(1111);
EarningGroup : localized String(1111);
Period : localized String(1111);
Currency : localized String(1111);
Prior_Balance : Decimal;
Earning : Decimal;
Payment : Decimal;
Balance : Decimal;
Processing_Unit : localized String(1111);
Business_Unit : localized String(1111);
}
srv/cat-service.cds
using {payout as payout} from '../db/schema';
service Payment@(path : '/srv') {
entity reports as
select from payout.reports {*};
annotate Payment.reports with @UI : {
LineItem : [
{Value : ID, Label : 'ID'},
{Value : Participant, Label : 'Participant'},
{Value : Position, Label : 'Position'},
{Value : Period, Label : 'Period'},
{Value : EarningGroup, Label : 'Earning Group'},
{Value : Earning, Label : 'Earning'},
{Value : Currency, Label : 'Currency'},
{Value : Payment, Label : 'Payment'},
{Value : Business_Unit, Label : 'Business Unit'},
{Value : Processing_Unit, Label : 'Processing Unit'}
]
};
};
Go to SAP Commissions – Payments Workspace and download the csv
db/data/payout-report.csv
Paste your downloaded data from SAP Commissions - Payments Workspace
run cds watch
Click on Open in New Tab
Click on reports to see Json data and Fiori Preview to see the Payments report in UI
you can see the JSON records
Payment Reports on Fiori UI as same as SAP Commissions Payment Workspace
We have the project ready. Now, we will activate the graphQL feature adding this code in the package.json:
This will be the result:
"cds": {
"features": {
"graphql": true
}
}
Install Graphql
npm add graphql express-graphql @graphql-tools/schema
run cds watch
Checking the feature
It’s time to check the results, first of all, when we ejecute the command “cds watch” we will see the following:
GraphQL IDE to review the Payments report data
so everything is fine now, in coming blog you can generate SAP UI5 Fiori App for Sales / Business Users to access and see the Payments report.
Next Part 2 – SAP Commissions – CAP – Consuming Files based – Part 2
Hope you like this blog post ?
Feel free to comment