Thursday, September 9, 2010

ABAP Basics

ABAP Basics



SAP R/3 - ABAP - BASICS


SAP originally developed the ABAP/4 (Advanced Business Application Programming) language for internal use. It is being constantly improved and modified to meet the needs of the business world. Today, ABAP/4 is the sole tool used by SAP to develop all of its applications. Now ABAP/4 is just called "ABAP", by SAP. The ABAP/4 Development Workbench (DW) contains all the tools needed to create and maintain ABAP programs. ABAP is a fourth generation language which supports structured programming. Some of its basic features include the following


ABAP/4 contains
    - declarative elements for declaring data of various types
    - operational elements for data manipulation
    - control elements for controlling the program flow
    - event elements for reacting external events
    ABAP/4 supports several languages. Text elements (e.g. titles, headers, and other text) are stored separately from the program code. You can change translate and maintain these at any time without changing the program code.
    ABAP/4 supports business data types and operations. You can perform calculations with special date and time fields.
    ABAP/4 contains a subset of SQL called Open SQL which will enable the user to read and access database tables regardless of the database system (Oracle, DB/2, etc.).
    ABAP/4 allows the user to define and process internal tables which exist only as long as the program is running. Internal tables make it easier to work with database tables.
    ABAP/4 allows you to define and call subroutines. You can also call the subroutines of other programs. Parameters can be passed to and from subroutines in various ways.
    ABAP/4 contains a special kind of subroutine known as a function module. You create and maintain function modules in a central library. They can be tested in a stand-alone mode independently of the calling program.
    There are two main types of ABAP/4 programs
Report Programs
Report programs are used to analyze data from database tables. In reporting you use ABAP/4 Open SQL to read data from the R/3 database. A report consists of a selection screen, on which you define the data set you wish to display, and a list, which displays the data itself. Typically, reports merely read data from the database. However, it is also possible to make changes in the database using a report. Report programs are based on logical databases which are special ABAP/4 programs which provide access to all databases. List in SAP is called a report.
- Dialog Programs
Dialog programs are organized as module pools which contain dialog modules. Each "dynpro" (a Dynamic program which consists of a screen and its flow logic) is based on exactly one ABAP/4 dialog program. In dialog programming you use the Screen Painter to create screens and program the sequence in which they appear. You write a ABAP program (ABAP/4 module pool) for your screens. Dialog program is a SAP transaction.

Creating an ABAP Program

Creating a simple ABAP Program involves the following basic steps:
    Naming the program
    Specifying the program attributes
    Writing the program code
    Testing the program
The procedures described here apply to reports and short training programs. To create dialog programs (module pools for a new transaction, you can proceed in a different way than for a report program). There are two menu paths to create a new program.
Tools -> ABAP/4 Workbench; Choose ABAP/4 Editor; Enter a name for the program you want to create in the program field; Choose Create; ABAP/4 Program attribute screen appears.
Tools -> ABAP/4 Workbench; Choose Object Browser; Choose Program under Object List; Choose Program Objects under Single Object list; Enter the name of program and click Display. If the program does not already exist, you are asked whether you want to create it - yes
Some rules and conventions for naming a program
    Use at least one, but not more than eight, characters
    Do not use the following characters:
    - period .
    - comma ,
    - space
    - parentheses ( )
    - single or double quotation marks ' "
    - equal sign =
    - asterisk *
    - percentage % and underscore _
    Report programs (for outputting data analyses in list format):Yaxxxxxx or Zaxxxxxx. Replace a with the classification letter of the application area (f for finance, s for sales, etc.). Replace xwith any valid character. SAP report programs follow a similar naming convention: Raxxxxxx.
    Any other ABAP/4 programs (training programs or programs for transactions); SAPMYxxx or SAPMZxxx. Replace with any valid character. Standard SAP programs follow a similar naming convention: SAPMaxxx, where a represents an application area.

Program attributes

When you have assigned a name to the program and chosenCreate on the ABAP/4 editor: the Program Attributes screen appears - To enter the program attributes:
    Enter the title for the program in the field Title. Choose a title which describes the function of the program. The system automatically incorporates the title in the text elements. If you want to change the title later you can change it: Choose Text Elements or Attributes on the ABAP/4 Editor: Initial Screen, Choose Change.
    Complete the two mandatory fields Type andApplication
For a report program enter 1 and for module pool enter Min the Type. You can look at possible values in the list box.
- Enter the classification letter for your application in theApplication field i.e. F for financial accounting
If you are creating a report (type = 1) Choose, Enter. The system automatically inserts input fields for report specific attributes:
    Type
    Apart from type 1 and type M, there is a type I for include programs. An include program is an independent program which contains program code, that can be used by different programs. In addition, include programs serve to modularize program source codes into logically related parts. Each of these parts is stored in a different include program. Include programs improve readability of source code and facilitate maintenance.
    Development Class
    The development class is important for transporting between systems. When performing a transport, you can combine workbench objects (different programs, tables, transactions, etc.) assigned to one development class together. If you are working in a team, you may have to assign your program to an existing development class or create a new one. Programs assigned to development calass $TMP are private objects and can not be transported to other systems. You can, however change the development class to which a program is assigned by choosingProgram -> Reassign on the ABAP/4 Editor, Initial Screen.
    Logical database from application (report programs only)
    These attributes determine which logical database the report uses to retrieve data and to which application the logical database belongs. Database names within an application must be unique. However, the entire system may contain several databases with the same name. It is therefore important to specify an application. If your program reads data directly instead of using a logical database, you should specify an application as usual but leave thelogical database field blank.
    Selection Screen Version (report programs only)
    If you do not specify a selection screen version, the system automatically creates a selection screen based on the logical database selection criteria. If you want to use your own selection screen, enter a number in this field. The number must be smaller than 1000.
    Editor lock
    If you set this attribute, other users cannot modify, rename, or delete your program. Only you can release the lock.
    Fixed point arithmetic
    If you set this attribute the system rounds type P fields according to the number of decimal places.
After entering the program attributes save the attributes by choosingSaveMaintain Object Catalog Entry window appears. Enter the development class $TMP or choose Local Object. Save the development class by choosing Save. You will be now in theProgram Attributes Screen.
Leave the screen by choosing back. If you want to branch to the ABAP/4 editor directly,
choose Goto -> Source code.

Writing the Program

You write your ABAP/4 program in the ABAP/4 editor. Choose Source Code in the ABAP/4 Program Attributes Screen, orSelect Source Code and Choose Change on the ABAP/4 Editor - Initial Screen.
The ABAP/4 Editor: Edit Program screen appears. The editor can run in three different modes: "Command Mode", "PC Mode with line numbering", and "PC Mode without line numbering". You can switch between editor modes by choosing Settings -> Editor Mode. The system automatically enters the first ABAP/4 statement, e.g. REPORT or PROGRAM . For report name/ program name the system uses the name you entered on the ABAP/4 Editor: Initial Screen.
Enter the program code. Check the Syntax by choosing Check.The system then scans the program code for any syntax errors and incompatibilities. In an error, is detected, a message appears to report this and, if possible proposes a solution or correction. The cursor is placed in the appropriate position. Then save the code by choosing Save. The source text is stored in the program library. You can also change the source code of the program by Choosing Change from ABAP/4 editor. You can again check for syntax errors after making changes and then save the source code. If the development class is $TMP the changed version is saved immediately. If it is not $TMP you see a window where you can specify a correction number.

Testing the Program

Test the program to check whether the code works correctly.Choose Program -> Execute on the ABAP/4 Editor: Edit Program screen. If you are creating an ABAP/4 program module (dialog programs), you must create a transaction code before running the program. For testing purposes, you can run a program that is not part of a module pool without saving it first. The editor keeps a temporary version containing the changes. However, you must return to the editor after the test is over to ensure that all changes are saved.

Assigning Transaction Codes to Report Programs

You can assign transaction codes to standalone programs of type 1 and handle these programs like transactions afterwards. ChooseDevelopment -> Further tools -> Transactions at the ABAP/4 DW screen.
Fill in a name for the transaction and choose Create onMaintain Transaction screen.
Select Report Transaction on the following dialog window. Fill inrequired entries Transaction Text and Program on the Crate Report Transaction screen. Save the transaction code in adevelopment class.


