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 the first part of this blog series introducing abap2UI5 — an open-source project for developing UI5 apps purely in ABAP.

This first post offers an overview of the project. It highlights its features, presents demonstrations, and provides a step-by-step guide to the development process.

Blog Series & More

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

  1. Introduction: Developing UI5 Apps Purely in ABAP (this blog post)
  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
  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. Project Information
    1.  Features
    2. Demos
    3. Basic Example
  2. Development Process
    1. View
    2. Controller
    3. Event
    4. Model & Data Binding
  3. What's next?
  4. Conclusion

Let’s begin with the first topic.

1. Project Information

This project offers a pure ABAP approach for developing UI5 apps, entirely without JavaScript, OData and RAP — similar to the past, when only a few lines of ABAP sufficed to display input forms and tables using Selection Screens & ALVs. Designed with a minimal system footprint, it works in both on-premise and cloud environments.

1.1 Features, Compatibility & Installation

  • 100% ABAP: Developing purely in ABAP (no JavaScript, DDL, EML or Customizing)
  • User-Friendly: Implement just a single interface for a standalone UI5 application
  • Minimal System Footprint: Based on a plain HTTP handler (no BSP, OData, CDS, BOPF or RAP)
  • Cloud and On-Premise Ready: Works with both language versions (ABAP for Cloud, Standard ABAP)
  • Broad System Compatibility: Runs on all ABAP releases (from NW 7.02 to ABAP Cloud Stacks)
  • Easy Installation: abapGit project, no additional app deployment required

Use abapGit for installation, pull the repository, create a new HTTP service and call abap2UI5. Detailed information can be found in part 6 of this series. This project is compatible with all ABAP releases and language versions:

  • BTP ABAP Environment (ABAP for Cloud)
  • S/4 Public Cloud ABAP Environment (ABAP for Cloud)
  • S/4 Private Cloud or On-Premise (ABAP for Cloud, Standard ABAP)
  • R/3 NetWeaver AS ABAP 7.50 or higher (Standard ABAP)
  • R/3 NetWeaver AS ABAP 7.02 to 7.42 (Standard ABAP) - use this downport repository

1.2 Demos

For an impression of the possibilities of abap2UI5, take a look at the demos presented in this blog series — everything is developed in pure ABAP:

Selection Screens (Blog 2)Tables, Lists & Maintenance (Blog 2)
Popups & F4-Helps (Blog 3)File Editor, File Upload & Visualization (Blog 4)

But first let's start with a basic example.

1.3 Basic Example

A simple abap2UI5 app with an input and a message output looks like this:

 

 

 

CLASS z2ui5_cl_app_hello_world DEFINITION PUBLIC.

  PUBLIC SECTION.
    INTERFACES z2ui5_if_app.
    DATA quantity TYPE string.

ENDCLASS.

CLASS z2ui5_cl_app_hello_world IMPLEMENTATION.
  METHOD z2ui5_if_app~main.

    CASE client->get( )-event.
      WHEN 'BUTTON_POST'.
        client->message_toast_display( |{ quantity } Product ABC - send to the server| ).

    ENDCASE.

    client->view_display( z2ui5_cl_xml_view=>factory(
      )->page( 'abap2UI5 - Hello World App'
         )->simple_form( )->content( ns = `form`
            )->title( 'Input here and send it to the server...'
            )->label( 'Product-ABC'
            )->input( client->_bind_edit( quantity )
            )->button( text = 'post' press = client->_event( 'BUTTON_POST' )
      )->stringify( ) ).

  ENDMETHOD.
ENDCLASS.

 

 

 

As you can see, to develop an UI5 app with abap2UI5, simply create a new class and implement the method main of the following interface:

 

 

 

INTERFACE z2ui5_if_app PUBLIC.

  METHODS main
    IMPORTING
      client TYPE REF TO z2ui5_if_client.

ENDINTERFACE.

 

 

 

The output of this app looks like this:

 

abap2UI5 - Basic Example


Everything functions seamlessly out-of-the-box, offering bidirectional data transfer, event handling, and a user interface

2. Development Process


Let's walk through the development process step-by-step, beginning with the view, then progressing to the controller, and finally, we'll examine the model.

2.1 View


