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

[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.

[Docker] Usefull commands

Image Handling

docker image listlist downloaded images
docker rmi image_namedelete image

Administration

docker system dfshow docker disk usage
docker system prunefree space – remove stopped containers, images, cache
systemctl restart docker.servicerestarts the docker service (and all your container)
ss -tulpncheck if docker containers listen to any port
docker exec contaienr_id cat /etc/hosts
or
docker inspect -f ‘{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ contaienr_id
check container ip address

Container Handling

docker pslist running containers
docker ps -alist all the docker containers (running and stopped)
docker stop container_idstop container
docker rm container_iddelete stopped container
docker update –restart=unless-stopped container_idmake sure container re-start, unless manually stopped
docker run -l debug container_idrun container with log
docker logs -f container_iddisplay log
docker exec -it container_id /bin/shopen a shell in the running container
docker commit container_id user/test_imagethis command saves modified container state into a new image user/test_image
docker run -ti –entrypoint=sh user/test_imagerun with a different entrypoint
docker run –volume-driver=nfs container_idmount NFS share

Docker Compose

docker-compose -f ~/docker/docker-compose.yml up -d The -d option daemonizes it in the background
docker-compose -f ~/docker/docker-compose.yml down completely stop and remove containers, images, volumes, and networks (go back to how it was before running docker compose file)
docker-compose -f ~/docker/docker-compose.yml pullPull latest images
docker-compose logs container_id check real-time logs
docker-compose stop container_id stops a running container
docker-compose configtest your.env file which is used for variable substitution in the docker-compose.yaml

[Shell] User and Group management & File permissions

  • User and Group management
    • id
    • useradd
      • -c – Full name
      • -e – Expiration date
      • -s – Default shell
      • -d – Home directory
    • passwd
    • usermod
      • -l – rename
      • -L – Lock
      • -U – unlock
    • userdel
      • -r – remove user data
    • groupadd
    • groupmod
    • gpasswd [-a -d -A] [user1, user2] [group]
    • newgrp [group]
  • su vs. su – vs. sudo
    • visudo
  • File permissions
    • UGO – User, Group, Other
    • RWX – Read, Write, Execute
    • chmod -R g+x (grant recursive execute permission to group)
      • r = 4
      • w = 2
      • x = 1
      • = 0
      • rwxrwxrwx = 777
      • rw-rw-rw- = 666
      • rwxrwxr–- = 774
      • rw-rw—- = 660
      • rw-r—–- = 640
    • chown
    • chgrp
    • umask

https://www.sluug.org/resources/presentations/2020/2020-02-12_permissions.pdf