Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
oblomov
Active Participant
Welcome to part 6 of this blog series introducing abap2UI5 — an open-source project for developing UI5 apps purely in ABAP.

This post explains the installation, configuration and troubleshooting steps of abap2UI5.

Blog Series & More

You can find all the information about this project on GitHub, stay up-to-date by following on Twitter and be sure to explore the other articles of this blog series:







































(1) Introduction: Developing UI5 Apps Purely in ABAP
(2) Displaying Selection Screens & Tables
(3) Popups, F4-Help, Messages & Controller Logic
(4) Advanced Functionality & Demonstrations
(5) Creating UIs with XML Views, HTML, CSS & JavaScript 
(6) Installation, Configuration & Troubleshooting (this blog post)
(7) Technical Background: Under the Hood of abap2UI5
(8) Repository Organization: Working with abapGit, abaplint & open-abap
(9) Update I: Community Feedback & New Features - Sep. 2023
(10) Extensions I: Exploring External Libraries & Native Device Capabilities
(11) Extensions II: Guideline for Developing New Features in JavaScript
(12) Update II: Community Feedback, New Features & Outlook - Jan. 2024

Content

This post covers the following areas:

  1. Installation

    1. Install the Project

    2. Create a new HTTP Service

    3. Implement the Handler Method



  2. Configuration

    1. Options & URL Parameters

    2. Title

    3. Synchronize the Configuration

    4. Theme

    5. Bootstrapping

    6. Launchpad

    7. CSS



  3. Security

  4. Debugging

    1. Frontend

    2. Backend



  5. Conclusion


Let’s begin with the first topic.

1. Installation


1.1. Install the project with abapGit


If you are new to abapGit, start by reviewing this Guideline for on-premise systems and this Tutorial for cloud environments.

The project is based on a single code line for both language versions (ABAP Cloud, Standard ABAP), so you can pull this repository in both cases. For lower releases (NW 7.03 to 7.40) use this downport repository.

1.2. Create a new HTTP Service


Next, create a new HTTP service in your system. In an on-premise environment, you need to create and configure a new ICF service. Follow this guideline for that and see how to develop a new HTTP request handler here. In a cloud scenario, follow this tutorial.

1.3. Implement the Handler Method


Now copy the following implementation into your new handle_request method.

ABAP Standard:

METHOD if_http_extension~handle_request.

DATA(lv_resp) = SWITCH #( server->request->get_method( )
WHEN 'GET' THEN z2ui5_cl_fw_http_handler=>http_get( )
WHEN 'POST' THEN z2ui5_cl_fw_http_handler=>http_post( server->request->get_cdata( ) ) ).

server->response->set_header_field( name = `cache-control` value = `no-cache` ).
server->response->set_cdata( lv_resp ).
server->response->set_status( code = 200 reason = `success` ).

ENDMETHOD.


ABAP Cloud:

METHOD if_http_service_extension~handle_request.

DATA(lv_resp) = SWITCH #( request->get_method( )
WHEN 'GET' THEN z2ui5_cl_fw_http_handler=>http_get( )
WHEN 'POST' THEN z2ui5_cl_fw_http_handler=>http_post( request->get_text( ) ) ).

response->set_status( 200 )->set_text( lv_resp
)->set_header_field( i_name = `cache-control` i_value = `no-cache` ).

ENDMETHOD.




By calling your new HTTP handler via browser, you can start abap2UI5 and see the landing page:


abap2UI5 Landing Page


Optionally you can install the abap2UI5 samples repository next and check out all the examples:


abap2UI5 Samples Repository


Now you are ready to develop your first own app. See the first blog post to find more information about the development process.

2. Configuration


2.1. Options and URL Parameters



There are two ways to set the configuration: one is by setting it via URL parameter, and the other option is by importing it as a configuration by calling the index HTML.

