Showing posts with label Enhancement Technique. Show all posts
Showing posts with label Enhancement Technique. Show all posts

Monday, May 18, 2009

Test User-exit without creating a project

by Joyjit Ghosh

This tip will show us how to test user-exit from SMOD without creating any project.

Go to SMOD and check the enhancement.

For example, here we are checking the enhancement SEUED001. Now press Test button.

Now put the cursor on an exit FM and press select component button.

Now create the include program.

Insert a break point in it.

Now go back to the test screen and press activate button.

It will activate the enhancement without creating any project.

Now press the execute button and enter the transaction for which this user exit may trigger.

As shown below user exit is triggered from SE38.

After the testing you should de-activate the exit and delete the include program created above.

Go back to the test screen. And press the Undo activation button.

You will get the following message

Now delete the include program created earlier. Press the Delete Test Objects button

In the next popup select the include program and press ok button.

Now press Yes button

It will display the following message

Now to crosscheck whether the include program is really deleted or not, select the exit and again press button. And in the next screen double click on the include name and then press enter.

It will display the pop up which confirms that include program does not exist.

Monday, January 26, 2009

Set up business events to update custom tables from a Standard Transaction

By Joyjit Ghosh,
Kolkata
, India
.

At times the business requirement demands that if the user changes some data from a standard SAP transaction, the same will be noted down in some form and subsequently a daily batch job will pick up that information and will send to another system. One way to achieve this type of requirement is to have the business events set up for this standard transaction in question (provided that transaction calls the business events in it). There are a number of business events declared in a SAP system that may be of use. The transaction is BF34 where we need to configure the business events.

Step-1

In the BF34 transaction, SAP provides the opportunity to configure the Business events and the corresponding function modules:

There is a F4 drop down help available for these business events as shown below:


One can easily choose the business events from this drop down box.

For every event number one corresponding function module exists.

Step-2

The function module SAMPLE_INTERFACE_00001340 is a function module template that needs to be copied as a Z-function module and then altered so that the desired functionality can be achieved. Please see the following screenshots for details:

The existing template:

Please note that this function module contains all the details about the relevant data as importing parameters. The example above is relevant to the event no. 00001340, which is ‘Customer Master data: Final checks’. All data corresponding to this transaction is available within this function module. The idea is to create a custom function module by copying this template function module and then add additional code in that to get the desired functionality.

A real life scenario:

A typical case can be monitoring the customer hierarchy (tcodeVDH1N) for any create/change/delete in the hierarchy relationship. This is important when the client decides that he/she will use non-SAP software (e.g. I-MANY) to monitor the rebate amount distribution. This is a primary requirement for the I-MANY software that the customer hierarchy relationship is in sync with SAP.

The business events for the customer hierarchy create/change/delete are as below: -

These events are configured in the BF34 transaction as below: -

Using transaction BF24 we can create the “Product” as shown below:

The requirement was to write down the create/change/delete information for the customer hierarchy in three different custom tables with the Higher-level customer number and the validity start, end dates. The Z_CS_LOG_CH_CREATE,Z_CS_LOG_CH_CHANGE, Z_CS_LOG_CH_DELETE function modules accomplishes the same.

How does this work?

In the standard SAP transaction VDH1N, the standard code issues outbound function calls as below: -

For the creationà the outbound call is made for the business event 00504004

For the change à the outbound call is made for the business event 00504005

For the deletionà the outbound call is made for the business event 00504006

These events have been set up in the configuration as shown above. So, whenever there is a change in the customer hierarchy by the standard SAP transaction, the same is being logged by these custom function modules via the business events.

There is a separate program, which is scheduled to run once daily, which picks up the information for the day it is running, from these custom tables and sends Idocs to the non-SAP system.