ABAP on Cloud – 15 – Advanced Topics – 2 – On Screen Validation for Managed Scenario

0
2520
ABAP on Cloud Advanced Managed Unmanaged

EMLEntity Manipulation Language is the term used widely in ABAP RESTful Programming. In this article we shall get a glimpse of the EML, which is used to control the behavior of the business objects that are created on top of the root views or DDL sources.

There are two kinds of EML, one known as Standard API based and other Generic API for Business Objects integration with other frameworks.

We will see many variations of the EML in upcoming articles.

For validating our on-screen fields we shall use few EML statements which will clarify the concepts. In the last tutorial, we stopped with just few EML statement. Let’s continue where we left.

STEP 11:

First EML syntax is below:

READ ENTITY <root_view (entity name)>
FIELDS ( <field_to_be_validated> )
WITH CORRESPONDING #( <sub entity> )
RESULT DATA( <internal table> ).

Filling the right inputs we get following :

a. Field is the Employee ID, on which we are applying a validation.

b. One change has been done is to differentiate Entity name versus sub entity or input parameter table.

Funny thing about this syntax is : SAP itself is yet to include in the documentation and help topics.

Proceeding further, lets add a normal READ statement and IF-ELSE statement along with Message Class to display error.

STEP 12:

First let’s create a Message Class to add custom error message. To achieve that follow next steps:

Once added just save ( Shortcut : CTRL + S ) 🙂

Go back to ABAP Class where behavior implementation is done.

STEP 13:

Second EML syntax is below:

APPEND VALUE #( %key = <work_area/data>-%key
%msg = new_message( id = <message_class>
number = <message_num>
severity = if_abap_behv_message=>severity-<enum_value> )
) TO reported-<entity>.

a. severity can be following enumerate values:

b. Standard Parameters are also provided by SAP for EML.

So, let’s code now.

Here, the sy-subrc check and if the Employee ID is initial form the other non-descriptive code.

STEP 14:

To test the functionality we need set a break point in this code and trigger from Application Preview.

First activate the class. Then just double click on the line where the break point needs to be set.

STEP 15:

Create a Metadata Extension, a Service Definition and a Service Binding. To do that refer the following links:

a. Metadata Extension
b. Service Definition and Binding

STEP 16:

Let me trigger a preview:

STEP 17:

Click on “Create” without entering any value in Employee ID field.

STEP 18:

Check if the back end code break point is triggering and execution of LUW stops near that point.

STEP 19:

Complete the execution by pressing F8 from debug screen to see the error message in Fiori Preview App.

AMAZING !!!!

But, here there is any issue ??!!

It does not stop the creation of new record. Just informs the end user with a message but the creation of new record process gets completed.

Go back to landing main page and see if this record is added.

Undesirable ! How to overcome this? Step 20 in next article of this series will explain that! We will cover such handlings in our next tutorial. Please stay tuned.

Please follow our LinkedIn Page,LinkedIn Group, Facebook Page, Facebook Group, Twitter and Instagram.

Do not forget to SUBSCRIBE to our YouTube Channel for Free Courses and Unconventional Interesting Videos.

Also consider joining SAPYard’s Telegram Channel for SAP Blogs and Tutorials.

Save our number +1-251-727-9273 and send us a Whatsapp message ‘LEARN’ to be part of our Learning Community.

All ABAP on Cloud Tutorials

Also Check BAS – Business Application Studio Tutorials

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here