Monday, January 26, 2009

Store internal table content in local file during debugging in 4.6c

By Joyjit Ghosh,
Kolkata, India.

In 4.6C there is no direct option provided in the debugger to store internal table content in local file as it is there from release 6.20 onwards (see the screen shot below).

This tip will show us how to achieve the same in release 4.6C.

Step1: When you are in debugging mode press the table push button. And enter the internal table name. Place the cursor on the table field.

Step 2: Go to the “Goto” menu. Choose ”Display data object” sub-menu. And from the Sub-menu Choose “Structure Editor”.

Step 3: When we press the ‘Structure editor’ sub-menu, screen with title “Structure editor: change [table name] from entry 1” is displayed, where all the contents of the internal table is displayed as a list. Here if we want we can add /delete/modify new rows.

Step 4: Here our main objective is to download the contents of the internal table. To accomplish this go to “Object” menu and select “Display entire list” sub-menu.

Step 5: Now go to System -> List -> Save -> Local file sub-menu.

Step 6: A pop-up screen is appeared to ask ’In which format should the list be saved?’ Just press OK button.

Step 7: When OK button is pressed again a pop-up screen is appeared where the file name has to be given. After providing the file name, press ‘Transfer’ button.

Step 8: Now if we open the file then we can see that the content of the internal table is stored in the following format. This facility will save us from tedious work of researching the internal table contents from within the ABAP debugger as we can now use a user-friendly tool (like Microsoft Excel, Notepad etc.) to check the data in the file itself.


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.