SAP ABAP blog

Thursday, October 21, 2010

aaaa





Saturday, September 18, 2010

User Exits

User exits :

1. Introduction
2. How to find user exits
3. Using Project management of SAP Enhancements

1. Introduction:

User exits (Function module exits) are exits developed by SAP. The exit is implementerd as a call to a functionmodule. The code for the function module is writeen by the developer. You are not writing the code directly in the function module, but in the include that is implemented in the function module.

The naming standard of function modules for functionmodule exits is:
EXIT_<3 digit suffix>

The call to a functionmodule exit is implemented as:
CALL CUSTOMER.-FUNCTION <3 digit suffix>

Example:

The program for transaction VA01 Create salesorder is SAPMV45A

If you search for CALL CUSTOMER-FUNCTION i program
SAPMV45A you will find ( Among other user exits):

CALL CUSTOMER-FUNCTION '003'
exporting
xvbak = vbak
xvbuk = vbuk
xkomk = tkomk
importing
lvf_subrc = lvf_subrc
tables
xvbfa = xvbfa
xvbap = xvbap
xvbup = xvbup.

The exit calls function module EXIT_SAPMV45A_003

2. How to find user exits?

Display the program where you are searching for and exit and search for CALL CUSTOMER-EXIT

If you know the Exit name, go to transaction CMOD.

Choose menu Utillities->SAP Enhancements. Enter the exit name and press enter.

You will now come to a screen that shows the function module exits for the exit.

3. Using Project management of SAP Enhancements, we want to create a project to enahance trasnaction VA01 .

- Go to transaction CMOD
- Create a project called ZVA01
- Choose the Enhancement assign radio button and press the Change button

In the first column enter V45A0002 Predefine sold-to party in sales document.

Note that an enhancement can only be used in 1 project. If the enhancement is already in use, and error message will be displayed

Press Save

Press Components. You can now see that enhancement uses user exit EXIT_SAPMV45A_002. Double click on the exit.

Now the function module is displayed. Double click on include ZXVVAU04 in the function module

Insert the following code into the include: E_KUNNR = '2155'.

Activate the include program. Go back to CMOD and activate the project.

Goto transaction VA01 and craete a salesorder.

Note that Sold-to-party now automatically is "2155"

Sunday, September 12, 2010

BADI

BADI – Business Add Ins are enhancements to the standard version of the code of SAP. They can be inserted into the SAP system to accommodate user requirements too specific to be included in the standard delivery. Customers can find the possible enhancements (BADIs) in their SAP system in the Implementation Guide (IMG) and in the component hierarchy. BADI definitions are included in the IMG so that the customer can create suitable, company-specific implementations. SAP guarantees the upward compatibility of all Business Add-In interfaces. Release upgrades do not affect enhancement calls from within the standard software nor do they affect the validity of call interfaces.
Two different views are available:



■In the definition view, an application programmer defines exit points in a source that allow specific industry sectors, partners, and customers to attach additional coding to standard SAP source code without having to modify the original object.
■In the implementation view, the users of Business Add-Ins can customize the logic they need or use a standard solution if one is available.
Definition of A BAdI



SAP application developer actually defines a Business Add-In available to an application program. Tcode SE18 can also be used to see the definition of existing badi .The following are the steps in defining a BADI:

1. Using the SAP BADI builder, the SAP application developer defines an enhancement (BADI). It consists of an interface with a method.
2. The interface name is generated automatically and can be changed. The system branches to the Class Builder.
3. Using the Class Builder, the developer assigns a method to the interface.
4. For each method, he defines parameters. Parameters can either be importing or changing and these are the fields available for customer to use for enhancements. Importing parameters are the fields being passed from the calling program and changing parameters are the fields being passed back to the program.
5. The Business Add-In is then activated in the Class Builder.

Note: Documentation of the BADI usually provides the list of parameters and their definition. For example, for method DETERMINE_EXTPO, the available parameters are:
Importing
o ITEM_DATA Item data (is a structure)
Changing
o BBP_EXTPO_GL
o If the field has the value X, the request is subject to the extended classic scenario.
o If the field is empty, the request is not subject to the extended classic scenario.

Implementation of a BAdI

If a customer wishes to use a Business Add-In, he or she first creates an implementation. The customer must implement the methods and the enhancements. You need to program the interface method in such a way that, when the add-in is called from the application program, it will perform the specific action the customer intends. The following are the steps customer can follow in implementing a BADI:
1. In the SAP menu, choose ABAP Workbench ® Utilities ® Business Add-Ins (transaction SE19) or double-click the corresponding activity in the Implementation Guide (IMG).

2. Enter a name for the implementation and then click the Create pushbutton.
3. Enter the name of the add-in for which you want to create an implementation for in the dialog box that appears. Choose the Interface tab.
4. Choose ABAP Code as the implementation type.
5. Navigate to the Class Builder by double-clicking the method. You must first enter a
package before the Class Builder is displayed.
6. Insert the desired source code for the implementation between the method if_ex_businessaddin~method. and endmethod (statements that already exist) You need to use the parameters (importing and changing) as fields within the BADI. You can define additional fields you need in the coding as local data fields.
7. Save your entries and return to the Change Implementation screen.
8. Choose Activate. The enhancement’s active components are then called at runtime.

EXAMPLE (code)

Definition name BBP_EXTLOCALPO_BADI

Implementation Name ZEXTENDEDCLASSIC

Interface name IF_EX_BBP_EXTLOCALPO_BADI
Name of implementing class: ZCL_IM_EXTENDEDCLASSIC