By default, the following parameters are set:
lt_config = VALUE #(
( n = `src` v = `https://sdk.openui5.org/resources/sap-ui-cachebuster/sap-ui-core.js` )
( n = `data-sap-ui-theme` v = `sap_horizon` )
( n = `data-sap-ui-async` v = `true` )
( n = `data-sap-ui-bindingSyntax` v = `complex` )
( n = `data-sap-ui-frameOptions` v = `trusted` )
( n = `data-sap-ui-compatVersion` v = `edge` ) ).

If you want to make changes, simply copy the table, adjust the necessary parameters and then import the table again when calling the method:
DATA(lt_config) = VALUE z2ui5_if_client=>ty_t_name_value( 
( n = `data-sap-ui-theme` v = `sap_belize` ) "<- adjusted
( n = `src` v = `https://sdk.openui5.org/resources/sap-ui-cachebuster/sap-ui-core.js` )
( n = `data-sap-ui-async` v = `true` )
( n = `data-sap-ui-bindingSyntax` v = `complex` )
( n = `data-sap-ui-frameOptions` v = `trusted` )
( n = `data-sap-ui-compatVersion` v = `edge` ) ).

DATA(lv_resp) = SWITCH #( request->get_method( )
WHEN 'GET' THEN z2ui5_cl_fw_http_handler=>http_get( lt_config )
WHEN 'POST' THEN z2ui5_cl_fw_http_handler=>http_post( request->get_text( ) ) ).

You can find a list of all configuration parameters here. Additionally, you can modify these parameters with the sap-ui- prefix to use them as URL parameters.

2.2. Title


You can set the title with the following snippet in your definition of the view:
DATA(view) = z2ui5_cl_xml_view=>factory( ).
view->_z2ui5( )->title( i_client->_bind_edit( `My Title` )


abap2UI5 with changed title


Check out the following sample.

2.4. Synchronize the Configuration


You can also synchronize your configurations with all other ui5 apps in your system by reading the customizing from the following table prior to making the method call (Enjoy the view – this is the only SAP GUI screenshot included in this blog series 😉😞


Configuration SAP UI5 Bootstrapping



2.4. Theme


The most common change is to the theme. You can find all available themes here. The newest theme is Horizon (sap_horizon) and it is used in all the demos of this blog series. Other popular themes are:



















Belize (sap_belize) Quartz Light (sap_fiori_3)
Evening Horizon (sap_horizon_dark) High Contrast Black (sap_horizon_hcb)

2.5. Bootstrapping


In an on-premise landscape, you can bootstrap the UI5 library from your local system. Typically, the path is "/sap/public/bc/ui5_ui5/resources/sap-ui-core.js" or "resources/sap-ui-core.js". In a cloud scenario, you can refer to SAP guidelines available here.

2.6. Launchpad


Abap2UI5 is based on a single-page index.html, which makes it not compatible with FLP out-of-the-box (since FLP replaces the index.html). However, it is no problem to encapsulate abap2UI5 in a UI5 standard app for the use with launchpads. Check out and install this additional repository.

2.7. CSS


You can change the CSS by sending HTML with your View in your app. An example can be found here:


abap2UI5 app with changed CSS



3. Security


At the backend, abap2UI5 is a plain HTTP handler that every user creates and configures by themselves (visibility, authentication & other security parameters). In the implementation of your apps you have to take care of a secure programming style like always when developing HTTP-Handlers (call authorization checks, avoid dynamic SQL etc.). Check this for more information.

At the frontend, abap2UI5 is a normal one page UI5 application. It loads the external library UI5 from a CDN or your own customized directory. The UI5 framework is used to render the HTML and only methods of the UI5 framework are called to handle the all events.

Additionally to prevent cross-site-scripting the following parameter are set in the index.html:
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval' ui5.sap.com *.ui5.sap.com sdk.openui5.org *.sdk.openui5.org cdn.jsdelivr.net *.cdn.jsdelivr.net"/>

It only allows libraries from the same server, ui5.sap.com, openui5.com or cdn.jsdelivr.net, which we needed to use for some external libraries. Adjust the importing parameter 'content-security-policy' when you want to include more external URLs:
DATA(lv_resp) = SWITCH #( request->get_method( )
WHEN 'GET' THEN z2ui5_cl_fw_http_handler=>http_get(
content_security_policy = `<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval' ui5.sap.com *.ui5.sap.com sdk.openui5.org *.sdk.openui5.org cdn.jsdelivr.net *.cdn.jsdelivr.net"/>` )
WHEN 'POST' THEN z2ui5_cl_fw_http_handler=>http_post( request->get_text( ) ) ).

You can find more information about CSP here.

4. Debugging


When your app is in the development process, you can activate the debugging tools by changing the following parameter:
DATA(lv_resp) = SWITCH #( request->get_method( )
WHEN 'GET' THEN z2ui5_cl_fw_http_handler=>http_get(
check_debugging = abap_true )
WHEN 'POST' THEN z2ui5_cl_fw_http_handler=>http_post( request->get_text( ) ) ).

