Welcome to part six of this blog series introducing abap2UI5 — an open-source project for developing standalone UI5 apps in pure ABAP.

This post explains how to install, configure and debug abap2UI5.

Find all the information about the project on GitHub and stay up-to-date by following on Twitter.

Blog Series

(1/7) Introduction: Developing UI5 Apps in pure ABAP
(2/7) Displaying Selection Screens & Tables
(3/7) Popups, F4-Help, Messages & Controller Logic
(4/7) Advanced Functionality & Demonstrations
(5/7) Extensions with XML Views, HTML, JS & Custom Controls 
(6/7) Installation, Configuration & Debugging (this blog post)
(7/7) Technical Background

Installation

1. Install the project with abapGit

For an on-premise system, you can use this Tutorial. In a cloud environment, you can follow this SAP Developer Tutorial. The project is based on a single code line for both language versions (ABAP Cloud, Standard ABAP), so you can clone this main branch in both cases. For lower releases (NW 7.03 to 7.40) use this low syntax branch.

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.

3. Develop a new HTTP Request Handler

Now copy the following implementation into the handler method.

ABAP Standard:

METHOD if_http_extension~handle_request.

   DATA lt_header TYPE tihttpnvp.
   server->request->get_header_fields( CHANGING fields = lt_header ).

   DATA lt_param TYPE tihttpnvp.
   server->request->get_form_fields( CHANGING fields = lt_param ).

   z2ui5_cl_http_handler=>client = VALUE #(
      t_header = lt_header
      t_param  = lt_param
      body     = server->request->get_cdata( ) ).

   DATA(lv_resp) = SWITCH #( server->request->get_method( )
      WHEN 'GET'  THEN z2ui5_cl_http_handler=>main_index_html( )
      WHEN 'POST' THEN z2ui5_cl_http_handler=>main_roundtrip( ) ).

   server->response->set_cdata( lv_resp ).
   server->response->set_status( code = 200 reason = 'success' ).

ENDMETHOD.

ABAP Cloud:

METHOD if_http_service_extension~handle_request.

   z2ui5_cl_http_handler=>client = VALUE #(
      t_header = request->get_header_fields( )
      t_param  = request->get_form_fields( )
      body     = request->get_text( ) ).

   DATA(lv_resp) = SWITCH #( request->get_method( )
      WHEN 'GET'  THEN z2ui5_cl_http_handler=>main_index_html( )
      WHEN 'POST' THEN z2ui5_cl_http_handler=>main_roundtrip( ) ).

   response->set_status( 200 )->set_text( lv_resp ).

ENDMETHOD.

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

abap2UI5 Landing Page

And continue to the demo section:

abap2UI5%20Demi%20Section

abap2UI5 Demo Section

Next check out this first blog post to see how to start developing your app.

Configuration

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 #(
        (  name = `data-sap-ui-theme`         value = `sap_horizon` )
        (  name = `src`                       value = `https://sdk.openui5.org/resources/sap-ui-core.js` )
        (  name = `data-sap-ui-libs`          value = `sap.m` )
        (  name = `data-sap-ui-bindingSyntax` value = `complex` )
        (  name = `data-sap-ui-frameOptions`  value = `trusted` )
        (  name = `data-sap-ui-compatVersion` value = `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( 
      (  name = `data-sap-ui-theme`         value = `sap_belize` ) "<- adjusted
      (  name = `src`                       value = `https://sdk.openui5.org/resources/sap-ui-core.js` )
      (  name = `data-sap-ui-libs`          value = `sap.m` )
      (  name = `data-sap-ui-bindingSyntax` value = `complex` )
      (  name = `data-sap-ui-frameOptions`  value = `trusted` )
      (  name = `data-sap-ui-compatVersion` value = `edge` ) ).

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

You can also change the title:

    DATA(lv_resp) = SWITCH #( request->get_method( )
       WHEN 'GET'  THEN z2ui5_cl_http_handler=>main_index_html(
                                 title = `MyTitle` )
       WHEN 'POST' THEN z2ui5_cl_http_handler=>main_roundtrip( ) ).

abap2UI5%20with%20changed%20title

abap2UI5 with changed title

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.

To synchronize the configuration with all other UI5 apps in your system, you can use the following customizing and read this table before the method call (enjoy the view, this is the only SAP GUI screenshot included in this blog series 😉):

Configure%20SAP%20UI5%20Bootstrap

Configuration SAP UI5 Bootstrapping

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)
test
Evening Horizon (sap_horizon_dark) High Contrast Black (sap_horizon_hcb)

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.

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 possible to encapsulate abap2UI5 in a UI5 standard app. Note that there is still some work to do but if you want to try out this approach or contribute to the project, check out this issue.

Debugging

When your app is in the development process, you can activate logging by changing the following parameter:

DATA(lv_resp) = SWITCH #( request->get_method( )
       WHEN 'GET'  THEN z2ui5_cl_http_handler=>main_index_html(
                           check_logging = abap_true )
       WHEN 'POST' THEN z2ui5_cl_http_handler=>main_roundtrip( ) ).

Frontend

After that, the XML View is written into the console after every server response:
XML-View%20Console

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.

Next, you can scroll up a little bit to check the remainder of the previous response.

Response%20Object

Response Object

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.

object

Request Object

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

UI5%20Dev%20Tools%20with%20abap2UI5

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%20Development%20in%20abap2UI5

View Development in abap2UI5

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:

Single%20HTTP%20Handler

abap2UI5 HTTP Handler

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

Initial%20Request

abap2UI5 Get Request (index.html)

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

Programm%20flow

abap2UI5 Post Request

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:

Initialize%20app%20after%20frontend

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.

Summary

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 final blog post, we will focus on the technical background of this framework by covering topics such as compatibility, downporting and its code line.

Thank you for reading this blog post!

Your questions, comments and wishes for this project are always welcome, create an issue or leave a comment.

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x