Saturday, October 27, 2012

SAP Webdynpro ABAP Interview Questions Part 2


Welcome to part 2! Here we go ahead with some more questions . I wish these questions offer some value to you. 


If you have already worked on web dynpro , these questions should be easy for you . Even if you haven't had a chance to work on Webdynpro ABAP , these questions will guide you for your interviews . In that case, I would suggest you do some hands on exercises on a sandbox server at least.  


Imp* 
Question 16:What is an Assistance class in webdynpro ABAP? Where do you define an assistance class? How many assistance classes can a webdynpro component have?
Assistance class helps you achieve two things:
1) Segregation of business specific logic (one of the purpose of MVC).
2) Performance benefit.                                                        

We can write the business logic in the methods of the View, Window or even the Component controller. But it is not a good practice to load all the business 
 logic in the views or windows. So SAP has provided an option of assistance class where you can write all your business logic. By this way, you are still in the framework of your webdynpro and also avoid loading too much logic in the components of webdynpro itself. Assistance class methods are much better from a performance point of view than calls of Web Dynpro controller methods.

A web dynpro component will have only one assistance class and it is defined at the component level as per the screenshot below. The assistance class is automatically instantiated when a component is called. You can access the instance of this class with the attribute wd_assist, which is created when you create the assistance class in web dynpro.
   








Imp* 
Question 17: What is Singleton Property of a Context Node?
Understanding Singleton property of a context node and how it works in conjunction with the lead selection event can be a bit complicated. If you do not already know what a Singleton set is , I recommend you going through an example of Cars(Parent node with cardinality 0..n ) and Customers ( Nested child node with cardinality 0...n ) on Singleton Node by clicking on the link. This is not that tough , just spend some time with it and you should be okay.


The best way to answer this question is by taking an example.
Say there are two ALV's on a View:
ALV1 ---> 
NODE_SO_HEADER----> Displays all the Sales Orders. 
ALV2 ---> NODE_SO_ITEMS ------> Displays all the line items for the Sales Order selected in ALV1. 

NODE_SO_ITEMS is the child node for NODE_SO_HEADER and is declared as Singleton node.
Since this node is declared as singleton , at runtime , it holds the line item data only for the Lead Selected Sales Order from NODE_SO_HEADER and not for all the Sales Orders from the parent node.
Whenever the lead selection changes for the parent node, line item data for that lead selected order is fetched from database and populated in the child node.

As a result great performance optimization is achieved.

I hope you get this one :). 




Question 18: What is a supply function? When is it called?
You can assign a supply function to a context node when you create a node. In simple terms, supply function is used to populate data records in the context node. A supply function is called when one or more elements of the node are accessed for the first time.

Supply function in web dynpro
Supply function in web dynpro
To give you an analogy, we all know that a constructor method of a class is called whenever an object of that class is instantiated. In the same way, a supply function for a context node is called when the node is accessed for the first time.

The supply function is generally used in combination with singleton nodes.So whenever the lead selection of the parent node changes , the supply function of the singleton node recalculates and repopulates the child node.



Question 19: What is lead selection? Is it an event?
Yes , the lead selection is an event in web dynpro.
At run time a context node may contain many records , but only one of those is selected .
The user can select any record from the Table/ALV and this selection is called lead selection. 

Lead selection in web dynpro
Lead Selection in Web Dynpro
Question 20: What is Cardinality of a context node?
Cardinality simply indicates the minimum and the maximum no. of entries the node can have.
The 4 cardinalities are 0:1, 0:n, 1:1, and 1:n .


Question 21: Is there any relation between Cardinality and Lead selection?
Yes , If the cardinality is set to 0:1 or 1:1 , the user cannot select multiple records on the view.
So if you want the user to be able to select multiple records on the screen , the cardinality of that particular node must be set to 0:n or 1:n.


Question 22: Some important Web Dynpro attributes that you should know:
Some attribute in webdynpro that are used very frequently and some of those that you must know are :

Wd_this
Wd_context

Each controller has the above two mentioned attributes.
To elaborate, if you are using the above two attributes say in a method of a View Controller, then WD_CONTEXT is the reference to the Context node of the View and WD_THIS is the reference to the View Controller itself.


Wd_comp_controller
 is the reference to the Component Controller. View and Window controller have this attribute defined by default and methods/attributes of the Component Controller can be accessed by using this attribute.
For example:


Wd_assist:
 This attribute is created when the assistance class is saved and activated for a web dynpro component. All the methods of the assistance class can be accesses by using this attribute.



Question 23:
 What are layouts in Web Dynpro ABAP?
Flow layout, Row Layout, Grid Layout, Matrix layout and the form layout.
The layout can be set at a Container level.

layouts in web dynpro


Question 24: Can you use multiple layouts in one view?
Layouts can be assigned at the container level. For example, you define the layout for your view at the ROOTUIELEMENT container level.
So if at all you want to use multiple layouts in one view, you can create multiple transparent containers and assign different layouts to them.



Question 25: How do you introduce line break for a UI element in any layout?
Say if you are using matrix layout, you will say Matrix Head data for the UI element for which you need a line break.


Question 26:Can you call/launch one web dynpro application from another webdynpro application?
Yes, you can launch one webdynpro application from another webdynpro application.
First, you should get the URL of the web dynpro component that you want to launch and second, call that URL in an external window.
To get the URL of any web Dynpro component, you use the FM 

CALL METHOD 
cl_wd_utilities=>construct_wd_url    

    EXPORTING
      application_name = 
'ZDEMO’
    
IMPORTING
      out_absolute_url = str.
  
Once you get the URL in str, you can call this web dynpro using 'str' and fm: create_external_window.


Question 27: Can you create a Tcode for Webdynpro Application?
How to create tcode for webdynro ABAP
Creating Transaction code for Web dynpro ABAP 

Yes, you can create a Tcode for webdynpro application. Go to SE93 , create Tcode, choose the last option and maintain default values as shown in the screenshot:



  
























Question 28: Can you pass parameters in a webdynpro URL?
Yes, you can pass parameters in webdynpro URL and read them too in your web dynpro component.
Example: http://domainname.com:8000/sap/bc/webdynpro/sap/zdemo_webdynpro?sap-language=EN&var1=4500000001&var2=00010



Question 29: How do you read parameters passed in the Web Dynpro URL?
First lets understand how a typical webdynpro application looks like:
When you create a web dynpro application , you can see the link URL generated by web dynpro.
It will be something like:
 http://domainname.com:8000/sap/bc/webdynpro/sap/zdemo_webdynpro?sap-language=EN&sap-client=100.

Whatever comes after the ‘?’ and is followed by ‘&’ is an URL parameter. You can see sap-language and sap-client as default parameters whenever you launch your web dynpro in browser. The cool thing is you can add some custom variables too. 
http://domainname.com:8000/sap/bc/webdynpro/sap/zdemo_webdynpro?sap-language=EN&sap-client=100&var1=4500000001&var2=00010.

So var1 and var2 are custom webdynpro URL parameters and you can read them in the HANDLEDEFAULT method of your main window:



Question 30: Can you run a Webdynpro Application in background?
This is a tricky question. It doesn’t make sense to run a webdynpro application in background because in that case you are beating the purpose of the MVC controller architecture for webdynpro. However, you can build logic to create background jobs from a Web Dynpro Application. 

So we have by now put a bunch of questions here . Let me know how do you find these questions.
We haven't yet covered Web Dynpro component usage , ALV, Select Options , OVS , the coding part in web dynpro, Web dynpro enhancements etc.

No comments: