Sie sind auf Seite 1von 51

Adding Explicit Enhancement to custom program

By Rohit Ranka, StraVis IT Solutions

Introduction:
Enhancement Framework is the new paradigm to bring all enhancement techniques under one roof. It
can also be switched using Switch Framework. The following are different enhancement technologies
available under this framework.
Source Code Enhancement
Function Group Enhancement
Class Enhancement
Kernel-BADI Enhancement
Source Code enhancement
Whenever enhancement needs to be incorporated directly into the ABAP source code, this technology
shall be provided. Implementing this technology is also called as Source Code Plug-In. There are two
types of Source Code enhancements possible.
Implicit enhancement option
Explicit enhancement option
Explicit enhancement option
As implicit enhancements are predefined enhancements provided by SAP in the source code, the explicit
enhancements can be implemented by the customers or partners.
There are two types of Explicit Enhancement options available. For this, we now have two new ABAP
statements, viz.
1.
Enhancement
point
(Syntax
2. Enhancement section (Syntax - ENHANCEMENT-SECTION)

ENHANCEMENT-POINT)

Enhancement section is used to replace a set of code or statements with the customer (custom code). In
this technique the original source code does not get executed but, the customer implementation (custom
code) gets executed.
Note - Explicit enhancements though can be placed anywhere in the source code but, not just anywhere
except some areas where SAP would allow (program allows).
STEP 1: Create a package in transaction SE80 (Object navigator) Name YDEV

STEP 2: Navigate to 'Enhancements' folder of your package. Package (YDEV) Enhancement.


Right click the 'Enhancements' 'Create' 'Enhancement Spot'.

Fill in the details in the 'Create Enhancement Spot' dialog.

And save it into created package. Observe the enhancement spot created under the 'Enhancement
Spots' folder.

STEP 3: 'Right Click' the spot created and 'Implement' it (Create an Implementation).

Fill in all the details in the 'Create Enhancement Implementation' dialog.

STEP 4: Now, we need to 'Activate' the enhancement spot. In addition with the Enhancement spot the
'Enhancement Implementation' will get activated.

Click here to continue...

Adding Explicit Enhancement to custom program


...Previous

STEP 5: Here we are applying enhancements to a CUSTOM program not a standard program to
demonstrate the functionality. So we create a simple program 'YDEV_CODE' (say) it is retrieving records
from the database table 'VBAK' (Sales Document Header) and displaying a few records.
Now, if the customer wants to replace the set of logic with his own logic (say) like retrieving records from
database table 'VBAP' (Sales Document Item) and then display a few records, he/she will create an
enhancement section which goes like,
Create a program YDEV_CODE.

OUTPUT

STEP 6: Right click the area which is appropriate to apply the enhancement
Note - Explicit enhancements though can be placed anywhere in the source code but, not just anywhere
except some areas where SAP would allow (program allows).

Now, in the 'Create Enhancement Option' fill in the details, here fill the name under 'Enhancementsection' only. Then fill in the Enhancement Spot Implementation Name which we created earlier.

Now we are able to see program lines have Enhancement-SectionEnd Enhancement-Section.

Note- Make sure that the code which has to be replaced is within the 'ENHANCEMENT-SECTION...' and
'END-ENHANCEMENT-SECTION'.
Click here to continue..

Adding Explicit Enhancement to custom program


...Previous

STEP 7: Now to include the custom code in the program which will replace the original code, enable the
'Enhancement Mode' by clicking on the 'Spiral' button.

Place the cursor on the 'Enhancement-section' and navigate to 'Edit' 'Enhancement Operations'
'Create Implementation'.

Fill in the details for the 'Create Enhancement Implementation' dialog. Click on 'Create' button for the
'Select or Create Enhancement Implementation' dialog.

STEP 8: Now, write the code within the 'ENHANCEMENT' and 'ENDENHANCEMENT' statements as the
replacement code.

STEP 9: Don't forget to 'Activate' the enhancement Switch the 'Enhancement' mode OFF and
'Activate' the entire program.

STEP 10: Execute the transaction/program to find out the difference.


Before Enhancement:

After Enhancement:

Summary:
1. Here we deals with the enhancement of a 'Z' program it is possible to 'CREATE' an
'ENHANCEMENT-SECTION'. But, in case of a 'STANDARD SAP' program there are certain
places (provided by SAP) like 'ENHANCEMENT-POINT...' and 'ENHANCEMENT-SECTION...'
where we can create implementations based on customers business functionality.
2. There can be only one and only one 'ACTIVE' implementation for an 'ENHANCEMENT-SECTION'.
Source Code:

1.
Here we deals with the enhancement of a 'Z' program it is possible to 'CREATE' an 'ENHANCEMENTSECTION'. But, in case of a 'STANDARD SAP' program there are certain places (provided by SAP) like
'ENHANCEMENT-POINT...' and 'ENHANCEMENT-SECTION...' where we can create implementations based
on customers business functionality.

2.

There can be only one and only one 'ACTIVE' implementation for an 'ENHANCEMENT-SECTION'.

Source Code:

*&---------------------------------------------------------------------*
*& Report YDEV_CODE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT YDEV_CODE.
TABLES : VBAK, VBAP.
DATA : IT_VBAK TYPE STANDARD TABLE OF VBAK INITIAL SIZE 0,
WA_VBAK TYPE VBAK,
IT_VBAP TYPE STANDARD TABLE OF VBAP INITIAL SIZE 0,
WA_VBAP TYPE VBAP.

INITIALIZATION.
REFRESH : IT_VBAK,
IT_VBAP.
CLEAR : WA_VBAK,
WA_VBAP.

START-OF-SELECTION.

ENHANCEMENT-SECTION YDEV_ENHANCE_SECTION SPOTS YDEV_IMPLEMENT_SPOT .


SELECT *
FROM VBAP
INTO TABLE IT_VBAP[]
UP TO 15 ROWS.

WRITE: /02 'Sales Document',


20 'Date',
40 'Time',
65 'Name of Person'.
ULINE .
IF IT_VBAP[] IS NOT INITIAL.
LOOP AT IT_VBAP INTO WA_VBAP.
WRITE: /02 WA_VBAP-VBELN,
20 WA_VBAP-POSNR,
40 WA_VBAP-MATNR,
65 WA_VBAP-MATWA.
ENDLOOP.
ENDIF.
END-ENHANCEMENT-SECTION.
*$*$-Start: YDEV_ENHANCE_SECTION----------------------------------------------------------------$*$*
ENHANCEMENT 1 YDEV_IMPLEMENT_ENHC_SECTION.
SELECT *

"active version

FROM VBAP
INTO TABLE IT_VBAP[]
UP TO 10 ROWS.

WRITE: /02 'Sales Document',


20 'Sales Item',
40 'Material Number',
65 'Material entered'.
ULINE .
IF IT_VBAP[] IS NOT INITIAL.
LOOP AT IT_VBAP INTO WA_VBAP.
WRITE: /02 WA_VBAP-VBELN,
20 WA_VBAP-POSNR,
40 WA_VBAP-MATNR,
65 WA_VBAP-MATWA.
ENDLOOP.
ENDIF.
ENDENHANCEMENT.
*$*$-End: YDEV_ENHANCE_SECTION----------------------------------------------------------------$*$*

*********************************************************************************************************************

Add new parameters and enhance source code of standard Function


Module
By Shweta Chavan, Hitachi Consulting

Introduction
Many times the existing functionality in standard function module is not sufficient for a developer. In such
cases, to little more functionality, we copy the standard FM and make the Z custom copy of it. Or else
create the custom new FM for extra functionality and call multiple function modules.
In SAPs new enhancement Framework, SAP has provided this new enhancement technique which allow
user to enhance the standard function module. So when there are small changes required we can
enhance the function module itself. Once we made changes in standard FM, new changes would be
available to all objects in environment.
This article will elaborate you the way to enhance the standard function module. Here we are taking
example of Function module LAST_WEEK. We are enhancing the parameters in EXPORT & TABLES
with source code enhancement. We will also be enhancing the global data to declare some new
variables.
First lets see the original function module, its parameters & output.
Import & Export parameters:

Original

Function

module

output:

Lets now enhance this function module. We will add one more parameter in Export which will give no of
holidays in that week. We will also add table which hold details on holidays. Once we enhance this
function module LAST_WEEK it will start giving more appropriate details of last week.
Steps to Enhance Interface

1.

Go

to

Export

parameter

screen

select

menu

Function

Module

Enhance

interfac

2. A pop-up will come to Create Enhancement Implementation. Give the details to create custom
implementation and click on , give the package and save.

3. Now you can add required parameter in editable rows.

4. We also need to add new table. So we will also add required table under tables tab.

5. Save the enhancement and activate it.


Click here to continue..

Add new parameters and enhance source code of standard Function


Module
...Previous

Steps to Enhance Global Data


1. Now to add new global variables, go to menu Goto Global data.

2. An include file will be opened. Click on enhance button


Operations Show Implicit Enhancement Option.

. Now select menu Edit Enhancement

3. First click anywhere on """""""" line and then right click on same line. Go to Enhancement
Implementation create Implementation.

4. Create Enhancement Implementation and save it.

5. Write your custom code in enhancement 1. Save and activate it.

Steps to Enhance Source Code


1. Now we have to enhance the source code to populate values in our export & table parameters. Go to
source code click on enhance . Select menu Edit Enhancement Operations Show Implicit
Enhancement Option.
2. Go to last line of function module. Before ENDFUNCTION statement you will see the available implicit
enhancement. Implement custom enhancement by clicking right click and selecting Enhancement
Implementation create Implementation.
3. You will get a pop-up like below. Choose option Code.

4. Create new implementation.

5. Write down custom code, save and activate the implementation.

Result
Run the Function module.

You will see the newly added parameters in Export & Tables.

Notes

All parameters which you add in IMPORT/EXPORT/TABLE must be optional. This will not affect existing
objects which are using function module.
SAP doesnt support this function level enhancement to all standard function modules. There are some
FM in central repository which never be enhanced like FM POPUP_TO_CONFIRM.

