nocin.eu

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

[ABAP] Z_CLEANUP_LRQ_WORKFLOWS

A cleanup report I’ve written some years ago, to end incomplete leave request workflows. I couldn’t figure out why some workflows hadn’t been completed over the years. Since the absences were from a long time ago, the goal was simply to clean up the system. Maybe someone else will need to do something similar someday.

*&---------------------------------------------------------------------*
*& Report Z_CLEANUP_LRQ_WORKFLOWS
*&---------------------------------------------------------------------*
*& This report was written to end old absence request workflows,
*& where the absence request got already approved,
*& but somehow the WF got not set to status 'COMPELTED'.
*& https://me.sap.com/notes/0002650820
*&---------------------------------------------------------------------*
REPORT z_cleanup_lrq_workflows.

TABLES: ptreq_header, swwwihead, pa0002.

TYPES:
  BEGIN OF ty_log,
    icon          TYPE icon-id,
    objid         TYPE objektid,
    vorna         TYPE vorna,
    nachn         TYPE nachn,
    request_id    TYPE ptreq_header-request_id,
    version_no    TYPE tim_req_version,
    request_type  TYPE tim_req_type,
    status        TYPE tim_req_status,
    mod_timestamp TYPE timestamp,
    timestamp     TYPE string,
    workitem_id	  TYPE sww_wiid,
    wi_stat       TYPE sww_wistat,
    wi_stat_new   TYPE sww_wistat,
    comment       TYPE string,
  END OF ty_log.

DATA gt_log     TYPE TABLE OF ty_log WITH DEFAULT KEY.
DATA return     TYPE TABLE OF swl_return.
DATA new_status TYPE sww_wistat.
DATA status     TYPE ptarq_uia_request-status.

INITIALIZATION.

  SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-b01.

    SELECT-OPTIONS: s_pernr FOR pa0002-pernr              MATCHCODE OBJECT prem,
                    s_guid  FOR ptreq_header-request_id,
                    s_rtype FOR ptreq_header-request_type DEFAULT 'ABSREQ',
                    s_statu FOR status                    DEFAULT 'POSTED',
                    wi_stat FOR swwwihead-wi_stat         DEFAULT 'STARTED'.

    PARAMETERS: fdate  TYPE datum DEFAULT '20180101',
                ftime  TYPE tims,
                tdate  TYPE datum DEFAULT '20231231',
                ttime  TYPE tims,
                p_test AS CHECKBOX DEFAULT abap_true.

  SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

  CONVERT DATE fdate TIME ftime INTO TIME STAMP DATA(ts_from) TIME ZONE 'UTC'.
  CONVERT DATE tdate TIME ttime INTO TIME STAMP DATA(ts_upto) TIME ZONE 'UTC'.

  SELECT a~request_id, a~version_no, a~status, a~request_type, a~mod_timestamp, a~workitem_id, b~objid, c~wi_stat, d~vorna, d~nachn
    FROM ptreq_header    AS a
        JOIN ptreq_actor AS b ON a~initiator_ins = b~actor_id
        JOIN swwwihead   AS c ON a~workitem_id   = c~wi_id
        JOIN pa0002      AS d ON b~objid         = d~pernr
    INTO CORRESPONDING FIELDS OF TABLE @gt_log
    WHERE a~request_id    IN @s_guid
      AND a~status        IN @s_statu
      AND a~request_type  IN @s_rtype
      AND a~mod_timestamp BETWEEN @ts_from AND @ts_upto
      AND b~objid         IN @s_pernr
      AND c~wi_stat       IN @wi_stat.

