Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[SAPUI5] Formatting numbers

https://experience.sap.com/fiori-design-web/formatting-numbers/#usage
https://sapui5.netweaver.ondemand.com/sdk/#/topic/91f3145e6f4d1014b6dd926db0e91070
a few examples: https://github.com/brooklynb7/HTML5/blob/master/sapui5-dist-static/test-resources/sap/ca/ui/demokit/explored/views/type/number.view.xml

<ObjectListItem 
title="{income>Month}" 
number="{ model : 'income', path : 'Cost', type: 'sap.ui.model.type.Integer', formatOptions: {groupingEnabled: true} }"
numberUnit="EUR" />

[SAPUI5] Deploying the ui5 sample app on debian

I’m deploying the openui5-sample-app to a Linux Container running Debian Buster. First update the packages and install Node.js.

apt update && apt upgrade -y
apt install curl -y
curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt install nodejs -y
nodejs --version

Install PM2 (process manager to manage Node.js applications) and the UI5 Tooling

npm install pm2 -g
npm install --global @ui5/cli

Now clone the openui5-sample-app and build it

apt install git
git clone https://github.com/SAP/openui5-sample-app.git
cd openui5-sample-app/
ui5 build -a
cd ..

Run your project on port 8000. With “startup” it will automatically create a systemd script.

pm2 serve openui5-sample-app/dist/ 8000
pm2 startup
pm2 save
systemctl start pm2-root
systemctl status pm2-root

[SAPUI5] local ui5 development

1. Install node.js

2. Install UI5 Tooling

npm install --global @ui5/cli

3. Install Easy UI5 Generator, create a project and run it on your localhost

npm install -g yo generator-easy-ui5
yo easy-ui5
cd <your project name> 
npm start

4. Set up a Github project and do your initial push

git add .
git commit -m "Initial commit"
git remote add origin https://github.com/user/myUI5App.git 
git push origin master

5. Install your favorite Editor, e.g. Visual Studio Code or Atom, and open your project to edit it

[SAPUI5] Versioning

SAPUI5 follows Semantic Versioning.

MAJOR.MINOR.PATCH (e.g. 1.71.9)

  • Patches are mostly bug fixes.
  • Minor releases bring new features.
  • Major contains incompatible API changes.

Version overviews:
https://sapui5.hana.ondemand.com/versionoverview.html
https://openui5.hana.ondemand.com/versionoverview.html

Find detailed patchinfos here:
https://sapui5.hana.ondemand.com/X.XX.X/patchinfo.html (where X.XX.X is the SAPUI5 version number)
https://openui5.hana.ondemand.com/X.XX.X/patchinfo.html (where X.XX.X is the OpenUI5 version number)

Note: “sap.ui.core and sap.m are special, because they are OpenUI5 libraries. Currently, OpenUI5 libraries are always released as a whole. This means that whenever there is a change to be released for any of the OpenUI5 libraries, the new patch includes them all.”

[ABAP] Calculation

* ab ABAP 7.54
DATA field TYPE p decimals 2.

field += 4.
field -= 2.
field *= 3.
field /= 2.

*obsolet: ADD, SUBSTRACT, MULTIPLY, DIVIDE

[ABAP] Alpha conversion

DATA(lv_matnr) = VALUE matnr( 0000000001 ).
DATA(character_string) = VALUE string( ).

character_string = |Your Material Number is { lv_matnr ALPHA = IN }|.    "Adds leading zeros
character_string = |Your Material Number is { lv_matnr ALPHA = OUT }|.   "Removes leading zeros

[ABAP Env] Create Data Model & OData Service

Recently I worked through the tutorial on creating a travel bookings app in the SAP Cloud Platform ABAP Environment.

Find a good introduction and overview on this topic here: Getting Started with ABAP in the Cloud – Part I
And the travel bookings app tutorial here: Getting Started with ABAP in the Cloud – Part II

These are my notes on the steps needed to create the data model and publish it as oData service.

#LayerNomenclatureDescription
1Database TableZTABLEPlace your raw data first
2Data Definition (Interface View)ZI_Relation between different tables (e.g. currency or text table)
3Projection View (Consumption View)ZC_Configure the UI depending on your scenario.
Use different projection views for different usages of the same interface view and the same physical table.
4Service DefinitionZSD_Expose the projection view (and underlying associations like currency, country…) as service
5Service BindingZSB_How to we want to make the service available? Defines the binding type (OData V2 / OData V4)
Activate it with the “Activate” Button within the editor window.
Select the Entity and hit “Preview…” to see whtat we defined in our projection view.

If you’ve done this, you are able to view the data in a generated Fiori Elements app. But if you also want to create, edit, delete data, you’ll have to add some behavior functionality.

6Behavior Definition on Data DefinitionZI_Created on top of the Data Definition. Will get the same name es the Data Definition.
Implementation Type: Managed
Defines the operations create, delete, edit.
7Behavior Implementation on Definition ViewZBP_I_The code for the behavior… For the travel app tutorial, some logic for a generated unique key and field validation.
The class inherits from cl_abap_behavior_handler.
8Behavior Definition on Projection ViewZC_Created on top of the Projection View. Will get the same name es the Projection View.
Defines the operations create, delete, edit.

[ABAP] Select-Option for ALV Layout

Create a ALV Layout Variant
Select-Option for Layout Variant on Selectionscreen
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-b03.
PARAMETERS: p_vari TYPE slis_vari.
SELECTION-SCREEN END OF BLOCK b3.

INITIALIZATION.

  "Load default layout
  DATA: ls_layout TYPE salv_s_layout_info,
        ls_key    TYPE salv_s_layout_key.

  ls_key-report = sy-repid.

  ls_layout = cl_salv_layout_service=>get_default_layout( s_key    = ls_key
                                                          restrict = '1' ).
  p_vari = ls_layout-layout.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.

  "Value Help
  DATA: ls_layout TYPE salv_s_layout_info,
        ls_key    TYPE salv_s_layout_key.

  ls_key-report = sy-repid.

  ls_layout = cl_salv_layout_service=>f4_layouts( s_key    = ls_key
                                                  restrict = '1' ).
  p_vari = ls_layout-layout.

[ABAP] Fill table rows into range table

DATA(pernrs) = VALUE pernr_tab( ( |00000001| )
                                ( |00000002| )
                                ( |00000003| ) ).

DATA(lr_pernr) = VALUE cchry_pernr_range( FOR pernr IN pernrs ( sign   = 'I'
                                                                option = 'EQ'
                                                                low    = pernr
                                                                high   = '' ) ).
"Append row to range

APPEND VALUE #( option = 'EQ'
                sign   = 'I'
                low    = pernr ) TO lr_pernr.