4.1. Frontend


After that, you can can start an app and press the shortcut STRG+A and the debugging tools are displayed:


abap2UI5 Debugging Tools


Next follow the left menu and press for example View XML:


abap2UI5 Debugging Tools - XML-View


Most of the issues arise because the XML is not valid. You can check it there or copy & paste it to an XML validator. Another good way to test the XML are UI5 sandboxes, such as the OpenUI5 Sandbox.

You can also check the View Model and previous request here. If a parameter is bound with _bind_one, it should be written in the oViewModel. If a parameter is bound with _bind, it should be written in oUpdate. You can also check the last request to ensure that all updated values have been sent to the server.

To take a more detailed look at the UI, use the UI5 Inspector. This tool is helpful for analyzing and checking certain controls:


UI5 Inspector with an abap2UI5 app


You can find more guidelines here.

Also, keep in mind that abap2UI5 is based on REST, so you don't need to restart the app all the time after a change, like in the former screen logic where changes were only visible after restarting. Just triggering a server roundtrip is enough to see the changes:


View Development in abap2UI5



4.2. Backend


Set a breakpoint in your app and check the values that abap2UI5 provides you, as well as the values you give back to abap2UI5. Check if the view XML is filled and if it is valid. Normally, abap2UI5 throws an exception if something unexpected happens, which can help you to identify the problem. If you want to gain a deeper understanding, you can also debug the framework itself.

The framework is based on a single http handler. Set a breakpoint here and check incoming requests and outgoing responses:


abap2UI5 HTTP Handler


The initial request loads the UI5 index.html, which is independent of your application and should normally not cause any problems:


abap2UI5 Get Handler (index.html)


After this, the AJAX roundtrip logic begins. Every event and interaction creates a new HTTP Post request, which triggers the following method:


abap2UI5 Post Handler


As you can see, we call the user's app on line 44. You can also check if your app has been successfully updated after the frontend on line 39 and check the following method:


Update app after frontend (PAI)


And the reverse direction, setting the response with the values of your app in this method:


Create frontend model before output (PBO)


If you find a bug in the framework or running into problems with your app, feel free to open an issue.

5. Conclusion


This was part six of this introduction to abap2UI5. You now have an understanding how to install & configure it and got insights into troubleshooting & debugging.

In the next blog post, we will focus on the technical background of this framework and summarize all the project's key ideas by covering topics such as its architecture, codebase and compatibility.

Thank you for reading! Your questions, comments and wishes for this project are always welcome, create an issue or leave a comment.
27 Comments
Tyukmaev
Explorer
0 Kudos
Hi all!

When I select “Pull” to copy all objects from the Git repository into the SAP system.
I get message "Error from DDIF_TABL_PUT", has anyone ever received such an error?
ChristianGünter
Contributor

I'd suggest to raise an issue in the git repo.

ABAP2UI5

BR Christian

barisguler
Participant
0 Kudos

Hello,
I'm having trouble with creating services and running demos with SICF. I created the service using the given method, but when I test it, I get Internal service 500 error. Do you have any ideas?