Abap2UI5 provides the possibility to develop UI5 Views similar to an UI5 freestyle application. You have complete freedom in structuring the view and the flexibility to use a wide range of UI5 controls. The view can be defined either directly as a string or crafted using the class z2ui5_cl_xml_view. Let's examine the app mentioned earlier and compare its UI5-View with its abap2UI5 counterpart:

UI5-View vs. abap2UI5-View

<Page title="Page title" >

	<f:SimpleForm title="Form Title">

		<f:content>

			<Title text="Input" />

			<Label text="quantity"/>

			<Input value="{/oUpdate/QUANTITY}"/>

			<Label text="product" />

			<Input value="tomato" />

			<Button press="onEvent" text="post"/>

		</f:content>

	</f:SimpleForm>

</Page>

view->page( title = 'Page title' )

        )->simple_form( 'Form Title'

          )->content( 'f'

             )->title( 'Input'

             )->label( 'quantity'

             )->input( client->_bind_edit( quantity )

             )->label( 'product'

             )->input( value = product editable = abap_false

             )->button( text  = 'post'  

                        press = client->_event( 'BUTTON_POST' ) ).


In abap2UI5, the XML-View is generated in ABAP and the class serves as a helper to simplify the creation of XML. However, ultimately, both approaches yield the same result, with the key difference being that in abap2UI5, the view is transmitted from the backend.

This is just a simple example and in the following blog posts, we will expand its functionality to include tables, lists, selection screens, charts and more.

abap2UI5 Control Library

Here is a selection of available UI5 controls that you can utilize with the class z2ui5_cl_xml_view:

 

z2ui5_cl_xml_view


More controls will be added in the future – check out the source code. Additionally in part five of this series, other view creation approaches with increased flexibility will be explained.

Most UI5 controls are compatible with abap2UI5 without requiring any additional adjustments. For example, Inputs can be used since it only consists of attributes that can be directly sent back to the server. Controls that rely on additional JavaScript logic need to be modified to work with abap2UI5. They have to be encapsulated in a custom control first.

We will see an example for this in part four of this blog series, where we will use a custom control for uploading and downloading files and check also out part 11 to learn how to implement your own custom control in abap2UI5.

2.2 Controller


The interface z2ui5_if_app consists of the method 'main', which gives you control over the frontend UI5 app, similar to the JavaScript controller of a UI5 freestyle application. Consequently, they look similar:

UI5-Controller vs. abap2UI5-Controller

