Showing posts with label Implementation. Show all posts
Showing posts with label Implementation. Show all posts

Friday, 12 February 2016

Basics of ABAP Webdynpro: Getting familiar with Webdynpro jargons part 3

Internal/Context mapping: We can define context node at any of the available controller. However as WD component controller works as a global one, context node defined there is accessible in any other controller. We just have to drag and drop those WD component controller context node to the controller we want them to be used. In that case, if we define any value to this node at WD component level, this value will flow to the other controller where it has been used. And also if we make any changes in that context node in controller where it is mapped, that value will flow to WD component level also.

External/Cross component context mapping: In one of the earlier posts we have seen what component usage is all about. Suppose we are using WDC1 into WDC2 through component usage. Now context mapping between a context node, which is in interface controller of WDC1, and a context node of WDC2 will be known as external mapping. In that case context node data from WDC2 will flow to WDC1.

Hook methods: As soon as you create a WD component, many hook methods will be automatically will be available at WD component level, view level, Window Level. In one of my post, I have very elaborately described about the Hook methods and their order of triggering in normal as well as in special scenarios. To know more ClickHere and Here

Singleton Node: We will understand this with one example. Suppose there is one node which will have sales order header related information. Now this node has another sub/child node which is meant for the item level information. In normal scenario if both of these nodes are normal node, if the parent node has 10 header records, child node will have the item level information of all the 10 sales order.

Now in case the child node is defined as singleton node, this child node will only contain item level information for the sales order which is currently selected. This is huge success in improving the overall application performance.

Supply function: While defining the context node we can give the supply function also. This supply function is meant for providing a value to the context node. Supply function will gets triggered if the data of the context node is being used and its value is either initial or invalid. Context node’s value will be invalid if it’s a singleton node and the lead selection of the parent node has changed. In that case supply function will get triggered and will calculate the new value based on the parent node’s data.

Apart from the ABAP Webdynpro terms I covered in last 3 posts, I have already shared many ABAP Webdynpro related posts in my blogs. While you can go through the blog to find more, here are few links of the important posts.

Deploy ABAPWebdynpro application in SAP Enterprise portal 

Default leadselection in ALV in ABAP webdynpro

Disable empty rowscoming in Webdynpro ALV

Dump (System_name :is not a valid attribute type) in starting the Webdynpro Application 

Radio button as a cell editor for a column in Table UI element - Part 1 

Radio button as acell editor for a column in Table UI element - Part 2 

Different types ofwindow creation in Webdynpro

Cell Variant: A wayto use multiple editor in a single table column in webdynpro ALV 

Floor Plan Manager:FPM application using OIF


Use ofIF_FPM_UI_BUILDING_BLOCK interface in FPM and triggering sequence of itsmethods 


I’ll continue posting more basic concepts and exercises in my further post. Till then Happy Learning :)

Sunday, 20 September 2015

BADI implementation

Here we go witht he step by step guide on BADI implementation. In the first 2 posts, we have seen about the creation of BADI and about the fallback class. Here is the quick link of earlier posts. Post 1 & Post 2 . In this last post of this BADI series, we'll see about BADI implementation.
First Approach:
Go to the enhancement spot and click on the create BADI implementation button.


Give the Enhancement Implementation name and it's description. What enhancement spot is to BADI, the same is Enhancement implementation to BADI implementation. Enhancement implementation contains the BADI implementation.



Because we have a fallback class in place, we will get the below information.


Click on empty class.



Click on method to implement it.


activate every object. Now execute the program which we created in last post, where we use this BADI. Earlier because there was no active BADI implementation, fallback class's method was executed. This time because an implementation does exist, method from implementation should be called.

The highlighted text is coming from BADI implementation.

Second approach:
Because we have created this BADI, so we are aware about the enhancement spot name and everything. Otherwise in daily business when technical developer doesn't know about which BADI needs to be implemented, we take help of method GET_INSTANCE of class CL_EXITHANDLER. This class comes into picture whenever a BADI comes in a code. GET_INSTANCE method gives us all the BADI names which are being used in a screen. So all we have to do is to put a breakpoint at this method and do the normal execution. Everytime control stops at this breakpoint means a BADI has been used and parameter EXIT_NAME of method GET_INSTANCE gives us the BADI name. These BADIs are the classic BADIs. In SE19 we have that option of New BADI and Classic BADI. So now we have the BADI name and we need to implement it.

Goto SE19. In create implementation block, choose the classic BADI option and give the BADI name.
  
 Click on Create implementation button





We can see the implementing class here and we have 2 methods here. We can go inside that methods to implement it. 


So this is how we implement the classic BADIs.

Happy Learning :)

Monday, 14 September 2015

Fallback class: A workaround of BADI implementation

In earlier post we discussed about why we need to create BADI and steps to do it. If you have missed that post Here You Go

As we have now created the BADI, we would be seeing how to use it in our code. I have created a simple ABAP program with one line to print.


Now I'll be calling that BADI in the code.


Now if we execute this program, it will go into dump.


The reason for this is that there is no active implementation exists yet for this BADI.

Note: Remember this dump occurs only if  'Multiple Use' option is unchecked in BADI definition. Means if you use in your code a BADI, for which multiple implementation CAN exists, but no active implementation yet exists, this dump will not occur.

So what is the remedy for this dump ? Well, we have not one but three :)

The very first is to catch the exception CX_BADI_NOT_IMPLEMENTED in your code. like below. Code will not go into dump instead will print the last line.



Second option is to implement the BADI, which we will cover in next post.

The third and the last is the magical Fallback Class :) . The dictionary meaning for fallback is 'an alternative plan that may be used in an emergency'. That's what exactly the fallback class is meant for.

Fallback class comes into picture when there is no active implementation exists for the BADI. In such case the code in fallback class's method executes. As soon as an implementation exists in system, the implementation call will be used automatically. This fallback class we give when we create the BADI definition.

We will be ticking the option for call Fallback class and a class name needs to be given there. Click on adjacent edit button.

Now if you execute the code, Both texts will be printed. One from the fallback class and one from the actual code.


Happy Learning :)

Friday, 4 September 2015

Creation of BADI

Yes, you heard it right..It's about creation of BADI not the implementation of an existing ones. :)

So why do we even need to create a BADI? Well, SAP comes as a product to us SAP folks. Product means we are not allowed to touch the SAP standard code. When required we can only enhance the standard code. This enhancement works alongside the standard code. BADI is one of the few enhancement techniques SAP gives to us.

So, what if we create say some tool in SAP and we have few customers also who use that tool. Sounds cooool :). So to customers, this tool is a product. They must not be able to touch the standard/basic code of the tool. Now if user wants to do some sort of enhancement in the tool (of course they would be, they have paid for it), we have to provide the BADIs to accomplish this. So that's oen of the few cases where we would be creating BADIs.

Enhancement spot: Enhancement spot works as a container for BADI definition. Single enhancement spot may have multiple BADI definition.

BADI definition: BADI definition is the place which contains the interface. That interface will have methods in it. When we say we are implementing that BADI, we actually create a class, use that interface in it and implement the methods. These implementation of the methods are the place where user would be writing the custom code.

To start with, we would be creating an enhancement spot. Go in appropriate package, right click on it and follow the below path.



Now create BADI definition.




 You can check or uncheck the Multiple Use option, depending upon your requirement. If you want to do more than one implementation of the BADI, leave it as checked.

Create interface for BADI definition and activate everything.






What????? We are done with the BADI creation. Happy Learning :)