ABAP/4 Program Syntax


Syntax Elements
Statements - must end with a period. First word should be a key word.
PROGRAM SAPMTEST.
WRITE 'FIRST PROGRAM'.
Keywords
Declarative Keywords
Define data types or declare the data objects which the program can access. Ex: TYPES, DATA, TABLES They are processed independently of their position in the program.
Event Keywords
Define processing blocks in a program. Processing blocks are groups of statements which are processed as soon as a particular event occurs. Ex: AT SELECTION SCREEN, START-OF-SELECTION, AT USER-COMMAND
Control Keywords
Control the flow of a program according to certain conditions. Ex: IF, WHILE, CASE
Operational Keywords
The process the data (defined by declarative keywords) when certain events (triggered by event keywords) and conditions (defined by control keywords) occur. Ex: WRITE, MOVE, ADD
Comments
Comments are text elements which you can write between the statements of the ABAP program to explain the purpose to a reader. Comments are flagged by special characters which cause the system to ignore them. Comment should be used to document the program. Example:
**********************************************
* PROGRAM SAPMTZTST
* Created by Dr. Prattipati, 11/22/1998
* Last Change by Dr. Grambo 11/23/1998
* Purpose Demonstration
***********************************************
PROGRAM SAPMTZTST
***********************************************
* Declaration Part
***********************************************
DATA.....
All lines beginning with an asterisk (*) are comments and are ignored by the system.
Syntax Structure
An ABAP program is a sequence of different statements which have a particular structure. Comments can be inserted between statements. Sequences of separate, but similar, statements can be combined into chain statements. There are no format restrictions. Statements can be entered in free format. This means that you can indent statements, write several statements on one line, or extend one statement over several lines.Words within a statement must be separated with at least one space. You can insert comment lines anywhere in a program. If you want to entire line to be a comment enter an asterisk (*) at the beginning of the line. If you want part of a line to be a comment, enter a double quotation mark (") before the comment. Some examples of valid Syntax Structures:
***********************************************
REPORT SAPMZTST.
TABLES SPFLT.
GET SPLFI.
WRITE SPFLI-CITYFROM.
WRITE SPFLI-CITYTO.
WRITE SPFLI-CITYTO UNDER SPFLI-CITYFROM.
*************************************************
PROGRAM SAPMZTST.
WRITE 'THIS IS A STATEMENT'.
Could also be written as
PROGRAM SAPMZTST. WRITE 'THIS IS A STATEMENT'.
**************************************************
Statement sequence
WRITE SPFLI-CITYFROM.
WRITE SPFLI-CITYTO.
WRITE SPFLI-AIRPTO.
Chain statement
WRITE: SPFLI-CITYFROM, SPFLI-CITYTO, SPFLI-AIRPTO.
You could also write these statements as
WRITE: SPFLI-CITIYFROM,
SPFLI-CITYTO,
SPFLI-AIRPTO.
**************************************************
Statement sequence;
SUM = SUM + 1.
SUM = SUM +2.
SUM = SUM + 3.
SUM = SUM + 4.
Can be written as a chain statement
SUM = SUM +:1,2,3,4.
****************************************************


Concepts of Data Types & Objects


Data types in ABAP are classified by structure and definition. Data types are either:
    elementary (non-structured) or structured
    Pre-defined or user-defined
Elementary Data Types - Pre-defined
C -- Text, character (alpha numeric characters default size = 1)
D -- Date format (yyyymmdd)
F -- Floating point number - accuracy range upto 15 decimals
I -- Integer (whole numbers - fractions are rounded not truncated)
N -- Numeric text (Telephone numbers, IDs, Account numbers, etc.)
P -- Packed Number - allows digits after the decimal point - "Fixed Point arithmetic" - rounds to the nearest decimal point specified. Used for such values as distances, weights, amounts of money, etc.
T -- Time format (HHMMSS)
X -- Hexadecimal
Numeric pre-defined data types: I,P, and F
Elementary Data Types - User defined
User defined elementary data types are based on pre-defined elementary data types. To define your own elementary data types, you use the TYPES statement. Examples are given later.
Structured data types
In general, structured data types in ABAP programs are user defined. There are two kinds of structured data types:
    Field Strings: A consecutive collection of other data types. A data object with a field string data type occupies a continuous area in the memory. The components of the field strings can themselves field strings or internal tables. The field strings are defined with TYPES statement or with the DATA statement
    Internal tables: An internal table consists of several lines of the same type. Unlike field strings, which extend only horizontally, internal tables also extend vertically. You define internal tables with OCCURS parameter of the TYPES or DATA statements.

Data Objects

In ABAP/4 you can work with several kinds of data objects, such as:
Internal data objects: They are created for use in one particular program. They have no validity outside this program. Internal data objects are literals (text literals, and number literals), variables and constants. Text literals are sequences of alphanumeric characters enclosed in single quotation marks ex: 'Antony Smith'. Example of number literals: '-8473.67'.
Variables: A variable is used to store and reference data under a certain name and in a certain format. Variables can differ in name, type, length, and structure. You declare variables in your program with the DATA statement.
Constants: A constant is a data object containing a value which you fix at initialization. Their values can not be changed during the execution of the program. You declare constants with the CONSTANTS statement. Use constants if you need specific value frequently in your program. In this case do not use literals.
External Data Objects: External data objects exist independently of programs. You can not work with them directly, but you can copy them to internal data objects and write them back when you have finished. External data objects can be used globally throughout the system environment. External data objects are stored in tables defined in ABAP/4 dictionary. To access this data from within a program, you declare the tables in the program with the TABLES statement.
System Defined Data Objects: Some data objects are defined automatically by the system and do not need to be declared. System-defined data objects include: SPACE (constant of type C) and SYSTEM FIELDS. All system fields have names with the format SY-. Some examples of system fields are: SY-SUBRC (return code value '0' if an operation is successful) SY-UNAME (log on name of the user), SY-DATUM (current date), SY-UZEIT (current time), SY-TCODE (current transaction), etc.
Special Data Objects: ABAP/4 also includes some data objects with special features - namely: PARAMETERS, andSELECTION CRITERIA.

Declaring Data - Examples

Pre-Defined Elementary Data Types and Objects
PROGRAM SAPMZTST.
DATA TEXT1 (14) TYPE C.
DATA TEXT2 LIKE TEXT1.
DATA NUMBER TYPE I.
TEXT1 = 'The Number'.
NUMBER = 100.
TEXT2 = 'is an integer.'.
WRITE: TEXT1, NUMBER, TEXT2.
OUTPUT: The Number 100 is an integer.
In this example the data objects TEXT1, TEXT2, and NUMBER are declared with data statement. The data type of each is specified with the TYPE or the LIKE parameter of the DATA statement. The data types used here (C,I) are pre-defined in the system. The values are assigned to the data objects, contents of which are displayed.
**********************************************************************
User Defined-Elementary Data Types and Objects
PROGRAM SAPMZTST.
TYPES MYTEXT (10) TYPE C.
TYPES MYAMOUNT TYPE P DECIMALS 2.
DATA TEXT TYPE MYTEXT.
DATA AMOUNT TYPE MYAMOUNT.
TEXT = '4 /3 = '.
AMOUNT = 4/3.
WRITE : TEXT, AMOUNT.
Output: 4 /3 = 1.33
Here user-defined data types MYTEXT and MYAMOUNT are defined with the TYPES statement with reference to elementary data types that are pre-defined in the system. Then the data objects TEXT and AMOUNT are declared with DATA statement. Their data types are determined to be MYTEXT, and MYAMOUNT.
*******************************************************************
Example of field Strings (Structured)
PROGRAM SAPMZTST.
TYPES: BEGIN OF NAME,
TITLE (5) TYPE C,
FIRST_NAME (10) TYPE C,
LAST_NAME (10) TYPE C,
END OF NAME.
TYPES: BEGIN OF MYLIST,
CLIENT TYPE NAME,
NUMBER TYPE I,
END OF MYLIST.
DATA LIST TYPE MYLIST.
LIST-CLIENT-TITLE = 'Lord'.
LIST-CLIENT-FIRST_NAME = 'Howard'.
LIST-CLIENT-LAST_NAME = 'Mac Duff'.
LIST-NUMBER = 1.
WRITE LIST-CLIENT-TITLE.
WRITE LIST-CLIENT-FIRST_NAME.
WRITE LIST-CLIENT-LAST_NAME.
WRITE / 'Number'.
WRITE LIST-NUMBER.
Output: Lord Howard Mac Duff
Number 1
In this example, the structured data types NAME and MYLIST are defined with the TYPES statement. The field string, NAME contains three components, TITLE, FIRST_NAME, and LAST_NAME, which have pre-defined elementary data type C. The field string MYLIST contains two components, namely CLIENT and NUMBER, CLIENT it self is already structured because it is given data type NAME. A structured data object LIST is declared with data type MYLIST. Values are assigned to the components and their contents are then displayed.
******************************************************************
Example of Internal Tables
PROGRAM SAPMZTST.
TYPES: BEGIN OF MYSTRING,
NUMBER TYPE I,
NAME TYPE C,
END OF MYSTRING.
TYPES MYTAB TYPE MYSTRING OCCURS 5.
DATA STRING TYPE MYSTRING.
DATA ITAB TYPE MYTAB.
STRING-NUMBER = 1. STRING-NAME = 'John'.
APPEND STRING TO ITAB.
STRING-NUMBER = 2. STRING-NAME = 'Paul'.
APPEND STRING TO ITAB.
STRING-NUMBER = 3. STRING-NAME = 'Ringo'.
APPEND STRING TO ITAB.
STRING-NUMBER = 4. STRING-NAME = 'George'.
APPEND STRING TO ITAB.
LOOP AT ITAB INTO STRING.
WRITE: / STRING-NUMBER, STRING-NAME.
ENDLOOP.
Output
1 John
2 Paul
3 Ringo
4 George
First a data type MYSTRING is defined as a field string. Then, based on field string MYSTRING, a data type MYTAB is defined as an internal table with the OCCURS parameter of the TYPES statement. The data objects STRING and ITAB are declared with data types MYSTRING and MYTAB. The fields of the internal table ITAB are then filled line by line. By using the field string STRING, the contents of ITAB are displayed on the screen.
__________________________________________________________________________________________________________________________

SAP ABAP : Best Practices - Performance Techniques

Info by Sunil patel from Architect SAP solutions 
SAP Best Practices (Tips & Tricks) for SAP ABAP development. Using SAP ABAP  performance techniques, we can save server resource, reduce network traffic and the time of end-user; all these lead to increase in productivity of user.
Below are the performance techniques needs to be followed:
A) Database Techniques:
1. Secondary index:
There are two types of indexes: Primary index and secondary index. Primary index is automatically created using primary keys defined.
Secondary index could be created as per the user requirement. With a secondary index, we can reduce the record scaning time and improves performance.
2. Where clause in select query:
Always specify your conditions in where clause rather than first selecting all record   then using the check syntax.
The database system can then use an index and the network load is considerably less.
3. Select data into internal table:
Selecting data into internal table is faster than select — appending the table.
SELECT in LOOP will increase database hit and lead to high network traffic.
SELECT INTO TABLE is retrieving the max possible rows per fetch and puts it into the internal table.
4. Select single and select…. endselect:
If you want one database record then use select single instead of select… end select.
When you use SELECT * … END SELECT statement to access your table, the system will access the database for value each time you loop. This will cause the traffic to increase and memory usage. If you use SELECT SINGLE and using KEYS in where condition, this will limit the search and keep the memory usage low plus reducing the execution time at database side.
5. Use for all entries in <itab>:
It’s increase the performance tremendously. Duplicates are automatically removed from the resulting data set. This statement is very useful to help us processing data using separate internal tables, although some of the process can be achieved using simple join statement, the FOR ALL ENTRIES statement can give you more processing Independency working with many internal tables. We can use this method to avoid “select” statement within loop.
IMPORTANT – Before using FOR ALL ENTRIES check table is not initial otherwise query will return all records from table.
B) ABAP Processing Techniques:
1. Read table using binary Search:
The binary search algorithm helps faster search of a value in an internal table. It is advisable to sort the internal table before doing a binary search.  Binary search repeatedly divides the search interval in half.
If the value to be searched is less than the item in the middle of the interval, so it will consider 1st half part otherwise 2nd half part.
2. Use of move statements:
If two work area have same structure then, use move statement instead of move-corresponding. MOVE statement is used for similar structures, means sequence of field is same in both work area and MOVE-CORRESPONDING is used for non-similar structures.
3. Copying internal tables:
To copy entire contents of one table into another, use tab1 [] = tab2 [] instead of append tab2 in Loop…Endloop.
4. Comparing internal tables:
Internal tables can be compared in a much faster way by if tab1 [] = tab2 [].
If you want to address the body of the table in a comparison, you must place two brackets ([ ]) after the table name.
5. Sorting internal tables:
Before every Read statement it is better to have sort internal table on key (with Key) fields.
6. Number of records in an internal table:
TO find out number of records are in an internal table use DESCRIBE statement.
This command to check whether an internal table contains data. The system field SY-TFILL gets affected after select … into… statement.
7. Deleting a set of lines from internal Table:
Use delete where to delete a set of lines. You can specify any logical expression log_exp after WHERE, all rows for which the logical expression is true are deleted.
8. Unused variables:
Delete unused variables form program.
Use program –> check –> extended program to check for the variables, which are not used. – Unnecessarily memory allocation at runtime.