sap.ui.controller("sap.ui.myApp.controller.one", {



	onInit: function() {

	},



	onBeforeRendering: function() {	 

	},



	onEvent: function() {

	},



	onAfterRendering: function() {	

	},



	onExit: function() {

	}	

});

  METHOD z2ui5_if_app~main.



    IF check_initialized = abap_false.

      check_initialized = abap_true.

      "set init values here...

    ENDIF.



    CASE client->get( )-event.

      WHEN 'POST'.

        "event handling here...

    ENDCASE.



    "view rendering here...

    client->view_display( z2ui5_cl_xml_view=>factory(

        )->shell( )->page(  )->simple_form( 'Title'

    "....



  ENDMETHOD.


The abap2UI5 framework redirects event handling from the frontend controller to the backend implementation of your class, granting you complete freedom in the backend to determine how to respond to specific frontend events.

A single 'main' method is used for this purpose (similar to what if_oo_adt_classrun does), without segregating the view and controller. This approach creates flexibility and enable the user to structure their apps according to their preferences. Therefore, this method acts merely as a foundational layer, on top of which users can build their own logic through distinct methods. For example, one might have a method for initialization, another for handling user commands, and so on.

Next, let's examine how events can be triggered on the frontend.

2.3 Events

 

The following events are available:


Event (User-Command)


view->( )->button( 

     text  = 'post' 

     press = client->_event( 'BUTTON_POST' ) ).
Usually it's enough to just send a simple user-command back to the server -- use the method _event


Event (Popup Close)


view->button(

     text  = 'close'

     press = client->_event_client( client->cs_event-popup_close ) ).
You can close a popup at the frontend with this event -- we will take a more detailed look at popups in the third blog post of this series


If more event functions are necessary, the framework can be extended in the future.

2.4 Model & Data Binding


When values need to be displayed in the frontend, define them as public attributes in your abap2UI5 app. These attributes will be bound by the framework, so it needs to have a chance to assign them from the outside. Additionally, if your values will also be updated in the frontend, make sure that they are not defined as read-only, otherwise, abap2UI5 will throw an error when attempting to modify them. There are three ways to bind data and sent it to the frontend:

Direct XML


view( )->label( 'product'

      )->input( value = product editable = abap_false ).
You can write the value into the attribute, abap2UI5 will then write it directly into the UI5-XML-View and sent it to the frontend.

Bind Local


view( )->label( 'product'
      )->input( value = view->_bind_local( product ) ).
You can bind the values locally, which your can use for local variables which are not public attributes of your class. Their value is saved right at the moment. Use cases for example are tables with contents for value helps.

One-Way-Binding


view->( )->label( 'product'
        )->input( value = view->_bind( product ) editable = abap_false ).
You can use one-way-binding, the values are then written into the view model and bound to the UI5-XML-View. This is useful for complex data models such as tables. We will see this in more detail in the next blog post.


Two-Way-Binding


view( )->label( 'quantity'

      )->input( value = view->_bind_edit( quantity ) editable = abap_true ).​
You can use two-way-binding, it is similar to one-way binding, but it also sends values from the frontend to the server. This binding mode is useful for inputs and editable tables.


When defining the view, consider the data transfer to the frontend. To keep the request payload small use one-way-binding by default and two-way-binding only when necessary, such as when values need to be updated from the frontend. Besides that, abap2UI5 takes care of the rest by transforming the data into JSON, sending it to the frontend, and bringing back the updated values, as we'll see in part 7 of this series.

3. What's next?


Now you got a basic understanding of the functionality of this project. However, this was merely an overview. abap2UI5 is continuously evolving, and more blog posts are being written. If you wish to delve deeper into specific topics, explore the other blog posts next. Additionally, take a look to all the features of abap2UI5 by visiting the samples repository, which is also regularly updated with new features:

 

Samples of abap2UI5 (As of August 2023)



4. Conclusion


This was the first part of the introduction to abap2UI5. You now have an understanding of how to develop apps and its general functionality. While this post was quite technical, the upcoming parts of this blog series will showcase more demos & use cases and we will continuously add more features.

In the next part, we will develop abap2UI5 apps displaying tables and selection screens.

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

26 Comments
shais
Participant
0 Kudos
Amazing!
lfrey91
Participant
Hi All.. nice Discussion?

Why do they do that? Isnt it more easy to get JavaScript/TypeScript 😉 Developer, than SE80-ABAPers..

Ore takes Chat GPT from here?
shais
Participant
Well, to begin with, I don't see any Javascript developer writes logic in the ABAP backend.
axel_mohnen_ctie
Explorer
Hi oblomov,

Thanks a lot for that interesting blog series.

One question: Is it possible to create a value help based on the binded field DDIC type?

In you example I only see fixed value list.

Thanks a lot.

Kind regards

Axel
oblomov
Active Participant
Hi Axel,

thanks for reading this blog post!

The fixed value list is only an example. You can also call a function module or read database tables to get the allowed input values. When you want to use the values of an DDIC value help, you have to read this manually with abap and then send it instead of the fixed values to the frontend (there is no build in function for this like dynpros or seelction-screens have).

Regards

 

 

 
There are several reasons  : One developer does all in a small application. Software creators can better use there ressources, there are better concepts than pure MVC, which is anyway broken with UI5. To support several UI Types, view shouldn't have to much logic..
axel_mohnen_ctie
Explorer
Hi Oblomov,

thanks for the reply. I saw you new demo class "Z2UI5_CL_APP_DEMO_09" for the F4 custom popup. This was exactly what I was looking for!

Another question:

Are you able to run the ABAP2UI5 service embedded in the SAP Fiori Launchpad? I created a target mapping in the FLP customizing for external URL, but this runs the app in a separated window.

Is there a way to run the app embedded in the FLP? Maybe having a generic SAPUI5 component with the ABAP2UI5 app ID.

Thanks a lot.

Kind regards

Axel
oblomov
Active Participant
Hi Axel,

I never really tried to embed abap2UI5 in the FLP, but so far i know you can only embed UI5 applications which base on a component container, because the FLP replaces the index.html.

Due to the fact that abap2UI5 is based on a single onepage index.html file it should not be possible to embed it in FLP. You can only use it with a separated window. But if you find out something else, let me know! Till now I did not do a lot of research in this direction.

Kind regards!
axel_mohnen_ctie
Explorer
Hi Oblomov,

I found a way to embedded the ABAP2UI5 into UI5 app.

I created a simple SAPUI5 freestyle application based on the Fiori tools template.

Just added the following pieces in the controller and view.

Finally, I'm adding an "iFrame" on the fly to the XML View.

We could build the wrapper even more generic by passing the ABAP2UI5 app id via FLP target mapping parameter.

controller.js
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/core/HTML"
], function (Controller, HTML) {
"use strict";

return Controller.extend("ZAMOH_ABAP2UI5_TEST.ZAMOH_ABAP2UI5_TEST.controller.View1", {
onInit: function () {
},

onAfterRendering: function () {
//Get apphandler
var oPage = this.getView().byId("page");
var sIFrameId = "iFrameId1";

var sUrl;
sUrl =
"/sap/bc/http/sap/zabap2ui5srv?sap-client=040&amp;app=ZCL_AMOH_ABAP2UI5_TEST_01";

//Set HTML "iFrame" content
var sContent =
'<iframe id="' + sIFrameId + '" height="98%" width="100%" frameborder="0" src="' + sUrl + '" ></iframe>';

//Create new HTML page
var oPageHtmliFrame = new HTML({
preferDOM: true,
content: sContent
});

//Add new iFrame to page
oPage.addContent(oPageHtmliFrame);
}
});
});

 