Method DETERMINE_EXTPO
ABAP Code Determination of Control for Extended



METHOD IF_EX_BBP_EXTLOCALPO_BADI~DETERMINE_EXTPO.
DATA: zzecs type zecs. * local data field

*extended classic will be activated only for specific product categories
IF item_data-category eq '420DD2C2CFDF56478E705E352FEC86CB'.
bbp_extpo_gl-bbpexpo = 'X'.
ELSE.

SELECT single * from zecs into zzecs where product eq item_data-product.

IF sy-subrc eq 0.
bbp_extpo_gl-bbpexpo = 'X'.
ENDIF.

ENDIF.
ENDMETHOD.

Filter-Ddependent BAdI

Business Add-Ins may also be implemented on the basis of a filter value. The application program provides the filter value for the enhancement method. The filter parameter is defined within the method when creating the interface. For each method created in the interface of a filter-dependent enhancement, the filter value must be defined as the importing parameter so that the application program can provide the filter value to the enhancement method. The method then selects the active implementation for that value. The filter value is always declared using the parameter flt_val and is predefined in the list of parameters
For example:
You can use the Business Add-Ins BBP_DOC_CHANGE_BADI to make changes to the document, after user entry and before saving the document to the database. These changes are subject to the document-specific checks. The parameter FLT_VAL acts as a filter value that assigns the BAdI implementation to a particular document type. You can use the BAdI to change some of these documents:
o Shopping cart (filter value BUS2121 – shopping cart EC)
o Purchase order (filter value BUS2201 – purchase order EC)
o Confirmation (filter value BUS2203 – confirmation of goods/services EC)
o Invoice (filter value BUS2205 – incoming invoice EC)
o Bid invitation (filter value BUS2200 – bid invitation EC)



Calling A BAdI in The Applicat?on Program

When a Business Add-In is created, enhancement management generates a class that implements the interface. The application developer uses a factory method to create an instance of this adapter class in the application program and calls the corresponding method, if necessary.
The adapter class method generated by add-in management decides whether one or several active implementations should be called. If necessary, these implementations are subsequently executed. The application program ensures only that the adapter class method is called. The application program does not know which implementations are called.

Thursday, September 9, 2010

Business Transaction Events (BTE)

What is a BTE


BTE are comparable to the old enhancements
BTEs are used mostly within FI
BTEs can be used both by SAP, third party vendors and customers. Each use their own function modules where the logic is placed, so they don't interfere with each other

There are 2 types of BTE:


Publish & Subscribe interfaces. Can not update data. Possible to have multiple implementations
Process interfaces. Can update date. Only one active implementation


How does it work
The BTE is a function module (Implemented by the customer) that has a standard interface defined by SAP. The BTE is called by the SAP standard program by a call to function OPEN_FI_PERFORM_ or OUTBOUND_CALL_. This function checks if there are any active BTEs according to customizing.


How to find a BTE
Search the source code for for "OPEN_FI_PERFORM" og " OUTBOUND_CALL_"
Use transaction FIBF menu Environment->Info System (P/S ). Use the Documentation button to see the documentation for the BTE


Implementing a BTE
Goto transction FIBF menu Environment->Info System (P/S )
Select the BTE you want to implement.
Press button Sample function module
This brings you to SE37 - Copy the sample function module to a Z-function module (First create a new function group for the function module) . Note: The name of the Z-function module is not important
Edit the code in the new function module
Go back to transaction FIBF - Menu Settings->Products -> Of a customer and create a new product whicj identifies the new product . Remember to mark the Active field.
Go back to FIBF menu Settings->P/S function modules->of a customer - Create an entry that links the BTE and Product with the new function module

Netweaver

In the present era, where companies are struggling to unite various heterogeneous environments in their organizations and maintain a lower Total Cost of Ownership (TCO) NetWeaver comes as a solution to all their problems. SAP NetWeaver is the latest advancement in the mySAP Technology, which was developed as an Artificial Intelligence (AI) shell that accepts standard comments, literally as they are spoken, by domain experts.

Another unique feature of NetWeaver™ that makes it stand out amongst other software technologies is its modularity. The knowledge engineer can more easily create "digestible chunks" of modules or sub-dependency networks, which help to keep the overarching dependency network from becoming potentially incomprehensible because of apparent complexity. This text is aimed at explaining SAP NetWeaver architecture and its interoperability with Microsoft.NET and IBM WebSphere. In addition it aims at bringing out all the advantages that are associated with SAP NetWeaver.

Net Weaver in simple words is an application and Integration platform in which Web Services play a major role and which is open for Non-SAP applications and platform. It is used by organizations to improve productivity and enhance efficiency by making all the resources that are available in an enterprise to work collectively. The SAP customers to bring heterogeneous environments at one platform use SAP NetWeaver. In addition, it enables customers to use the already existing systems without putting in much investment. Further in the near future, the various corporate sectors and Organizations have to take a decision for some common platform; could be Microsoft .NET, IBM Websphere or SAP NetWeaver. Irrespective of the choice that they make, SAP NetWeaver is the one that integrates with all the three technologies.

SAP NetWeaver supports the ABAP programming language and its corresponding integrated development environment as a built-in capability of the application server. ABAP is especially designed for creating large-scale business applications, with dedicated features for developing backend business functionality, connecting applications, and provisioning services. IT professionals can use model-driven or code-driven tools to develop and configure user interfaces for web-based business applications.