END-OF-SELECTION.

  LOOP AT gt_log ASSIGNING FIELD-SYMBOL(<log>).

    <log>-timestamp = |{ <log>-mod_timestamp TIMESTAMP = ENVIRONMENT }|.

    IF p_test = abap_true.
      <log>-comment = |Testrun! No workflow changed!|.
      CONTINUE.
    ENDIF.

    IF <log>-wi_stat <> |STARTED|. CONTINUE. ENDIF.

    CALL FUNCTION 'SWL_ADM_WI_COMPLETE'
      EXPORTING
        wi_id                         = <log>-workitem_id
      TABLES
        return                        = return
      EXCEPTIONS
        workitem_not_found            = 1
        no_authority                  = 2
        wrong_workitem_type           = 3
        workflow_definition_not_found = 4
        internal_error                = 5
        action_canceled               = 6
        OTHERS                        = 7.
    IF sy-subrc <> 0.
      <log>-icon    = icon_red_light.
      <log>-comment = COND #( WHEN lines( return ) > 0 THEN return[ 1 ]-text
                                                       ELSE SWITCH #( sy-subrc WHEN 1 THEN |workitem_not_found|
                                                                               WHEN 2 THEN |no_authority|
                                                                               WHEN 3 THEN |wrong_workitem_type|
                                                                               WHEN 4 THEN |workflow_definition_not_found|
                                                                               WHEN 5 THEN |internal_error|
                                                                               WHEN 6 THEN |action_canceled|
                                                                               WHEN 7 THEN |OTHERS| ) ).
    ELSE.
      " Check if WF status really got changed
      SELECT SINGLE wi_stat FROM swwwihead INTO <log>-wi_stat_new WHERE wi_id = <log>-workitem_id.
      <log>-icon    = COND #( WHEN <log>-wi_stat_new <> |COMPLETED| THEN icon_red_light ELSE icon_green_light ).
      <log>-comment = COND #( WHEN <log>-wi_stat_new <> |COMPLETED| THEN |Something went wrong!| ).
    ENDIF.

  ENDLOOP.


  IF gt_log IS INITIAL.
    MESSAGE i002(wusl) DISPLAY LIKE 'E'.
  ELSE.
    TRY.
        cl_salv_table=>factory( IMPORTING r_salv_table = DATA(alv_table)
                                CHANGING  t_table      = gt_log ).

        alv_table->get_columns( )->get_column( 'ICON'          )->set_long_text( 'Icon' ).
        alv_table->get_columns( )->get_column( 'WI_STAT_NEW'   )->set_long_text( 'Neuer WF Status' ).
        alv_table->get_columns( )->get_column( 'WI_STAT_NEW'   )->set_medium_text( 'Neuer Status' ).
        alv_table->get_columns( )->get_column( 'COMMENT'       )->set_long_text( 'Kommentar' ).
        alv_table->get_columns( )->get_column( 'TIMESTAMP'     )->set_long_text( 'Letzte Änderung' ).
        alv_table->get_columns( )->get_column( 'COMMENT'       )->set_output_length( 100 ).
        alv_table->get_columns( )->get_column( 'TIMESTAMP'     )->set_output_length( 20 ).
        alv_table->get_columns( )->get_column( 'MOD_TIMESTAMP' )->set_visible( abap_false ).

        alv_table->display( ).

      CATCH cx_root.
    ENDTRY.
  ENDIF.

[ABAP] Display CL_BAL_LOGOBJ output as ALV in a splitcontainer

When developing a report that should also write logs (SLG1), I normaly use the class CL_BAL_LOGOBJ as described here. When using method lo_log->display( ) it displays the result in a popup. If you want to display the log as ALV some more logic is neede.

DATA ls_display_profile TYPE bal_s_prof.

TRY.
    DATA(lo_log) = NEW cl_bal_logobj(
      i_log_object        = 'Z_MY_LOG'
      i_default_subobject = 'GENERAL' ).

    lo_log->add_statustext( i_statustext = 'Processing started' ).

    lo_log->add_errortext( i_errortext = 'An error occurred during processing' ).

    CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
      IMPORTING
        e_s_display_profile = ls_display_profile.

    ls_display_profile-use_grid = abap_true.

    lo_log->display( i_disp_profile = ls_display_profile ).

  CATCH cx_bal_exception INTO DATA(lx_bal).
    MESSAGE lx_bal->get_text( ) TYPE 'I'.
ENDTRY.

In my case, I wanted to display the log next to the actual output of a report, so that I have my data result on the left side, and the application log on right side.

*--------------------------------------------------------------------*
* Create Split Container
*--------------------------------------------------------------------*

    " Create a splitter on default_screen
    DATA(o_splitter_main) = NEW cl_gui_splitter_container( parent                  = cl_gui_container=>default_screen
                                                           no_autodef_progid_dynnr = abap_true
                                                           rows                    = 1
                                                           columns                 = 2 ).

    " Width of left splitter in %
    o_splitter_main->set_column_width( id = 1 width = 75 ).

    " Get the ref from the left and right split containers
    DATA(o_container_1) = o_splitter_main->get_container( row = 1 column = 1 ).
    DATA(o_container_2) = o_splitter_main->get_container( row = 1 column = 2 ).