view.xml
<mvc:View controllerName="ZAMOH_ABAP2UI5_TEST.ZAMOH_ABAP2UI5_TEST.controller.View1" xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core" displayBlock="true"
xmlns="sap.m" xmlns:html="http://www.w3.org/1999/xhtml">
<Shell id="shell">
<App id="app">
<pages>
<Page id="page" showHeader="false">
<content>
</content>
</Page>
</pages>
</App>
</Shell>
</mvc:View>
oblomov
Active Participant

Great work!

I tried it and it works 🥳

abap2UI5 Launchpad Integration

Yes configuring the app via FLP target mapping and make it usable for different apps would be great extension. I am also not sure if the theme from the launchpad is used when you call it via iframe (have no on-premise system and can not test it at the moment).

Thank you for your work!

P.S.: This is a relevant topic for a lot of users so I created an issue, feel free to join if you are also on Github.

Octav
Participant
0 Kudos

cmx78_alpha Hi, would you like to explain this statement :"...MVC, which is anyway broken with UI5."

Thanks

aoyang
Contributor
Having able to create visual charts really raised the value of this ABAP2UI5 project(blog part4). It's great alternative if you only have ABAP resource and required UI5 applications.

Although there are more JavaScript developers out there, they can only create front-end and limited backend(with CAP model, but restricted to side-by-side extension) . The beauty of this ABAP2UI5 framework we cannot take for granted is that it works in all ABAP environment(on-prem, SteamPunk, Embedded SteamPunk), therefore suitable for both side-by-side in BTP and developer extensibility in S4 core.  So today, knowing ABAP alone will let you create full-stack UI5 applications, in all available ABAP stacks.

Really admire your work and looking forward to more feature upgrades!
hardyp180
Active Contributor
0 Kudos
I am also interested into how UI5 breaks the MVC model. WDA did clearly,you could put business logic into the view if you wanted, the exact thing it was designed to get away from,  but with most UI5 applications the model is in ABAP< the controller is in JavaScript and the view is in XML. I cannot think of a better way of enforcing the separation of concerns than having each element in a different language,

Presumably you think one of the MVC layers is doing more than one thing. Can you please elaborate?
jathinvarma11
Explorer
0 Kudos

Hi,

If we are using On premise SAP 750 system, how can we call the app through SICF? Do we need to add Handler class to /sap/bc node?

Can anyone please explain. Basically I have installed Abap2ui5 but yet to figure out how to test the demos provided.. 

 

Thanks

Jathin

oblomov
Active Participant
0 Kudos

Hi Jathin,

yes after creating a new ICF node, you have to create a new http handler class. In the method if_http_extension~handle_request you can call abap2UI5. Check the installation guidelines in this blog post. You can also create an issue if you run into further problems.

Best Regards.

oblomov
Active Participant

Hello aocheng,


Thank you for your comment! It's fun working with a plain HTTP handler and exploring what's possible with HTML, UI5 or htmx. I also discovered your blog post about this topic:

