The main idea of the article is to show how to generate a complete link to GUI transaction using SAP GUI for HTML (WebGU).
Classical and S/4 HANA systems are checked. Links are generated and they work for both cases.
The present article describes the way of generating a link to SAP GUI for HTML (WebGUI) with preset parameters.
Find the link to start WebGUI
*If you know your system’s <hostname>:<port>, skip this part and copy the path from the end of this step.
First, in order to find the link to WebGUI for current system, go to SICF and input the filter by Service Name parameter: WEBGUI

Next test the selected service

Now extract <hostname>:<port>/<path> to start SAP GUI for HTML:

It should look as follows:
https://<hostname>:<port>/sap/bc/gui/sap/its/webgui
Generate the parameters to access the transaction with filters
In this step there are 2 options available:
Using DYNP_OKCODE
Using ~OKCODE
Links should be generated as follows respectively for the options:
~transaction=*<transaction> <parameter>=<parameter_value>;DYNP_OKCODE=<function_key>
~transaction=<transaction>&<parameter>=<parameter_value>&~OKCODE=< function_key >
To find all the required parameters names and values follow the instruction:
Start the required transaction and open technical information for the field which should be predefined for access via WebGUI:

Use the Screen Field as parameter

Then go to GUI Data Status:

Find the Function Key value

Conclusion
As the result, the link is generated, and you can start the transaction with parameters using both approaches: DYNP_OKCODE and ~OKCODE.
Both mentioned options are available on classical and S/4 HANA systems.
For the case shown the links look like these:
https://<hostname>:<port>/sap/bc/gui/sap/its/webgui?~transaction=*IW33%20CAUFVD-AUFNR=200000;DYNP_OKCODE=IHKZ
Classical system:

S/4 HANA system:

https://<hostname>:<port>/sap/bc/gui/sap/its/webgui?~transaction=IW33&CAUFVD-AUFNR=200000&~OKCODE=IHKZ
Classical system:

S/4 HANA system:

The links were tested for:
Classical system:

S/4 HANA system:
