SAP Fiori Elements preview fails with underscore character in hostname
When using the Fiori Elements preview for a RAP business object in an on-premise SAP S/4HANA test system I ran into the problem that the SAP Fiori Elements preview did not work.
Instead I got the following error message: “Host and port configuration information is missing”
The root cause of this problem was that the hostname that was configured in table HTTPURLLOC in our SAP S/4HANA on premise demo system contained an underscore “_”.
The field for the host name with domain contained the value
However, underscore characters are illegal in host names as I learned from our ADT development team, which is described here:
Though it works in tools such as Chrome / Firefox / …(which do not follow the standard strictly), the URI parser in Java is very strict:
jshell> URI.create("https://2022_SECOND_SANDBOX.S4HANA.ONLY.COM:44301/sap/bc/adt").getHost() $19 ==> null
and as a result the hostname is lost.
Using e.g. “-” instead of “_” solves this:
jshell> URI.create("https://2022-SECOND-SANDBOX.S4HANA.ONLY.COM:44301/sap/bc/adt").getHost() $20 ==> "2022-SECOND-SANDBOX.S4HANA.ONLY.COM"
When using a hostname that contains underscores will also cause that the URL that is generated when trying to share source code via a http link in ADT will generate a URL without a hostname nor a port information that will hence not work.