https://blogs.sap.com/2022/04/08/exploring-web-app-development-with-abap-htmx-in-comparison-with-aba...

Great work!


Best regards!

YW
Explorer
oblomov

Is it possible for SAP to install your Open Source as a default feature on SAP system? (on-premise  and Cloud).
oblomov
Active Participant

everyone is allowed to deliver open-source, so you have to talk with sap about this 😉

pbist0103
Participant
I am sure SAP is aware of Neptune and  what they offer a totally ABAP based model. If SAP really wanted to make us all ABAPers Fiori Developers, they could have either acquired them or taken inspiration from them. Rather than that IMO SAP wasted millions in RAP a very inefficient model and that will never survive, either it will wither away or SAP will keep changing.

 

Isn't it funny how even CDS artifacts are changing and how they decide no more innovation for these. For years they promoted CDS with SE11 views now they have a new View and the old ones will not get the latest innovation. SAP tools team should understand that the developers outside need to develop right we do not have time for these shocks every 2/3  quarter. we need a platform and tool sets that work and lets us deliver and of course offers new features rather than breaking something every few months and years that was already working.

 

SAP has partnered with Apple and Google, so I don't see any dearth of inspiration. May be the CTO should rein in. It's good to be creative but sometimes over creativity delivers half baked unuseable tools that are frustrating in the market.

 

Prasenjit
pbist0103
Participant

CDS as the panacea for everything- Fiori, Analytics and everything sis a flawed concept. The whole CDS files full of annotations and BDL again some these that is the most in-efficient way of doing things.

The last model ODATA, BOPF with UI5 at front end was the most elegant clean approach where you had clear MVC paradigm . SAP will delete the comment so won't use but I don't know what to call this new model a very less intelligent model because it looks like a spaghetti code.

 

I did Analytics with CDS annotations and I appreciate it but Fiori with RAP is constrained and an ugly model a very ugly one. I even used Neptune and look at the tooling that is  world class from a small company. The problem is SAP forces us to use these tools and models that are half baked and like some tools earlier SAP will drop and move on promoting new tools with huge marketing budget but for us and our clients it is a huge investment.

 

A plain stupid question Paul as you are a member of the core SAP mentors, Vishal and Bjorn promoted clean code, timeless software does the current model goes anywhere near those lofty goals? What do you think? I wonder what Bjorn Goerke and Vishal Sikka think when they look at the new innovations and toolsets. I expected Apple like professionalism from SAP- a tool that works and then stop it there, these daily tinkering and half baked things as if SAP is a university lab is not what I expect after 16 years in SAP. They now even have 2 types of CDS one with SE11 view and one without and the new ones get new innovations so  all those we created are sitting ducks. 

I think the reason why SAP customers don't pick new innovation sis this lack of trust on SAP. I worked at a German manufacturer and I recall the Solution Architect telling us in open town hall we will wait a decade and then see if it even lives and then deicide to opt for it. I laughed that time but now I realise those were words of wisdom. Never ever jump on anything new SAP has use Module Pools and Open SQL and after decades if those new CDS, Fiori survive and they finally stop tinkering and release a final version then if it makes sense then adopt else just ignore and keep running because as Rimini Street proved that too is a successful business model.

 

Note: I called the RAP model and  CDS with annotation ugly i.e. the technology.

Prasenjit

pbist0103
Participant
0 Kudos
I think he refers to the RAP model not the clen model where u have ODATA and UI5 in separate files and separate stuffs. RAP surely breaks it's a spaghetti model.
pbist0103
Participant
Great stuff oblomov . I have used the Neptune package and that is a licensed product and really world class but I liked this open source initiative as well. All the very best.

Prasenjit
CarineTchoutouo
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi - see my response here.
Best regards
CarineTchoutouo
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi - see my comments on RAP and ABAP CDS here:

Best regards

pbist0103
Participant
0 Kudos
Miss Djomo, Why is it so that in CDS views the elements are separated by ',' and the ;ast element does not ends with a ',' but in db tables and metadata projections it is ';'. Somewhere it has to end with a ';' somewhere not. Why this inconsistency or there is a purpose behind these syntactical inconsistencies that are hidden features?
Yogeshwaran
Explorer
0 Kudos

Well , i have a doubt , how component.js can be replicated here , there we can declare all the json models and try to bind those in view.I want to know how to do this in abap2ui5?

Labels in this area