***********************************************************************************************************************

Adding custom tab to the transaction VF01/VF02/VF03 Header detail


screen
By Ugur Baris Turkeli , Istanbul

Go to VF02 transaction

Custom Tab to be added in the header detail

Step by step how can we add custom tab to the billing header detail;
In order to fulfill the requirement we need a custom subscreen with some custom fields in that screen.
Steps for creating the custom fields and adding them to the custom sub screen.
1. Creating the Custom fields
a) Create the Z fields to the table VBRK, by appending the structure.

b) Give a name to the structure for example ZZVBRK_APPEND. Enter the fields name which will you
need.
Note: the added fields should follow the naming convention that they should start with ZZxxxxx or
YYxxxxx.
c) Save and activate.

2. Creating the z* program and its screen and adding the Z fields on layout.
a) Create a z*program using transaction SE38
give a name for example ZZBILLHEADER .
b) Create a screen using the transaction SE51.

Click here to continue..

OUTPUT Adding custom tab to the transaction VF01/VF02/VF03 Header detail screen
...Previous

Go to screen layout and get the fields from dictionary on vbrk table

The screen in VF03 before which is in changeable mode. If you write screen pbo module below code it
will be read only.

Save and activate program and screen.

Go to transaction vf02,

Double click program name SAPMV60A

SAP provides 2 screens for customer addional datas; screen 6001 is for header and screen 6002 is for
detail screen.

Click here to continue..

Adding custom tab to the transaction VF01/VF02/VF03 Header detail


screen
...Previous

In the cust_head_activate subroutine we have to activate TABSTRIP_TAB06 for customer header tab
screen.

3. Steps to write the code in the enhancement spots.


a. First to find the enhancement spots click on the spiral icon in the menu bar, and next click on the edit
enhancement operations - show implicit enhancement options.

You will see the arrows . Right click on the arrow line and click Enhancement implemantation >Create

4. Give a name for Enhancement point, for example ZZBILLHEADER_ACTIVATE_TAB

Click enter and save in a package.


To make use of this logic use enhancement frame work. We have enhancement spots at the begin/end of
the subroutine.
5. Steps to write the code in the enhancement spots.
GS_CUST_TAB-HEAD_CAPTION
=
'ihracat
Ek
veriler'.custom
GS_CUST_TAB-HEAD_PROGRAM
=
'ZZBILLHEADER'.custom
GS_CUST_TAB-HEAD_DYNPRO = '0001' custom z* program screen

tab
z*

name
program

Activate the enhancement and check in the VF01/ VF02/ VF03 you can find the custom tab with the
custom fields. The Data automatically populates to the database table when the data is entered into the Z
fields.
******************************************************************************************************************************

Adding custom tab to the transaction VF01/VF02/VF03 item detail


screen
By Hema Bobbili, Hewlett Packard

Go to VF02 transaction:

Custom Tab to be added in the item detail

SAP
has provided a custom tab in the tab strip (Program name SAPMV60A) screen 6002
which is having the function code PFCU.

In order to fulfill the requirement we need a custom subscreen with some custom fields
in that screen.

Steps for creating the custom fields and adding them to the custom sub screen.
1. Creating the Custom fields
a) Create the Z fields to the table VBRP, by appending the structure.

b) Give a name to the structure for example zzcustom_fields. Enter the field name.

Note: the added fields should follow the naming convention that they should start with
ZZxxxxx.
c) Save and activate.

2.
Creating the screen and adding the Z fields
a) Create a screen using the transaction SE51.

b) Get the
field from the dictionary which needs to be added to the screen.

c) Save and activate the screen.


Click here to continue..

Adding custom tab to the transaction VF01/VF02/VF03 item detail


screen
...Previous

3. Go to SE80 and give the program name (SAPMV60A) of the VF01 transaction. Go to
screen -> 6002.

In the MODULE PBO_6002the subroutine PBO_6002_TABSTRIP_POS specifies the


position of the tab.

In order to activate the custom tab for this requirement which is having the function code
PFCU, the module CUST_ITEM_ACTIVATE needs to be implemented.

To make use of this logic use enhancement frame work. We have enhancement spots
at the begin/end of the subroutine.
4. Steps to write the code in the enhancement spots.
a. First to find the enhancement spots click on the spiral icon in the menu bar, and next
click on the edit enhancement operations - show implicit enhancement options.

Start of the enhancement spot

End of the enhancement spot

Create the enhancement spot.

Click on the create enhancement implementation

Give some name to the enhancement implementation.

Click enter and save in a package.


Select your implementation and then continue.

In between the ENHANCEMENT and ENDENHANCEMENT statements Insert the


below code.

Insert
your code as below.

Activate the enhancement and check in the vf01/vf02/vf03 you can find the custom tab
with
the
custom
fields.

The Data automatically populates to the database table when the data is entered into
the Z fields. But where as in display mode it is changeable for it to be made disable, a
simple code is to be added.
The

screen

in

VF03

before

which

is

in

changeable

mode.

After
adding the code the screen is as follows in VF03 transaction.

Das könnte Ihnen auch gefallen