SAP ECC/ABAP Enhancement Techniques

 This topic is  by Nikita Chitre(SAP Architect) from Architect SAPsolutions, where it discuss the different techniques which are be used to enhance SAP code. It is often required to modify the standard SAP code in order to match customer’s requirement to suit the business functionalities. SAP itself provides scope for the enhancements, like the user-exits, enhancement-spots, append structures, BADIs etc. These enhancements are retained even after an upgrade. Choice of the technique to be used depends upon the requirement and suitability.
Following are the enhancement techniques used to modify standard SAP functionality:
Technique:    BDT
Brief description: Business data toolset in a new functionality provided by SAP to modify screen i.e. standard screens. If the requirement is to add new fields, shift fields from one tab to another tab, add field groups, create views, and create sections in a screen BDT helps you to do that.
Technique:  FQEVENTS
Brief description: Transaction FQEVENTS is meant to maintain FI-CA events and some specific events which are used by the mass activities. For this method to be used for enhancement we have to find out events for the transaction and check the documentation for the function modules available for those events. The functionality which is provided by these function modules can only be used for enhancement.
Technique: FIELD EXITS
Brief description: As part of the extension concept, SAP allows you to install a field exit for each screen field. Similar to the conversion exit, the system branches at the field exit at DCI (DATA COMMUNICATIONS INPUT) to a function module, if the field is an input field and a function code was triggered. FIELD EXITS are available for all domains.
Technique: User Exits
Brief description: They are the hooks provided by SAP where we can add logic to enhance the transaction. For this method to be used for enhancement we have to find out User Exits for the transaction and check the functionality provided. The functionality which is provided can only be used for enhancement.
Technique: BADI
Brief Description: They are the hooks provided by SAP where we can add logic to enhance the transaction. Here approach is object oriented. For this method to be used for enhancement we have to find out BADI for the transaction and check the functionality provided. The functionality which is provided can only be used for enhancement.
Technique: Modification Assistant
Brief description: The aim of the Modification Assistant is to make modification adjustments easier.
You can add, replace, or comment out source code, all under the control of the Modification Assistant. Changes to layout and flow logic in the Screen Painter are also recorded. The Modification Assistant also records changes in the Menu Painter and to text elements, as well as the addition of new function modules to an existing function group if you want to change an SAP object, you must provide the following information: SSCR key, Change request.
Technique: Enhancement Spots.
Brief Description: This is Modification-free enhancement of source code.
Modification Available:
  • Implicit Enhancement Option
  • Explicit Enhancement Option
  • Function Group enhancement
  • Class enhancement
