Wednesday, November 22, 2017

ENHANCEMENT-POINT Implementation

ENHANCEMENT-POINT

Points are predefined hooks available in Std SAP code which you can implement. At runtime, based on the Switch status of the Implementation, the implementations would be called.
  • INCLUDE BOUND - If point is INCLUDE BOUND, the enh implementation would be created into the include, instead of the main program.
  • STATIC – If point is STATIC, the implementation would be called if switch is not assigned. If switch is assigned, implementation would be called based on the status. If point is not STATIC, the implementation has to be part of the switch and it has to be active.

Find an Enhancement-POINT

To find any enhancement, you need to follow almost similar process like you have used to find any other enhancement – You debug. If you know the program, you can go through it and look for a specific point which you want to implement. But, I believe Debugging would give you better options.
Let take some scenario – You want to update certain attributes for Line Item while posting the material document. So, you debug the process. And found out that there is this Enhancement point which you can implement.

Implement the Enhancement-Point

1. Get to Enhancement Mod
Press the Spiral button on the toolbar to bring up the Enhancement mode. Once you are in Enhancement, the Editor would be open for change with kind of maze on left.
Enhancement_Implementation_Initial_Mode
2. Create an Enhancement
Put Cursor on the Enhancement Name and choose option Edit > Enhancement Operations > Create Implementation
Enhancement_implementation_Create_Implemenation
The same option is also available in context menu (right click)
If all options in Enhancement Operations in Main Menu and in context Menu are not selectable, you must not be in the Enhancement Mode.
3. Choose or use Implementation
System would bring you a popup to choose existing Enhancement implementation. If you implementing a new functionality, I suggest you create the new Implementation by pressing the Create Icon. Enter the details of the Enh Imp name and description. In subsequent popup enter the Package and TR if you don’t select Local objects.
Enh_Imp_Explicit_pop_1
Once Enh Imp is created, you are back to the popup to select the Enh Imp.
Enh_Imp_Explicit_pop_2
4. Implement the logic
Now Implement the logic in your Enhancement Implementation. Once completed, press Activate Enhancements to activate the implementation.
Enh_Imp_Explicit_implemented_code

Remove Implementation

If the you wish to remove the implementation, you need to follow two step approach.
  1. Undo the implementation first. Choose Context Menu > Enhancement Implementation > Undo Implementation.
  2. Activate the Implementation. If you don’t activate, the object will not be detached from the program.
  3. Go to SE80. Choose Other objects > Enhancements. Choose option Enhancement Implementation and enter the name. Choose Delete to remove it completely from system.

Multiple Implementations

There could be multiple Implementations of the same enhancement point. Like one shown in this example. If the implementation is attached to the Switch and if the switch is active, the system would execute those implementations. Implementations without any switch are also active at the same time.
If you are in the change mode of one of the implementation, Enhancement Framework will not allow you to create another one right there. You need to go out of the change mode. I generally, go out of the program and start the process again.
Enh_Imp_Explicit_implemented_multiple

Debugging Implementation

Debug the Implementation

Once you have implemented the enhancement implementation, you would be able to see it in action. To be able to debug it:
  • Put a break-point just before the implementation
  • Put a break-point within your implementation as well
  • Run your application
Enhancement_Implementation_Initial_breakpoints
If you have implemented at the correct location, debugger will stop. When debugger comes up, it would be at your 1st break-point. You would notice that your implementation is not displayed in the program. Don’t get alarmed or confused. You notice a small spiral at the beginning of the line. This Spiral shows that there is an active implementation at that location. That implementation would be called by the program when control reaches to that point.
Enhancement_Implementation_Debugger_Spiral
As you can see in this image, there is a second ENHANCEMENT-POINT which doesn’t have any active implementation. Thus there is no Spiral button in front of that.
When you step over to your breakpoint, you would be now within your implementation.
Enhancement_Implementation_Include_Name

Implementation Include

As you can notice, this implementation is in its own include. When you create the implementation for enhancement options, system generates this include to house the code. At runtime, system determines if there is any active implementation needs to be called or not. If there is, it would display that Spiral icon and call the implementation from that generated include.
System generated include name as ZTEST_NP_MAT_DOC_LINE_CHANGE==E for the implementation ZTEST_NP_MAT_DOC_LINE_CHANGE. The include name is 31 characters long. 30 chars are the name of the Implementation and filler as = for name shorter than 30 char, and 31st char as E.

No comments:

Post a Comment

SAP giới thiệu mã hỗ trợ AI trong ngôn ngữ ABAP riêng của mình

SAP đã ra mắt một loạt tính năng mã hỗ trợ AI trong môi trường phát triển ứng dụng dựa trên đám mây của mình, đồng thời tham gia vào danh sá...