130 SAPUI5, SAP Fiori, HTML, CSS, JavaScript & JQuery, Interview Questions & Answers
130 SAPUI5, SAP Fiori, HTML, CSS, JavaScript & JQuery, Interview Questions & Answers
After I published my interview questions on SAP HANA ABAP, there were lots
of request for next series of interview questions and answers. As I
mentioned in my other article, we cannot judge someone’s knowledge by how
they answer some questions. There are very good technical architects who
can design are deliver complex projects but if they were to appear for an
interview, they might not come out with flying colors.
Reason is simple. Sometimes, interviewers are in a mode of rejection (in which case,
even God cannot help you) and other times, the candidate is not coherent in speaking
out the right answer in sequential and logical format (even though they know the exact
answer).
I have faced few interviews in my career and I believe, interviewers hunt for some key
words. If they find those words they are expecting in your answer, they are inclined
towards selecting the candidate.
With the hope that these questions and answers will help that needful
candidate who wants to crack the interview for his next project/job, I have
made a question and answer series from my learning notes. Please note,
you still need to have your fundamentals clear by diving deep into each topic,
but this short Q&A might help you revise your understandings and test
yourself.
In between the Q&A, I have filled in some tips and notes. Do go through them as
well.
Also Take – Free Video Course on Associations in ABAP CDS on HANA
1. Responsiveness
2. Device Support
3. Platform Independent
4. Browser Support
5. Coherent in nature
6. Integration
7. Open standard
8. Documentation
A Container control has an Aggregation called Pages and in this Aggregation we can create
array of Views.
Ans. app.to
Q5. To Access the object of the control, how to get the runtime instance of
the object?
1. Initialization – load
necessary dependencies – – Bootstrap in UI5
data-sap-ui-theme=“sap_bluecrystal” >
</script>
2. Declaration – Data
variables used in program – Create UI Control
( ) – parenthesis
{ } – curly braces
[ ] – bracket
3. Actual program
business or orchestration logic – manipulation, IF, Loop, call –
display control to User
ObjectContro.placeAt(
“id of control” );
4. Output – Show
output to user
5. Clean-up
Q10. How to load the Bootstrap for UI5 framework to work in the Offline
Mode?
Reason being: Since the WebIDE local installation runs on Orion Server, which has all
UI5 Framework Libraries pre-existing in the Server. To access the libraries in the
framework, we define neo-app.json which acts as an interface between Orion Server
->> Resources ( test ) to load the framework.
Any Web Application that is understood by browser is always a HTML page which is a
static web-page. Structure of a typical web app page is a html page
<html>
<head>
( * creation of control )
</head>
<body>
( * place the control in the body )
</body>
<html>
Q12. What is SAP WEB IDE?
Why
WebIDE?
SAP Web IDE can be used in two flavours: Personal Edition ( trial purpose ) & Productive
Version ( subscription to companies )
HTML
stands for Hypertext Markup Language which is created by W3C = World Wide
Web
Consortium who is responsible for defining HTML tags and versions. All browser
vendors like Chrome, IE, Firefox, Safari.
Difference
between HTML and HTML5?
HTML5 is just the advancement of HTML, it was
released in year 2014.
HTML5 is labral in nature
Even we
put something in head of html, it will be visible to user. Ideally we
should
not do that.4
Declaration of DOCTYPE
Open UI5
is an open source under Apache 2.0 license where as SAP UI5 is a
licensed
product, this comes along with SAP Netweaver or SCP (SAP Cloud Platform
–
formally known as HCP – HANA Cloud Platform).
Encoding-type
– help user to identify the type of characters that are applicable
Author-
created by
Keyword
– reside in metatag for search engine
optimization
Description
– description about the websites in the search engines
Block level elements are used to structure the HTML content properly. These
elements don’t have their own footprint on page. Two types of block level elements:
div – Division tag,
span
– inline element
Browser converts HTML in a tree data structure – This is known as DOM (Document
Object Model). Runtime structure of HTML in browser.
Also Watch – Free Video Course on Access Control in ABAP CDS on HANA
Q21. Define <iframe> tag.
3 ways to apply CS
1. Inline Style: is just like element level styling. à too much of coding
<tagName
style=“prop:value ; prop:value”></tagName>
2. Internal
Style: Applying the style for group of elements together, it is also
possible to apply style on single element as well.
For
applying internal Style, we should use a new tag called <style> tag in
the header
of HTML.
Syntax:
<style>
selector : {
prop: value;
prop: value
}
</style>
3. External Style: It is just like internal styling but the code for styling is taken out in
a separate file and reference the file in HTML file.
Inline styling is an element level / tag level styling which gets applied to all the
elements defined in the tag. So if there are multiple elements, applying style for each
and every element is not feasible. In that case we use Internal Style.
Q24. What is Internal Styling?
Web design which adapts itself according to screen size to provide a consistent user
experience. Based on device available space, the screen adjusts itself without a scroll
bar at page level.
CSS box model is how the element is represented on the HTML page, which has
border and the actual element. The space between the border and the element is
called padding (property) and the space between two different element boxes is
called margin (property).
selector:pseudo-class{
—CODE
}
**
list of available pseudo classes can be obtained from w3cshools.com, eg. FOCUS,
HOVER etc
JavaScript is case-sensitive
Naming convention to be
followed for declaring JavaScript “variables” and
“function”
first word
should start with small letter
next
consecutive word should be camel caps or first letter of next word
should caps
Every
statement of JS should end with semi colon (;)
Object oriented
2. Perform
calculations on client side: Write imperative logic – if, looping, arithmetic
and logical operations
3. Check
conditions and operations
4. Call
server
5. Manipulate
DOM (html)
6. Change CSS
at runtime
Also Watch – Free End to End Video Course on ABAP New Syntax
1. Inline
JS – code is written at element level
2. Internal
JS – code is written at page level inside <script></script>
tag.
3. External
JS – reference an external file (.js) into your html page,
<script
src=“(path of JS file)”></script>
1. alert()
– provide a popup to user
2. Console.log
– print output to console
3. document.write
– replace whole HTML page content with write content
4. .innerText
– change text of an HTML element
the
document object provides lots of methods to obtain the object of HTML
element(s) which are APIs – Application programming Interface – represented by
a
reusable method or class.
1. document.getElementById
– single element by its id (id of html element is unique)
2. document.getElementsByClassName
– list of all elements by class name
3. document.getElementsByTagname
– list of all elements having that tag
2 types of functions in JS
In JS, these functions are executed asynchronously without lead-time of the response.
Eg. focus, click, double click, key press, mouse down, mouse up.
There are certain events which are system events which are used to perform certain
functions in the programming: eg. load, close, kill, exit, timeout.
jQuery is not a language. It is a JavaScript library which is concise and fast to avoid
writing large piece of code using JS. It is based on a principle of “write less, do more”.
The most commonly used line of code and methods are available in
jQuery to be
consumed in the application code helping developers to quickly
achieve desired
results without much coding.
Download
the jQuery à add to project
and reference locally
Reference from
internet – CDN(Content Delivery Network)
<script
src=“path of JS file”></script>
Q39. Syntax to use jQuery
$(selector).action();
$ – tell
the browser that we are going to use jQuery
Selector –
tagname, .className, #id
Action –
method, event name, on, css(‘prop’,’val’)
$(selector).action(params,
callBackFunction());
When a method is called in JS, another method can be called on top of it.
Eg. object.method1().method2().method3();
object.method1(); object.method2() ; object.method3();
It is a function which
gets triggered when a particular operation is completed.
Typically Call Back Functions are
asynchronous and anonymous.
syntax: object.function(callbackFunction);
.hide, .show, .fadeOut, .fadeIn, .animate
https://openui5.hana.ondemand.com/#/api
SDK refers to Software Development Kit. It’s a repository of API’s and related
documentation, to be referred to develop applications based on particular
technology.
SAP UI5 SDK offers latest updates on the framework. It gives the
latest information
about the evolution in SAP UI5 technology like version, API
reference, Sample
applications, ICON explorer etc
https://sapui5.hana.ondemand.com/test-
resources/sap/m/demokit/iconExplorer/webapp/index.html
For every UI control in SAP UI5, there is setter and getter method to change and
read the text of UI control.
Q44. What are different ways to obtain object of SAP UI5 control?
sap.ui.getCore().byId(“id
of your control”);
OR
Note that -> the control name always starts with capital letter. Pure camel case.
sId:
Unique ID of the control.
sProperties:
the attributes/properties of the UI element. All the properties should
follow
below syntax
{
propname: “prop val”,
propname: “prop val”
}
1. Aggregation:
lose coupling, good to have relationship. Both objects can function
independently.
2. Composition:
tight coupling, objects cannot function independently. Must have
relationship.
Q48. What is Design Pattern?
Design
pattern are formalized best practices that the
programmer can use to solve
common problems when designing an application or
system. Types of Design Patterns
are Structural,
Creational and Behavioural.
JSON views
HTML views
getControllerName: function(){
Return the controller name of the view;
}
createContent: function(){
Return objectOfUIControl;
}
onInit() – this method gets called when the object of the controller is instantiated
onExit()-
onAfterRendering()
onBeforeRendering()
Q55. How to specify the path of the root folder, in the app, where your view
and controller resides?
data-sap-ui-resourceroots=‘{ “rootnamespace” :
“./” }’
jsonlint.com
sap.ui.core.mvc.ViewType.JS
sap.ui.core.mvc.ViewType.XML
sap.ui.core.mvc.ViewType.JSON
sap.ui.core.mvc.ViewType.HTML
Yes.
Also Watch – Free Video Course on Introduction to HANA, HANA DB and ADT
for Beginners
Q61. Can we have a single controller for all the views?
Q62. Why you see XML views are preferred, Why SAP recommends XML
views, Why standard Fiori Apps delivered by SAP has XML views only?
IF_IXML,
CL_XML_DOCUMENT…IF_IXML_NODE etc. (XI)
namespace:<controlname(Button)>
Statement: If we do not pass the <nameofmodel> this model acts like default model for
entire application and all UI controls will seek data from this model. If there are multiple
models in a single application, this becomes a confusion for application and UI controls to
pick data from which model? In this case we will give an identifier to the model which we
are setting as model name. in order to refer the model name we use “modelname>”
{
“empStr”: {
“empNo”: 100,
“empName”: “SAPYard”,
“salary”: 900,
“curr”: “EUR”
},
“empTab”: [{“empNo”: 200}, {“empNo”: 300}, {“empNo”: 400}]
}
To change and access the data in the model object we use binding.
Q71. What are different APIs to access and change the data in the model
object?
In the Controller, we can set the default binding mode for the
Model:
OR
OR
4. Element Binding
Typically – in a Master-Detail
Functionality in SAP, whenever, user clicks on a Master
record in the view,
corresponding detail data is displayed in the Detail View
A Template Aggregation of a control identifies how the control will be displayed on UI.
It provides the control with information about what type of control we want to assign
to the column and defines what kind of behavior is expected from the aggregation.
e.g. textfield, dropdown, label, radio, checkbox.
In order to convert the format of the data before displaying on the UI, a function is
utilized to change the format of the data before binding it to the UI element. Such
functions are called Formatter Functions. In short, these functions are utilized to
format the data and its type, which is supplied to the UI.
Syntax:
New library.ControlName(“id”,{
property: {
path: ‘model path’,
formatter: reference to the function
}
});
.bindProperty(“path”, formatterFunction);
VIEW
CONTROLLER:
implement the function in the controller
These functions can be defined in separate file called formatter.js globally, and can
be utilized in any view-controller logic to apply the formatting.
Functions that are specific to a View and Controller are NOT re-usable. Especially
functions which are UI specific and not data intensive or application logic : when
required to be reused in other view-controller, need to be defined outside of the
particular view-controller area to achieve RE-USABILITY functionality. This concept is
called as Custom Control in UI5 where it’s a JS file with a set of functions which you can
reuse across multiple controllers of an Application to achieve necessary functionality such
as conversion, formatting etc. ( just like INCLUDEs or FUNCTION MODULES in ABAP)
Syntax:
So bring all the functions() from sap.ui.controller
to the scaffolding template
Bring your entire Model code from Init function of the controller to
model.js , this is
following MVC pattern in the architecture
Q82. What is the purpose of “ use strict “ in the controller?
The keyword “use strict” with throw a syntax error if the dependency is defined in
the scaffolding and not used anywhere in the controller logic.
Q85. How to create a Global Variable in controller.js file for core libraries?
1. onExit() ->
2. onBeforeRendering() ->> This method gets called before the UI is displayed to the
USER : i.e UI modification before it is displayed to the USER : eq. Auth checks, UI
modifications before the UI is rendered. But : effects like jQuery will not be displayed
since UI is yet to be displayed.
It is like
the PBO event in ABAP
3. onAfterRendering() -> this method is triggered once the UI is loaded/ so all your
“jQuery” effects and CSS can be applied in this method
Key Features:
Integration capabilities
Role based
Q90. How does a Fiori based UI5 application set-up look like?
(Here the container control acts as a parent control for all the views which
establishes the communication/navigation between different views)
Container Control ( it can be an App Control or a Split App control -> which is
essentially a “View” )
oView.byId(“idSAPYard”).addPage(oView1).addPage(oView2);
And to Navigate from the first view to second view by clicking on a button in the first
view:
Please note ! -> that if you want to find more properties for a particular control : you
will always find it in the parent class
Q94. How to get the path of the element? ( V V IMPORTANT in how to get
control/element details in the function event object!
Get the path of the second view and then bind the
element to the path of the second
screen
1. Grouping/Sorting Items
2. Different modes of Selection
3. Delete Item
4. Search/Live Search / Fuzzy Search ( suggestion )
Note!! -> That when you are not in the controller logic, in the event handler method
—debug mode, “this” pointer will not return anything, to get the object of the control
element, use “sap.ui.getCore()”
sap.ui.getCore().byId(“id”)
It appends the parent id before control id e.g. if we have a list(l) inside a view (v) ->
v–l
this.getView()
this.getView().byId(“idSpidy”)
sap.ui.getCore().byId(“idSpidy”)
Q102. Which Control gives features such as colors and icons to a Text
Control?
NOTE! -> this will explain you the concept of Fragment defined once and re-used
multiple times
NOTE!! Always remember, inorder to retain the I/O on the pop-up fragment, always
define a global variable for the object, so that the properties of the pop-up are
retained if any user-action is done on the pop-up.
SetSelectedvalue in the pop-up back to the input field -> function “onConfirm”
*** try .addDependent for the pop-up to make “this.getView()” to work to get
the ID
of the control
The
syntax to add multiple filters is :
Which is used to
design/define a custom control
A renderer converts the code to equivalent HTML, CSS, JS code which the browser
can understand.
(
eg. <h1> tag which is not given by SAP UI5 standard )
Step
1. Create New folder “Controls” in your application Project
Step
2. Create File “<name>.js in the Control Folder
Step
3. Define Scaffolding ( dependency ) using sap.ui.core.Control inside your js
File
and define Function inside the scaffolding
Step
4. In the return function: define the Control inside
Control.extend(“<path>”);
** path
= workspace.controls.libraryname
Step
5. Follow the Syntax ( refer image above )
Refer to Control Documentation -> SAP UI5 SDK
** In Order to
check the version of your UI5 app -> press CTRL+ALT+SHIFT+P
Q116. What is Component.js ?
Whats
a Fiorilike App – Application which has Component.js inside.
Important Point:
Purpose of Component.js
Extensibility concepts
Syntax:
sap.ui.define([“sap/ui/core/UIComponent”],
function(Component){
sap.ui.core.UIComponent.extend(“namespace<path>”,{});
It tells the system which is the Starting / Initial View for the application
Q119. How does Navigation typically work in the browser? ( <- -> when
users clicks the back and forth button )
A browser tracks the history of each selection on the webpage which has its own
“tag” ( a unique identifier – in its unique state ) which allows it to restore the page
when the user clicks on <- -> button in the browser.
Configuration Section
1. Router class
3. Type of views
4. Container that contains all the views ( App / Split App etc )
2. View that should be loaded which is called as “target” à viewName, id, where to
load ( pages)
Master/Detail
Eg:
URL will be like below for the routing tag name.
Q124. Defining a Unique Tag (ID) for each click and each object list item in
the Master List?
Another way of passing the parameter :
Route
Match Handler example in Master Controller:
** Steps to get ES4 Gateway Server connection on sap
cloud – vid 34
Open standard
Easy to implement
EntitySet – representation of a
real-world object e.g. Material, Sales Order, Sales
Order Item etc. All the CRUD operations are applied on
Entityset – Entity set can be
identified in the metadata of the Service :
Following are the URL’s *as an example* to access different documents of an OData
Service:
Q127. How to access huge amount of data from an OData Service, if the App
in used on a Tablet or Mobile which cannot handle that load?
Note! -> there’s no need to type all these paging and filtering statements in the
service URL, SAP Fiori is capable to create that URL with the relevant filter/paging
statements
<your
webide folder>\eclipse\config_master\service.destinations\destinations
https://help.sap.com/viewer/825270ffffe74d9f988a0f0066ad59f0/Cloud/en-
US/fb956be1440745f89f1445e605096af8.html
Q130. Applying paging concept on the List Control in the UI5 App
Similarly for
“search” function : on clicking search button in the app :
You gave lots of love and shares to my previous 115 ABAP on HANA Interview
Questions & Answers. If you like this list, please do share the page with your
contacts, colleagues and team members. You never know, someone other than you
might be benefitted.
Please add SAPYard’s Whatsapp Number to your Contact List and send a
whatsapp app message ‘LEARN’ to +1-646-727-9273/+1-646-SAP-YARD to
be part of our Learning Community. You may Whatsapp message using this
direct link.
Please SUBSCRIBE to SAPYard’s Youtube Channel for Free End to End SAP
Video Course and Training.
Telegram SAP Technical Discuss Group. You need to install the Telegram App
first on your mobile device. Once you have it on your mobile, you can join the
group and also access it from the Web on your computer and laptop.