Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
qmacro
Developer Advocate
Developer Advocate
This is a searchable description of the content of a live stream recording, specifically "Episode 23 - Digging in to the sitregcapm project" in the "Hands-on SAP dev with qmacro" series. There are links directly to specific highlights in the video recording. For links to annotations of other episodes, please see the "Catch the replays" section of the series blog post.

This episode, titled "Digging in to the sitregcapm project", was streamed live on Fri 03 May 2019 and is approximately one hour in length. The stream recording is available on YouTube.



Below is a brief synopsis, and links to specific highlights - use these links to jump directly to particular places of interest in the recording, based on 'hh:mm:ss' style timestamps.

Brief synopsis


In this episode we take a closer look at the project to rewrite the SAP Event Registration app backend using CAP, in the form of the sitregcapm repo on GitHub.

00:02:01: Highlighting another live streamer, David Poindexter, who goes by the moniker roberttables on Twitch. It turns out that I've highlighted Robert before, in Ep.20, but anyway, David is definitely someone you should follow on Twitch for all sorts of hardware and software activities.

00:04:15: Along the same theme of "re-highlighting", I also point out the list Awesome Developer Streams which is full of lovely folks who stream on development topics.

00:05:10: Mentioning my colleague mariusobert and his great Cloud Foundry Fun series. While I do this, gregorw suggests that the ABAP topic is missing from the list of streamers! He's right. I think it would be awesome to see. Who's up for it - any volunteers? I can definitely help folks get set up for streaming, having gone through the process myself. But also, if you would just to come on as a guest here and show us some cool ABAP stuff, I'd love to host you - let me know!

00:08:12: Looking briefly at SAP Fiori Fundamentals, a light-weight presentation layer for building Fiori apps in any web-based technology. The team run office hours which are regular live sessions, the recordings of which are available on YouTube. Worth a visit!

00:09:42: Next we turn our attention to some really exciting news from the VS Code team, in a tweet highlighted by rsletta just before we started this stream. It's now possible to use a Docker container (or remote SSH host) with a local copy of VS Code. I think this is pretty darn good and a great set of facilities for an already very accomplished IDE.

00:11:30: This is definitely something worth looking into now, even for a quick peek. So that's what we do. Looking at the page linked from the tweet, we see it's the location in the Visual Studio Marketplace for this Remote Development extension.

00:13:50: This extension preview requires the insiders version of VS Code, so I'd blasted away my standard installation ready for this version instead. (I could have run both versions side by side, but I had been having some issues with one of the extensions (for SQLite) anyway so a clean reinstall couldn't harm, I figured).

00:14:30: Installing the insiders version of VS Code, before attempting to install the Remote Development extension pack.

00:15:00: Looking briefly at my Docker setup, in particular the images I have for CAP development and testing.
=> docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
cap latest 35042912625f 5 days ago 365MB
debiancap latest a8fd0c3eb330 5 days ago 293MB
node 10 64c810caf95a 5 weeks ago 899MB
node lts 64c810caf95a 5 weeks ago 899MB
debian latest a0bd3e1c8f9e 3 months ago 101MB

Here's what I have in my Dockerfile for building the "debiancap" image:
FROM debian
MAINTAINER DJ Adams dj.adams@sap.com

RUN apt-get update && apt-get install -y \
ranger \
unzip \
curl \
git \
vim

This means I can start a level slightly higher than the base Debian install, with tools that I use all the time.

On top of that I have another Dockerfile to create the "cap" image:
FROM debiancap
MAINTAINER DJ Adams dj.adams@sap.com

RUN rm /bin/sh && ln -s /bin/bash /bin/sh

RUN groupadd -g 999 user && \
useradd -m -r -u 999 -g user user
USER user

WORKDIR /home/user

COPY installcds .
COPY bashrc_additions .
RUN cat bashrc_additions >> .bashrc

RUN mkdir /home/user/.nvm
ENV NVM_DIR /home/user/.nvm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash \
&& source $NVM_DIR/nvm.sh \
&& nvm install --lts

00:17:45: I can then instantiate an instance of the "cap" image - a container - with:

docker run -it cap


00:19:54: Having fired up the newly installed "insiders" version of VS Code I attempt to install the Remote Development extension, but this doesn't work. It seems that the link behind the big green "Install" button is a custom one, that looks like this:
vscode:extension/ms-vscode-remote.vscode-remote-extensionpack

It looks like standard VS Code, and not the "insiders" version, is set up on my machine to handle this sort of link.

00:21:11: So we take an alternative route and download the extension. We know this route as we've used it before when installing the CDS Language Support for Visual Studio Code.

00:22:24: As I ramble on about bit rates, Gregor suggests we follow the "Trouble Installing" link but that doesn't give us any immediate clues that seem relevant. Not to worry though as the install-from-downloaded-VSIX file is something that I think will work.

