nocin.eu

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

[Firefox] Handy shortcuts I’ve learned recently

Over the past few months, I’ve picked up a few handy Firefox tricks.

Address Bar

  • Find open tabs: Press Ctrl + L (or Ctrl + T) to focus the address bar, then type @tabs or %, hit space, and start typing the tab’s name.
  • Search browsing history: Press Ctrl + L, type @history, hit space followed by your search term.
  • Duplicate the current tab: Focus the address bar with Ctrl + L, then press Ctrl + Shift + Enter. (It opens the same page in a new tab, but without keeping the original tab’s history.)

Tab Management

  • Quickly duplicate a tab: Hold Ctrl and drag a tab to another spot on the tab bar, or just middle‑click the refresh button.
  • Select multiple tabs: Use Ctrl + click to select specific tabs, or Shift + click to select a whole range.
  • Move selected tabs to a new window: After selecting tabs, simply drag them out of the tab bar.

[SAPUI5] Create app with full screen width / full screen layout

https://experience.sap.com/fiori-design-web/full-screen/

https://stackoverflow.com/questions/55832369/how-to-disable-or-enable-letterboxing-and-adjust-ui5-for-the-widescreen/56137602

Simply add appWidthLimited:false in your index.html

		<script>
			sap.ui.getCore().attachInit(function() {
					new sap.m.Shell({
						appWidthLimited:false,
						app: new sap.ui.core.ComponentContainer({
							height : "100%",
							name : "my.demo.app"
						})
					}).placeAt("content");
				);
			});
		</script>

[ABAP] Debugging as other user

Imagine the following situation:

USER_A: Allowed to run a specific report, but not allowed to debug
USER_B: Is allowed to debug

In such a case, you can do the following:

  • USER_B: Sets external breakpoint for USER_A
  • USER_A: Enters the following in the command field: /hext user=USER_B
  • USER_A: Starts his report
  • USER_B: Debugger will be opened

If you check SY-UNAME in the debugger, it will have the value USER_A

[Fiori] Creating a Launchpad Plugin using BAS

Since there is no Wizard anymore for creating a Launchpad Plugin, as there was in WebIDE, you have to create it manually. The following two guides helped me create a Launchpad Plugin in BAS from scratch:
https://github.com/SAP-samples/fiori-custom-plugin-abap/tree/main
https://github.com/SAP-samples/launchpad-service-samples
In my scenario, I had to deploy to a normal S/4 HANA system, so I skipped all the Steampunk or WorkZone parts.

In the first sample, for some reason they use jQuery to call an OData Service, in the second sample no OData is called at all. But of course, an OData Service can be used in a Plugin the same way as you do in every other Fiori App. You just have to add your service in the manifest.json like you would normally do:

  "sap.app": {
    ...
    "dataSources": {
      "ZFLP_TEST_SRV": {
        "uri": "/sap/opu/odata/sap/ZFLP_TEST_SRV",
        "type": "OData",
        "settings": {
          "odataVersion": "2.0",
          "localUri": "localService/metadata.xml"
        }
      }
    }
  },
  ...
  "sap.ui5": {
    ...
    "models": {
      "": {
        "dataSource": "ZFLP_TEST_SRV",
        "preload": true,
        "settings": {
          "defaultCountMode": "Inline",
          "metadataUrlParams": {
            "sap-documentation": "heading"
          }
        }
      }
    }

And for i18n

  "sap.ui5": {
     ...
    "models": {
      "i18n": {
        "type": "sap.ui.model.resource.ResourceModel",
        "settings": {
          "bundleName": "ne.flp.plugin.flp_my_plugin.i18n.i18n"
        }
      }
    }

To activate the deployed Plugin, use these transactions:

  • /ui2/flp_conf_def → Define FLP Plugins → Create new entry
  • /ui2/flp_sys_conf → Make Plugin available system-wide
  • /ui2/flp_cus_conf → Make plugin available in specific clients
  • /ui2/flp → open Fiori Launchpad to test plugin

[CAP] Parses a string in CQL expression and add it as WHERE condition

https://cap.cloud.sap/docs/node.js/cds-compile#cds-parse-xpr

Some examples:

// equal
cds.parse.xpr (`lastName = 'Naidoo'`)

// or
cds.parse.xpr (`lastName = 'Naidoo' or firstName = 'Verónica'`)

// in
cds.parse.xpr (`lastName IN ('Naidoo','González Esteban')`) 

How to add an expression as where condition:

    srv.before('READ', EntityName, async req => { 

        const cxn  = cds.parse.xpr (`lastName = 'Naidoo'`) 

        req.query.SELECT.where ??= []
        if (req.query.SELECT.where.length > 0) {
            req.query.SELECT.where.push("and")
        }
        req.query.SELECT.where.push(...cxn)

    })

[ABAP] Get MOLGA for PERNR

" Option 1
TRY.
    cl_hrpa_masterdata_factory=>get_read_molga( IMPORTING read_molga = DATA(lr_molga) ).
    DATA(molga) = lr_molga->read_molga_by_pernr( pernr ).
  CATCH cx_hrpa_violated_assertion.
ENDTRY.

" Option 2
TRY.
    DATA(employee_api) = cl_hcmfab_employee_api=>get_instance( ).
    DATA(molga)        = employee_api->get_molga( pernr ).
  CATCH cx_hcmfab_common.
ENDTRY.

[ABAP] xstring to binary (RAW)

* Option 1
  DATA lt_data TYPE STANDARD TABLE OF x255.
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer     = lv_xstring
    TABLES
      binary_tab = lt_data.

* Option 2
  cl_scp_change_db=>xstr_to_xtab( EXPORTING im_xstring = lv_xstring
                                  IMPORTING ex_xtab    = DATA(lt_data) ).

* Option 3
  DATA(lt_data) = cl_bcs_convert=>xstring_to_solix( lv_xstring ).

[Fiori] My Inbox – Tasks not appearing in Inbox

There are many reasons why a workflow task might not appear in the Inbox app. One reason I always forget to check is quite simple.

Check whether a scenario is configured!

Simply open the Tile configuration and check the Parameter field. If there is a scenario, it would be something like scenarioId=EHS_HS_HAZMAT instead of allItems=true.

If a scenario is in use, you can find more about it in the customizing here:

In a scenario, a restriction to certain workflow tasks can be configured.

More information can be found here:
https://help.sap.com/docs/SAP_S4HANA_ON-PREMISE/8308e6d301d54584a33cd04a9861bc52/68c4379a35f644f6b3a73428594d6c3f.html?locale=en-US&version=LATEST
https://community.sap.com/t5/technology-blog-posts-by-sap/sap-fiori-for-sap-s-4hana-fiori-my-inbox-part-1-activation/ba-p/13326175