Skip to Content
Event Information

Annotated links: Episode 10 of Hands-on SAP dev with qmacro

This is a searchable description of the content of a live stream recording, specifically “Episode 10 – Finishing off the data retrieval mechanism in Node.js” 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 “Finishing off the data retrieval mechanism in Node.js“, was streamed live on Thu 07 Mar 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

Following the previous episode there’s a bit more work to do to finish off the data retrieval mechanism we have been building to extract data from the original Northwind service and turn it into CSV files that can be loaded into a persistence layer with cds deploy. In this episode we finish this off and load the data.

00:02:20: Remembering where we left off, which was just having loaded the Categories CSV file into Northbreeze, and we have a northbreeze.db command from the use of the cds deploy invocation. Thinking also about what we have to do from a CSV column header perspective to make the navigation property relationships work “underneath”.

00:04:55: Looking at the data definitions in the persistence layer with the sqlite3 “.dump” command, and noticing how the entities are related via the “_ID” suffixed property names (supplier_ID and category_ID).

00:07:30: We see that this is similar in the Northwind service, when we look at the properties available in the Products entityset.

00:08:08: Re-attaching to the tmux session we had yesterday, with tmux a, and behold, all our work is still there ready for us to continue. Terminal multiplexers ftw!

00:08:30: Showing that you can zoom a tmux pane to expand to the entire window size with the prefix key + ‘z’ (for “zoom”). By default the prefix key is set to Ctrl-b, but I’ve set it to Ctrl-a as I find that an easier key combination to type. So “Ctrl-a z” will zoom a pane to full window size, and that same combination will toggle it (un-zoom it) back again.

00:10:02: Using the Vim plugin Nerdtree to explore the directory structure and find the file I’m looking for, which is the model.cds file, so I can have that as reference when I’m filling out the configuration in the entities map in the grab.js script.

I toggle Nerdtree with a key combination in Vim, specifically with this configuration:

nnoremap <leader>n :NERDTreeToggle<cr>

See my Vim config in the dotvim repository on GitHub for more details.

00:15:15: The default cds command is “compile”, but we can also invoke it explicitly, which we do, to check what data definition language (DDL) statements will be generated for the service:

cds compile srv --to sql

00:17:15: Disabling the Ctrl key on my keyboard to try and force myself to use the CapsLock key which I’d previously redefined to work as a Ctrl key. I think this trips me up later on, but hey. (Update: it does!)

00:18:55: Accidentally discovering a Ranger feature, which is that if you select multiple files (with space, for example), selecting one of them (with “l”, to go “right” into it) will open up the default handler for that file type, which in this case is my editor Vim, but it will open up Vim for all selected files, which means I can then navigate between then in Vim. Nice!

00:20:30: We replace the value of the base URL with the real Northwind service URL in grab.js, so that the real and final execution of the script uses Northwind rather than our saved data files.

00:23:30: Triggered by a comment by Nabheet we look at a Tweet thread on ABAP editor nostalgia, remembering how I edited ABAP in the late 1980’s when it first appeared on the scene, and wondering whether we’ll ever see ABAP being edited in Vim, via a language server implementation. Gosh!

00:25:32: Creating a new window in tmux and copying the CSV files we’ve just generated with the grab.js script into the db/csv/ directory in our Northbreeze project.

00:26:30: Someone at the door! Announced (and displayed) on my Google Home Hub via the Nest Hello device in the porch.

00:27:40: Using the Vim keybinding approach to rename files in Ranger, and there’s also a “mass rename” feature, which I couldn’t remember how to use at the time, but it’s described here: Bulk renaming.

Now we have the CSV files renamed to follow the convention that says the names should be <namespace>-<Entityname>.csv.

00:30:55: Using cds deploy to have the CSV data loaded into the persistence layer. We don’t need to specify the --to sqlite:northbreeze.db option as that detail has already been saved in the package.json file from a previous invocation.

00:32:20: Using cds run to start the service, where we can successfully see only the metadata document, including the navigation properties that are a result of the associations we’ve defined in model.cds. Lovely!

00:36:32: Looking at the data too, in the Categories, Suppliers and Products entitysets, which is now available as it’s been loaded into the persistence layer, from the CSV files, in the cds deploy activity.

00:37:55: Trying some OData query options, such as these:

http://localhost:4004/breezy/Categories?$expand=products
http://localhost:4004/breezy/Suppliers?$expand=products

and also

http://localhost:4004/breezy/Products?$select=name,discontinued

… where we discover something odd about the values of the discontinued property: they are all set to true, which is not correct (we double check this by looking at the “same” query on the original Northwind service: https://services.odata.org/V3/Northwind/Northwind.svc/Products?$format=json&$select=Discontinued.

00:40:40: Looking at the persistence layer, we can see that the values in the database are actually correct (i.e. we have some false values for the discontinued property).

We leave it there, on this exciting cliffhanger! What is up with the discontinued property values? Let’s find out soon!

Be the first to leave a comment
You must be Logged on to comment or reply to a post.