As we look at this documentation we spot how extensions can be installed from the command line; moreover, we've seen this before when Ronnie tooks us through his dotfiles - I remember glimpsing it when I was browsing through the macOS.sh file, specifically lines 91-102. Nice!

00:24:05: Looking briefly at some short (some one-liner!) scripts I've created in a new .scripts/ directory, including drmexited, rdminone, dsession and genannopost.

00:26:35: Installing the extension with:

code-insiders --install-extension ~/Desktop/ms-vscode-remote.vscode-remote-extensionpack-0.12.0.vsix


And it worked! (We also see some of my older extensions in there, perhaps from the previous VS Code install).

00:28:10: Now the extension pack is installed, we have a new feature in the bottom left corner of VS Code with which we can ... "attach to running container"!

We start up an instance of the "cap" image (a container) but have an initial issue as that image sets up a non-root user (see the USER command in the Dockerfile earlier). So we fire up an instance of the standard "debian" image to try instead ... successfully. We create a directory (banana) inside the container and can see it in VS Code. Result!

00:31:18: Jumping now to looking at the sitregcapm repository on GitHub, in the "sapmentors" namespace. This is a project initiated by Gregor as a rewrite of the backend for the SAP Inside Track registration and management app suite. A rewrite from HANA XS Classic to the Application Programming Model - as the description states: "SITreg implemented in the SAP Cloud Application Programming Model".

00:33:00: We take a quick look at one of the frontends for this suite, to contextualise the app backend, specifically the SAP Event Organiser app.

00:37:18: We clone the repository and start looking at it in VS Code, for an initial exploration of the contents - including the .vscode/ directory and the two "usual suspects" .db/ and .srv.

00:39:25: We look at the CSV files and notice that a couple have been "commented out" in that the extension has been changed to xcsv. It looks like these files are to contain the localised values of texts, as they each end in _texts.

00:41:27: Looking at more details of the repository we see that there are already six contributors so far - Gregor Wolf, Nabheet Madan, Balbino Soares, Christian Lechner, Mark Teichmann and mattiastrr.

But I guess the main point of the focus on this repository is that it deserves more love, and contributors. It would be great if you could get involved, clone the repository, start having a poke around, and make your first contribution. There's a #sitregdiscussion channel on the SAP Mentors & Friends Slack workspace - head on over there (you can register here if you need to) and say hi.

00:43:50: Noting the pairs of cds and js files in the srv/ directory, where there's an accompanying custom implementation file paired with each service definition. Turns out there's no custom implementation just yet ... but the project is still young.

00:47:16: Looking briefly at the .cdsrc.json file, which is part of the hierarchy (or precedence order) of configuration. Think of this file as at the bottom of the stack (i.e. the least significant), where you have the following cascading locations (higher in this stack overrides levels beneath):
Command line parameters
Environment variables
`package.json`
`.cdsrc.json`

00:50:20: Having a quick look at the errors that currently are highlighted in the data-model.cds file ... this is because we haven't yet installed anything inside this project! This means that we don't have a node_modules/ directory which is where @Sap/cds/common.cds lives of course, as we know from a couple of earlier episodes in this series.

00:51:15: So we start to perform the installs, with npm install. Looking in the package.json file we see this:
  "dependencies": {
"@sap/cds": "^3.5.2",
"express": "^4.16.4"
},

and we head off for a short digression into semantic versioning with NPM.

00:55:23: One thing we haven't seen so far is the use of enumerations, which are used here in the type definitions:
type URL            : String(256);
type HashT : Binary(32);
type AnswerOption : Integer enum { yes = 1; no = 2; maybe = 3; };
type DeviceT : String(36);
type TicketUsedT : String(1) enum{ YES = 'Y'; NO = 'N'; };
type ActiveT : String(1) enum{ YES = 'Y'; NO = 'N'; };
type PrintStatusT : String(1) enum{ QUEUED = 'Q'; SENT = 'S'; PRINTED = 'P' };

You can find out more about enumerations (Enums) in the Elements and Types of the SAP Help Portal.

Triggered by a question from Gregor, we look briefly again into how the cds command line bootstraps the CDS core - bringing in a local version if present, and falling back to a globally installed version otherwise. That is why here, while I have version 3.7.1 installed globally, 3.5.2 is installed locally to this project, which means that when I run cds version inside the sitregcapm project directory, I get this:
@sap/cds: 3.5.2
@sap/cds-compiler: 1.8.1
@sap/cds-ql: 1.5.1
@sap/cds-hana: 1.5.1
@sap/cds-sql: 1.5.1
@sap/cds-sqlite: 1.5.1
@sap/cds-reflect: 2.3.0
@sap/cds-services: 1.5.2
@sap/odata-server: 1.0.0
@sap/odata-commons: 1.0.0
@sap/generator-cds: 2.3.9
CDS home: /private/tmp/sitregcapm/node_modules/@sap/cds

And that about wraps it up for this episode - the time went very quickly! Until the next time, happy hacking!