Technique: BTE
Brief description: The enhancement technique (Open FI) that was developed for Financial Accounting component.
Open FI assumes that enhancement will only take place on three levels (SAP – partners – customers)
Open FI uses function modules for program enhancements.
Types of Interfaces
There are two types of interface available
a) Publish and Subscribe Interface
b) Process Interface
For this method to be used for enhancement we have to find out BTE for the transaction and check the functionality provided. The functionality which is provided can only be used for enhancement.
Technique: Append Structure
Append structures are used for enhance tables or structures.
We can add more than one append structures for a table or structure.
The following enhancements can be made to a table or structure TAB with an append structure:
  • We can insert new fields in TAB
  • We can define foreign keys for fields of TAB that already exist
  • We can attach search helps to fields of TAB that already exist.

SAP ABAP : Enhancement Spot Introduction and Concepts

The enhancement spots are used to manage explicit enhancement options. That means you can add your code in standard ABAP code without need of access key. Means the standard code is not disturbed.
Enhancement spots specify the places where we can add our code in standard SAP.
Explicit enhancement options are created in an initial system .Developer must be made aware of this enhancement by means of enhancement spots.
You can define explicit enhancement options by using ENHANCEMENT-POINT statement. This represents element definition.
Each enhancement spot element definition must be assigned to at least one enhancement spot.
You can go through report RIAUFMVK.
enhancement point report
ES_RIAUFMVK is enhancement spot, RIAUFMVK_G4 is the enhancement-point for this enhancement spot. ENHANCEMENT 1 MGV_GENERATED_RIAUFMVK is the active implementation for this enhancement spot.
Steps to create enhancement spot:
  1. Select the package and open the context menu.
  2. Choose Create –> Enhancements –>Enhancement Spot.