oblomov
Active Participant
Hi Baris, thank you for trying this out, I had to make some changes in the startup process, can you pull the actual version one more time and try again? Best Regards.
barisguler
Participant
0 Kudos
Thanks for quick reply. It's working now. Regards
JMoutreux
Explorer
0 Kudos
Hello error in class Z2UI5_CL_XML_VIEW method XML_GET

 

No type can be derived from the context for the operator "REDUCE". I'm on 740 system but i don't find this class in 702 repository.

 

could you please help.?

 

I don't know the new syntax (i work on add-on partner and we must be compatible 702 system).

 

 

    DATA(lv_tmp3REDUCE #INIT val `` FOR row IN mt_prop WHERE v <> `` )
NEXT val |{ val } { row-n }="{ escape( val = COND string( WHEN row-v = abap_true THEN `true` ELSE row-v ) format = cl_abap_format=>e_xml_attr ) }" \n | ).
oblomov
Active Participant
0 Kudos
Oh yes, the downported v702 branch is not up to date anymore. I will fix this in the next days and let you know again.
JMoutreux
Explorer
0 Kudos
Hello thanks.

 

temporary I declare lv_tmp3 with type string and it's work.
Mayursatardekar
Explorer
0 Kudos
Can't access the tutorial page

oblomov
Active Participant
0 Kudos
The blog is updated, this is the new link:
https://docs.abapgit.org/user-guide/getting-started/install.html
oblomov
Active Participant
0 Kudos

The downport repository is updated now:
https://github.com/oblomov-dev/abap2UI5-downport

WenjingLiu
Participant
0 Kudos

Hi oblomov,

Thanks for the project. I am on BTP Trial, and I have created my own application successfully. However I don't know how to change the theme.

DATA(lv_resp) = SWITCH #( request->get_method( )
WHEN 'GET' THEN z2ui5_cl_http_handler=>http_get( t_config = lt_config )
WHEN 'POST' THEN z2ui5_cl_http_handler=>http_post( ) ).

This line of code would throw an error, "Field "REQUEST" is unknown".

Can you help? Thanks!

Regards,
Wenjing

oblomov
Active Participant

Hi Wenjing,

Thank you for trying out abap2UI5. Have you created a new HTTP Service first? You can follow this guideline. After finishing the tutorial you get a new HTTP Handler class, and there you can copy the code snippet you marked into the method if_http_service_extension~handle_request.

Best regards.

WenjingLiu
Participant

Yes, you are right. Thanks for the help!

In the BTP Trial system, somebody has pulled the repo and created a package ZABAP2UI5. I was using the HTTP service ZABAP2UI5 in that package rather than my own ZNOV05_TEST_HTTP, and I didn’t place the configuration code in either HTTP service handler class. Instead, I tried to include the code in my application class, and that is why "request" caused an error. Now I have changed the theme in my own HTTP service handler class, and it works well.

ali-kaplan
Explorer


Hi oblomov

awesome framework! While trying to install it on your on-premises NW system I realized that the following line of code in Handler Method for Abap Standard seems to be outdated in this blog post:
path_info = lt_header[ name = `~path_info` ]-value

Other than that, everything went flawlessly!

Thank you so much for providing a framework that helps us ABAP developers provide slick modern UIs in no time.

BR,

Ali

oblomov
Active Participant
0 Kudos
Hi Ali, nice to hear that you like abap2UI5 and thank you for your feedback. The blog post is updated now. Best regards.
kmoore007
Active Contributor
I've downloaded the samples, but I'm not understanding how to run them.  I guess I'm not understanding the SICF settings and how to connect to the samples classes.
oblomov
Active Participant
0 Kudos
Hi kenneth.moore,

Install the abap2UI5 repository first and then create a new icf service to call the samples. You can find more detailed installation guidelines here and feel free to create an issue here if you have further questions.

Best regards.
kmoore007
Active Contributor
0 Kudos
Hello Oblomov,

I did already install the abap2UI5 repository, yes.  When I test the service zabap2UI5 in SICF, I get the error, "File not found!".

