You are on page 1of 9

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.

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

2. An include file will be opened. Click on enhance button . Now select menu Edit Enhancement
Operations Show Implicit Enhancement Option.
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.

You might also like