A dialog box appears.
create enhancement spot
  1. Enter a name for the (simple) enhancement spot.
  2. Enter a short text for the (simple) enhancement spot
  3. Select the desired technology (for example, BAdI Definition.)
  4. Select a composed enhancement spot or create a new one
  5. Choose  Creation of Enhancement (Enter).
enhancement spot
You see the enhancement spot (still empty) in the enhancement spot editor of the Enhancement Builder.
Edit an enhancement spot:
  1. Select the package and expand it.
  2. Expand the Enhancements node.
  3. Expand the Enhancement Spot node.
  4. Select the desired enhancement spot
edit enhancement spot
  1. Choose Change from the context menu.
  2. Choose Display if you only want to display the enhancement spot.
display enhancement spot
Delete an enhancement spot:
  1. Select the package and expand it.
  2. Expand the Enhancements node.
  3. Expand the Enhancement Spot node.
  4. Select the desired enhancement spot.
delete enhancement spot

SAP ECC/ABAP Enhancement Technique - Enhancement Spots

Description:
Modification-free enhancement of source code.
Modification Available:
Implicit Enhancement Option
At common enhancement places, implicit Enhancement options are available.
Examples:
End of Executable Program, Include, Function group, Dialog module.
Begin/End of Form routine / Function module / Method.
End of a structure.
End of Private/Protected/Public Section of a local class.
Explicit Enhancement Option
Predefined enhancement options can be defined in source code.
They are additionally stored inside Enhancement Spots.
There are two types of Explicit Enhancement options available. One which can be provided at a specific place – called Enhancement Point, and another which can be used to replace a set of statements – called Enhancement Section.
Function Group Enhancement
All application function modules can be enhanced by adding parameters to the standard function module interface.
Class Enhancement
    The global Classes and Interfaces can be enhanced as follows:
  • Adding optional parameters to existing Methods
  • Adding new Methods to the global Class / Interface
  • Adding Pre-exit, Post-exit or Overwrite-exit to an existing Method
How to find if Transaction have above modification technique available
To find Implicit enhancement spot go to Edit->Enhancement Options->Show Implicit Enhancement Options in source code. To find explicit enhancement find for ENAHNCEMENT-POINT/ENHANCEMENT-SECTION in source code.
Example:
  • For transaction VL02N
  • Enter transaction in SE93.
  • See the screen number
  • Go to the program
  • Search for enhancement point
  • Right click on it and create explicit enhancement
  • Enter LIKP-VBELN = ’80014974′.
  • This will set default value for VBELN

No comments:

Post a Comment