oblomov
Active Participant
0 Kudos
Hi Kenneth,

it seems that you installed the launchpad extension, this is not necessary. Just install the main repository:

https://github.com/abap2UI5/abap2UI5

You can find installation guidelines here:

https://github.com/abap2UI5/abap2UI5-documentation/blob/main/docs/01_installation/install_on_prem.md

After that, create a new ICF Service manually, as described here:

https://github.com/abap2UI5/abap2UI5-documentation/blob/main/docs/01_installation/create_http_on_pre...

Thats all you have to do.

Best regards.
kmoore007
Active Contributor
0 Kudos

Hello Oblomov,

I did not install the extension, but I went ahead and deleted and reinstalled the main repository.  I get the same result.  I did notice that the instructions for the http service class, ZCL_MY_ABAP2UI5_HTTP_HANDLER , that it shows class z2ui5_cl_http_handler, but that class is not available.  z2ui5_cl_fw_http_handler is only available.  Does it have something to do with that?

Thanks,

Kenneth

oblomov
Active Participant
0 Kudos
yes this could be the reason, use the class z2ui5_cl_fw_http_handler or just copy & paste the snippet, you can find here:

https://github.com/abap2UI5/abap2UI5#installation
stephane_g
Explorer
0 Kudos
Hi Oblomov,

Thank you for providing this series of great blogs. I haven't read everything in detail yet, as I just completed the installation described in this part 6 (on a on-premise A4H demo system).

I have a few remarks and questions.

1/ I think you should have made this part 6 the first one of the series.

2/ I would suggest that you correct the code in the section 'Installation / 3. Implement the Handler Method' and replace z2ui5_cl_http_handler by z2ui5_cl_fw_http_handler because it is quite confusing as the suggested code gives an error. I found the solution by reading the comments of the blog and the solution is in your response to Kenneth Moore just above.

3/ I have created the prg ZABAPGIT_STANDALONE and used it to 'pull' https://github.com/abapGit/abapGit/ which gives the prg ZABAPGIT (with transaction ZABAPGIT).

ZABAPGIT_STANDALONE is all with local classes (since the whole code is in one file) when ZABAPGIT uses Global classes and a different modularisation.

But the 2 programs seem to do exactly the same thing, so what is the purpose of creating ZABAPGIT if we already have ZABAPGIT_STANDALONE ?

4/ And one last remark, the link " samples repository " does not work. It is https://github.com/oblomov-dev/abap2UI5-samples and should probably be updated for https://github.com/abap2UI5/abap2UI5-samples

 

Thanks again

Stephane

 

 
oblomov
Active Participant
0 Kudos

Hi stephane-g

thank you for reading and trying out abap2UI5!

1) Yes it was not planned from the beginning that this series got as big as it is now, thats why some parts are not on the best position.

2) Updated the code sample.

3) Both programs do the same, so you can also use both for installing abap2UI5. The standalone version can be easily copy & pasted to any system (also with no internet connection). The zabapgit version needs an online connection to abapgit but can be automatically updated via PRs etc. For your use case i think the the standalone version is enough.

4) Corrected the link

Thank you for your hints, very helpful for me to find outdated information.

Best regards.

ekaterina_ermak
Explorer
0 Kudos
Hi Oblomov!

First of all thank you a lot for this interesting work!

I'm trying to run the examples and I'm encountering the following behaviour: without setting the flag "check_debugging abap_true" in the HTTP handler the inhalt of the table is not shown (for example in z2ui5_cl_demo_app_003) but with the flag I am seeing the entries. What could be the reason?

 
oblomov
Active Participant
0 Kudos
Hi ekaterina.ermak

thank you for using abap2UI5. I think i already fixed this bug a few days ago, can you install the latest version of abap2UI5 and check if the error still exists?

Best regards.
ekaterina_ermak
Explorer
0 Kudos
Hi Oblomov!

 

yes! It helped. Thank you very much!

 

Best regards.
Labels in this area