*--------------------------------------------------------------------*
* 1 ALV Output
*--------------------------------------------------------------------*

    TRY.
        cl_salv_table=>factory( EXPORTING r_container  = o_container_1
                                IMPORTING r_salv_table = DATA(o_salv)
                                CHANGING  t_table      = lt_sflight).
        o_salv->display( ).

      CATCH cx_salv_msg.
      CATCH cx_salv_not_found.
    ENDTRY.

*--------------------------------------------------------------------*
* 2 BAL Log
*--------------------------------------------------------------------*

    DATA ls_display_profile TYPE bal_s_prof.
    DATA lv_control_handle  TYPE balcnthndl.

    DATA(lt_log_handles) = VALUE bal_t_logh( ( mo_log->if_bal_logger~mv_loghandle ) ).

    CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
      IMPORTING
        e_s_display_profile = ls_display_profile.

    ls_display_profile-use_grid = abap_true.

    " Increase the width of the message text column
    LOOP AT ls_display_profile-mess_fcat ASSIGNING FIELD-SYMBOL(<ls_fcat>)
         WHERE ref_table = 'BAL_S_SHOW'
           AND ref_field = 'T_MSG'.
      <ls_fcat>-outputlen = 200.
    ENDLOOP.

    CALL FUNCTION 'BAL_CNTL_CREATE'
      EXPORTING
        i_container          = o_container_2
        i_s_display_profile  = ls_display_profile
        i_t_log_handle       = lt_log_handles
      IMPORTING
        e_control_handle     = lv_control_handle
      EXCEPTIONS
        profile_inconsistent = 1
        internal_error       = 2
        OTHERS               = 3.

  ENDMETHOD.

*--------------------------------------------------------------------*
*  Force output
*--------------------------------------------------------------------*
    WRITE: space.

I really like the result

[Docker] Portainer → Dockhand

I have been using Portainer for about 6 or 7 years. Recently the company announced version 3.0, a rebuild of the platform around Kubernetes, and that there will be no community version of it. Although version 2 will still get fixes and backports when possible, I took the opportunity to try something new. Especially since I’m not interested in Kubernetes and this seems to be the focus of Portainer from now on. For quite some time I already had Dockhand in my bookmarks, but never took a close look. I launched a container and have to say, the user experience is similar to Portainer’s, it even feels a bit cleaner and has a few more features. The setup just took a few minutes and everything was working out of the box. Great!

services:
  dockhand:
    image: fnsys/dockhand:v1.0.54
    container_name: dockhand
    restart: unless-stopped
    environment:
      - DATA_DIR=/opt/dockhand
    volumes:
      - /opt/containers/dockhand/data:/opt/dockhand
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/containers:/opt/containers           # this path is added to access local docker-compose.yml files, created outside dockhand
    group_add:
      - "988"
    networks:
      - proxy

networks:
  proxy:
    external: true

[Firefox] Freezes computer

For the past few weeks, my computer was randomly freezing for about 30 seconds. After a quick search, it became clear that it was a memory issue, even though my computer has over 32 GB of RAM…

> journalctl -k -b -o short-precise

Sep 23 09:39:38.873173 myPC systemd-journald: Under memory pressure, flushing caches.
Sep 23 09:39:41.632171 myPC systemd-journald: Under memory pressure, flushing caches.
Sep 23 09:39:44.072486 myPC systemd-journald: Under memory pressure, flushing caches.
Sep 23 09:39:50.630124 myPC systemd-journald: Under memory pressure, flushing caches.
Sep 23 09:40:18.142581 myPC kernel: upowerd invoked oom-killer: gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0, oom_score_adj=0

> journalctl -k -b --since "2026-09-23 09:39:30" --until "2026-09-23 09:41:30" \
  | grep -iE 'oom|killed process|kill process|out of memory|memory cgroup'

Sep 23 09:40:18 myPC kernel: oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/session-c2.scope,task=Isolated Web Co,pid=2666576,uid=1000
Sep 23 09:40:18 myPC kernel: Out of memory: Killed process 2666576 (Isolated Web Co) total-vm:10469216kB, anon-rss:7162184kB, file-rss:196kB, shmem-rss:1752kB, UID:1000 pgtables:54092kB oom_score_adj:200

As it turned out, the problem was caused by Firefox (Killed process Isolated Web Co). Fortunately, the solution was quite simple. I enabled the unloadOnLowMemory setting:

about:config → browser.tabs.unloadOnLowMemory →true

Since then, everything is running normal again. I also tried to identify a specific extension or website, which needed too much memory via

about:processes

about:memory

but it was nothing out of the ordinary. I guess I just had too many Firefox windows and tabs open…

[Nextcloud] OnlyOffice to Euro-Office

A fork of OnlyOffice called Euro-Office has been available for a few months now. Since it seems that many users are switching to this new solution, I decided to test it out for a while as well. Since I don’t use Nextcloud AIO, I had to manually set up a separate Euro-Office instance.

The setup was straightforward. Create a docker-compose.yaml and a .env for your 32 character long JWT secret, and then start the service with docker compose up -d.

services:
  documentserver:
    image: ghcr.io/euro-office/documentserver:latest
    container_name: euro-office-documentserver
    restart: unless-stopped
    environment:
      EXAMPLE_ENABLED: "false"
      JWT_SECRET: ${JWT_SECRET}
    networks:
      - proxy

networks:
  proxy:
    external: true

Add the new service to your reverse-proxy. In my case, I still wanted to keep my OnlyOffice setup, in case I want to go back, so I first created a new subdomain. After about 3h, the new created A record for my subdomain was working.

The only problem I had, was that I could not find “Nextcloud Office” in the Apps list via the Nextcloud Web Interface. Perhaps because I’m still on Nextcloud Version 33.0.9 and Nextcloud 34 is listed as prerequisite in the docs. Therefore, I had to install it via command line.

docker exec --user www-data nextcloud-app php occ app:install eurooffice

It installed the latest Version 11.0.5.

After that, simply add your URL and JWT Secret in the settings.

Everything was working immediately. Great!

One nice thing I already noticed, you can edit files on your mobile phone again. This feature had been restricted at some point in OnlyOffice.

[Firefox] Tab-Container für Fiori Launchpad

Seit Firefox 153 werden die Tab-Container standardmäßig unterstützt und machen die Erweiterung Firefox Multi-Account Containers überflüssig. Das ist besonders praktisch, wenn man häufiger mit Web-Anwendungen arbeitet, bei denen man verschiedene Benutzer testen muss. Da ich viel mit Fiori Apps und Workflows zu tun habe, muss ich hier häufig mit 3 oder 4 Benutzern abwechselnd testen, um einen Workflow vom Antrag bis zur Genehmigung durchzuspielen. Dafür habe ich mir nun einfach 4 Tab-Container definiert und kann mich in jedem Container mit einem separaten User am Fiori Launchpad anmelden. Super praktisch!

Eine vergleichbare Funktion konnte ich für Edge oder Chrome bisher nicht finden. Hier ist man meist auf das normale Fenster + ein privates Fenster beschränkt. Leider steht in den IT-Landschaften der Kunden Firefox immer seltener zur Verfügung …

[Pi-hole] New instance and blocklists

I’ve been using Pi-hole for more than 8 years now. In all that time, I haven’t had a single problem with the software itself or with updates. The only annoyance was that I only had one instance, and I couldn’t use the internet properly while updating my Proxmox host or the LXC container where Pi-hole was running. That’s why I’ve now installed a second Pi-hole instance on my TrueNAS server. Originally, I didn’t really want to run any additional software on my NAS, but since installation with TrueNAS Scale is so easy and my NAS has nearly 100% uptime throughout the year, it makes sense.

After setting up and importing the configuration from my primary Pi-Hole instance via Teleporter I checked if there are any new relevant blocklists. I listed my used blocklists in an earlier post here. Of course, I’ve added a few more lists over the past few years, but I never updated that post. I found the following helpful repository

https://github.com/hagezi/dns-blocklists

And also this site to test the blocking, but not sure how meaningful the result is…

https://superadblocktest.com

As last step, I added my second Pi-hole instance as alternative DNS-Sever in my FritzBox.