Thursday, July 24, 2008

PERFORMANCE TUNING TIPS AND TRICKS


This tutorial focuses on presenting various performance tuning tips and tricks to make the ABAP programs efficient in doing their work.


1. Run Extended syntax checks with character literals checkbox switched on & Code Inspector to rectify all relevant errors and warning (e.g. Use the results of the above checks to remove all variables/constants etc that are declared but are not used).


2. Transaction SE30 (ABAP Runtime Analysis) must be checked to measure/compare program performance/runtime if program has multiple inefficient databases selects or complicated internal table operations.


3. Use transaction ST05 (SQL Trace) to see what indices your database accesses are using. Check these indices against your “where” clause to assure they are significant. Check other indices for this table and where you have to change your “where” clause to use it. Create new indices if necessary, but do not forget to check the impact by consulting onsite coordinator.


4. TYPE (data element) command is used while declaring the fields whenever feasible instead of LIKE. Remember not always the data element name matches with the table field name.


5. Internal Table is defined with “TYPE STANDARD TABLE OF” & Work-Areas is used instead of header lines.


6. Global variables are minimized by declaring local variables or by passing variables through parameters & arguments while creating internal subroutine(s).


7. In SELECT statement, only the required fields are selected in the same order as they reside on the database table/structure/view.


8. For selecting single row from a database table, “SELECT UP to 1 Rows” is used. “Select Single” is used only when full primary key combination is known.


9. See that No SELECT * is used.


10. Use “SELECT INTO TABLE” rather than “SELECT INTO CORRESPONDING FIELDS OF TABLE”.


11. Always specify as many primary keys as possible in WHERE clause to make the Select efficient.


12. Always select into an internal table, except when the table will be very large (i.e., when the internal table will be greater than 500,000 records). Use “Up to N Rows” when the number of records needed is known.


13. Select statement within a GET event is not used.


14. Wild cards like ‘A%’ is avoided as much as possible.


15. Nested Select is not used instead “Inner Join” and/or “For all Entries” is used. “For all Entries” is to be used over “Loop at ITAB / Select / ENDLOOP” (FOR ALL ENTRIES retrieves a unique result set so ensure you retrieve the full key from the database).


16. When creating joins over database tables there should be an index at least on the inner table for the fields in the join condition else use “ FOR ALL ENTRIES” select statement.


17. Usage of JOIN is limited to a maximum of 2 i.e. not more than 3 database tables are joined at one time.


18. CHECK that the internal table used in FOR ALL ENTRIES is NOT empty as this will retrieve all entries from the table.


19. Delete adjacent duplicate entries from internal table before selection from database table using “ FOR ALL ENTRIES” statement.


20. For copying internal tables use ‘=’ operator instead of Looping & Appending.


21. SORT inside a LOOP is not used.


22. Sort internal table by fields in the correct order, which are used in a READ TABLE statement using BINARY SEARCH. If the order of sorting is invalid the BINARY SEARCH will never work.


23. For large internal tables where only some rows are to be processed, use SORT and then the READ TABLE command is used to set index to first relevant row before looping from that index. Use CHECK or IF…EXIT…ENDIF as appropriate to exit from the loop.


24. Sort fields and Sort Order on the SORT statement should be mentioned explicitly (e.g. SORT ITAB BY FLD1 FLD2 ASCENDING).


25. Hashed table is used for processing large amount of data (provided that you access single records only, and all with a fully specified key).


26. DELETE or SORT is not used on a hashed table since it increases memory consumption.


27. Sorted table is used for range accesses involving table key or index accesses.


28. Fields specified in the WHERE condition with the critical operators NOT and <> (negative SQL statements) cannot be used for a search using database indexes. Whenever possible formulate SQL statements positively.


29. When coding IF or CASE, testing conditions are nested so that the most frequently true conditions are processed first. Also CASE is used instead of IF when testing multiple fields “equal to” something.


30. Loop at itab INTO WORKAREA WHERE K = ‘XXX’ should be used instead of Loop at itab INTO WORKAREA / CHECK ITAB-K = ‘XXX’. Also READ TABLE INTO WORKAREA should be used instead of only READ TABLE.


31. After the APPEND statement inside a loop, the work area that has been appended is cleared.


32. Internal tables, Work areas & Global Variables are freed when no longer needed (e.g. using the FREE / REFRESH command), especially when the tables are large or the program is a batch program.


33. Do not delete the records of internal table inside the Loop – Endloop.
Do not Use: LOOP AT ITAB WHERE EQUNR = ‘00001011’.
DELETE ITAB.
ENDLOOP.
Use: DELETE ITAB WHERE EQUNR = ‘00001011’.


34. Use the MODIFY ITAB ... TRANSPORTING f1 f2 ... for single line, and MODIFY ITAB ... TRANSPORTING f1 f2 ... WHERE condition for a set of line, to accelerate the updating of internal table.


35. If possible, Update/Insert statement is used instead of Modify.


36. Following steps should be ensured during database updates:
· Lock data to be edited.
· Read current data from the database.
· Process data and write it to the database.
· Release the locks.


37. Try to avoid logical databases. If your program uses a logical database, but does not require all fields belonging to a certain GET event, always use the FIELDS addition to reduce the amount of data selected by the logical database.


38. Avoid the aggregate (Count, Max, Min) functions in the database selection.


39. Use Parallel Cursor methods for nested loop into the internal tables if second internal table contains considerable number of records.

Wednesday, July 23, 2008

Easy way to find BADI

Easy way to find BADI:

When any requirements of Enhancement comes which needs the implementation of BADI then the biggest hurdle comes in the way that how to find the BADI. Especially this question troubles the fresher most. Then we fresher go through the F4 help provided in the SE18 Transaction if your luck is good then you get it otherwise we go on internet ,SDN and all forums .
In this article I am going to share my simple trick to find the BADI, which I learned through my experience.

Procedure:

1. Go to transaction SE24 i.e. Class Builder.

2. Put the Object type as CL_EXITHANDLER and press Display.






3. Go to the tab of METHODS and double click on the method GET_INSTANCE.



4.When you double click it will lead you to the source code of the method.In the source code at very start you will find code which method is called i.e. get_class_name_by_interface. We need to just put a break-point on that.



5. There we will find a Changing parameter EXIT_NAME .This is the parameter which will tell us that which BADI got Trigger at the point where we want to enhance the logic.



Example:
Suppose you want to know the list of BADI which gets triggered at MM02 when you want to change the Description of the Material.
Just Do the above mentioned steps GO to Transaction MM02 Change the description of and press ENTER .Then the the debugger will start and we will get the names of the BADI which Triggers at PAI of the transaction MM02 after changing the Description Of the material.

Lets change the description of a material.
For e.g . We change the material Description of material TEST MAT.








After changing the material description we will press Enter and then debugger will open .

Here at the debugger we can see the value of parameter EXIT_NAME and we can check the BADI which get triggered.
We have to note down the name of the BADI every time we go to debugger and in SE18 we can check the BADI and its Methods and their parameters and can implement those by SE19.

Tuesday, July 22, 2008

Useful SAP tables

1 Customising
1.1 General settings
1.1.1 Countries
T005 Countries


1.1.2 Currency
TCURC Currency codes
TCURR Wisselkoersen
TCURT Currency name
TCURX Decimal places for currencies.


1.1.3 Unit of measure
T006 Units of measure


1.1.4 Calendar functions
T247 Month names
TFACD Factory calendar definition
T015M Month names
TTZZ Time zones
TTZD Summer time rules
TTZDF Summer time rules (fixed annual dates)
TTZDV Summer time rules (variable dates)
TTZDT Summer time rules texts
TTZ5 Assign Time Tones to Countries
TTZ5S Assign time zones to regions


1.2 Enterprise structure



1.2.1 Definition
FI T880 Company
T001 Company code




CO TKA01 Controlling area


LO T001W Plant / sales organization
T499S Locations
TSPA Division


SD TVKO Sales organization / company code
TVTW Distribution channel
TVBUR Sales office
TVKBT Sales office text
TVKGR Sales group
TVGRT Sales group text
T171T Sales district text


MM T001L Storage locations
T024E Purchasing organization
T3001 Warehouse number
TVST Shipping point
TVLA Loading point
TTDS Transportation


1.2.2 Assignment
CO TKA02 Assign company code to controlling area
LO T001K Assign plant (valuation area) to company code

SD TVKO Sales organization / company code
TVKOV Distribution channel / sales organization
TVKOS Division to sales organization
TVTA Sales aria
TVKBZ Sales office to sales area
TVBVK Sales group to sales office
TVKWZ Plants to sales organization


MM T024E Purchasing organization / company code
T024W Plant to Purchase organization
T001K Link plant ( = valuation area) / company code
TVSWZ Shipping point to plant
T320 Assignment MM Storage Location to WM Warehouse


1.3 Financial accounting
1.3.1 Company code
T004 Chart of accounts
T077S Account group (g/l accounts)
T009 Fiscal year variants
T880 Global company data
T014 Credit control area


1.3.2 Fi document
T010O Posting period variant
T010P Posting Period Variant Names
T001B Permitted Posting Periods
T003 Document types
T012 House banks


1.4 Not categorized
T007a Tax keys
T134 Material types
T179 Materials: Product Hierarchies
T179T Materials: Product hierarchies: Texts
TJ02T Status text
TINC Customer incoterms
TVFK Billing doc types
T390 PM: Shop papers for print control


2 Basic data / administration
2.1 Workbench related tables
2.1.1 Data dictionary tables
DD02L Tables in SAP
DD02T Tables description
DD03L Field names in SAP
DD03T Field description in SAP


2.1.2 Workbench
TADIR Directory of R/3 Repository Objects
TRDIR System table TRDIR
TFDIR Function Module
TLIBG Person responsible for function class
TLIBT Function Group Short Texts
TFTIT Function Module Short Text
TSTC Transaction codes in SAP
TSTCT Transaction codes texts
T100 Message text (vb e000)
VARID Variant data
D020T Screen texts
TDEVC Development class
TDEVCT Texts for development classes


2.2 Administration
2.2.1 User administration
USR01 User master
USR02 Logon data
USR03 User address data
USR04 User master authorizations
USR11 User Master Texts for Profiles (USR10)
UST12 User master: Authorizations
USR12 User master authorization values
USR13 Short Texts for Authorizations
USR40 Prohibited passwords
TOBJ Objects
TOBC Authorization Object Classes
TPRPROF Profile Name for Activity Group
DEVACCESS Table for development user


2.2.2 Batch input queue
APQD DATA DEFINITION Queue
APQI Queue info definition


2.2.3 Job processing
TBTCO Job status overview table
TBTCP Batch job step overview


2.2.4 Spool
TSP02 Spool: Print requests


2.2.5 Runtime errors
SNAP Runtime errors


2.2.6 Message control
TNAPR Processing programs for output
NAST Message status
NACH Printer determination
2.2.7 EDI
EDIDC Control record
EDIDD Data record
EDID2 Data record 3.0 Version
EDIDS EDI status record
EDPAR Convert External < > Internal Partner Number
EDPVW EDI partner types
EDPI1 EDI partner profile inbound
EDPO1/2/3 EDI partner profile outbound
2.2.8 Change documents
CDHDR Change document header
CDPOS Change document position
JCDS Change Documents for System/User Statuses (Table JEST)
2.2.9 Reporting tree table
SERPTREE Reporting: tree structure
2.2.10 LIS structure/control tables
TMC4 Global Control Elements: LIS Info Structure
3 MASTER DATA:
3.1 Material master:
MARA Material master
MAKT Material text
MARC Material per plant / stock
MVKE Material master, sales data
MARD Storage location / stock
MSKA Sales order stock
MSPR Project stock
MARM Units of measure
MEAN International article number
PGMI Planning material
PROP Forecast parameters
MAPR Link MARC <=> PROP
MBEW Material valuation
MVER Material consumption
MLGN Material / Warehouse number
MLGT Material / Storage type
MPRP Forecast profiles
MDTB MRP table
MDKP Header data for MRP document
MLAN Tax data material master
MTQSS Material master view: QM
3.1.1 Basic data text (sap script)
STXB SAP script: Texts in non-SAP script format
STXH STXD SAP script text file header
STXL STXD SAP script text file lines
3.1.2 Batches
MCHA Batches
MCH1 Batches
MCHB Stock : batches
3.2 Customer master data
KNA1 Customer master
KNB1 Customer / company
KNVV Customer sales data
KNBK Bank details
KNVH Customer hierarchy
KNVP Customer partners
KNVS Shipment data for customer
KNVK Contact persons
KNVI Customer master tax indicator
3.3 Vendor
LFA1 Vendor master
LFB1 Vendor per company code
LFB5 Vendor dunning data
LFM1 Purchasing organization data
LFM2 Purchasing data
LFBK Bank details

3.4 Customer – material info record
KNMT Customer material info record
3.5 Bank data
BNKA Master bank data

4 Characteristics :
4.1 Characteristics :
CABN Characteristics ( o.a. batch/vendor)
CABNT Characteristics description
CAWN Characteristics ( o.a. material)
CAWNT Characteristics description
AUSP Characteristic Values
4.2 Class types and objects :
TCLAO Several class types for object
TCLA Class types ( vb. lfa1 => v10 en 010)
TCLAT Class type text
TCLT Classifiable objects
TCLC Classification status
4.3 Links :
INOB Link between Internal Number and Object
KLAH Class header data
KSSK Allocation Table: Object (vb.matnr) to Class
KSML Characteristics for a class (internal number)
5 FI/CO :
5.1 FI :
5.1.1 Master data
SKA1 Accounts
BNKA Bank master record
5.1.2 Accounting documents // indices
BKPF Accounting documents
BSEG item level
BSID Accounting: Secondary index for customers
BSIK Accounting: Secondary index for vendors
BSIM Secondary Index, Documents for Material
BSIP Index for vendor validation of double documents
BSIS Accounting: Secondary index for G/L accounts
BSAD Accounting: Index for customers (cleared items)
BSAK Accounting: Index for vendors (cleared items)
BSAS Accounting: Index for G/L accounts (cleared items)
5.1.3 Payment run
REGUH Settlement data from payment program
REGUP Processed items from payment program
5.2 CO :
TKA01 Controlling areas
TKA02 Controlling area assignment
KEKO Product-costing header
KEPH Cost components for cost of goods manuf.
KALO Costing objects
KANZ Sales order items - costing objects
5.2.1 Cost center master data
CSKS Cost Center Master Data
CSKT Cost center texts
CRCO Assignment of Work Center to Cost Center
5.2.2 Cost center accounting
COSP CO Object: Cost Totals for External Postings
COEP CO Object: Line Items (by Period)
. COBK CO Object: Document header
COST CO Object: Price Totals


6 Sales and Distribution (SD) :

VBFA Document flow (alg.)
VTFA Flow shipping documents
6.1 Sales order :
VBAK Header data
VBAP Item data
VBPA Partners in sales order
VBKD Sales district data
VBEP Data related to line items, delivery lines
6.2 Billing document :
VBRK header data
VBRP Item data
6.3 Shipping :
VTTK Shipment header
VTTP Shipment item
VTTS Stage in transport
VTSP Stage in transport per shipment item
VTPA Shipment partners
VEKP Handling Unit - Header Table
VEPO Packing: Handling Unit Item (Contents)
6.4 Delivery :
LIKP Delivery header
LIPS Delivery item
6.5 Pricing :
KONH Conditions header
KONP Conditions items
KONV Procedure ( billing doc or sales order)
KOND
6.6 contracts :
VEDA Contract data

7 Material Management (MM) :
7.1 Material document
MKPF material document
MSEG material document (item level)
7.2 Purchasing
EKKO Purchase document
EKPO Purchase document (item level)
EKPV Shipping-Specific Data on Stock Tfr. for Purch. Doc. Item
EKET Delivery schedule
VETVG Delivery Due Index for Stock Transfer
EKES Order Acceptance/Fulfillment Confirmations
EKKN Account assignment in purchasing
EKAN Vendor address purchasing
EKPA Partner functions
EIPO Item export / import data
EINA Purchase info record (main data)
EINE Purchase info record (organizational data)
EORD Source list
EBAN Purchase requisition
EBKN Purchase Requisition Account Assignment

8 Warehouse Management (WM) :
8.1 Transfer requirement
LTBK Transfer requirement - header
LTBP Transfer requirement - item
8.2 Transfer order
LTAK Transfer order - header
LTAP Transfer order - item
8.3 Master data - stock positions
LQUA Quants
8.4 Inventory documents in WM
LINK Inventory document header
LINP Inventory document item
LINV Inventory data per quant


9 Quality Management (QM) :

9.1 Inspection lot / info record
QALS Inspection lot record
QAMB Link inspection lot - material document
QAVE Inspection usage decision
QDPS Inspection stages
QMAT Inspection type - material parameters
QINF Inspection info record (vendor - material)
QDQL Quality level
QDPS Inspection stages
9.2 Quality notification
TQ80 Notification types
QMEL Quality notification
QMFE Quality notification – items
QMUR Quality notification – causes
QMSM Quality notification – tasks
QMMA Quality notification – activities
QMIH Quality message - maintenance data excerpt
9.3 Certificate profile
QCVMT Certificate profile characteristic level: texts
QCVM Certificate profile characteristic level
QCVK Certificate profile header

10 Production Planning (PP)
10.1 Work center
CRHH Work center hierarchy
CRHS Hierarchy structure
CRHD Work center header
CRTX Text for the Work Center or Production Resource/Tool
CRCO Assignment of Work Center to Cost Center
KAKO Capacity Header Segment
CRCA Work Center Capacity Allocation
TC24 Person responsible for the workcenter
10.2 Routings/operations
MAPL Allocation of task lists to materials
PLAS Task list - selection of operations/activities
PLFH Task list - production resources/tools
PLFL Task list - sequences
PLKO Task list - header
PLKZ Task list: main header
PLPH Phases / suboperations
PLPO Task list operation / activity
PLPR Log collector for tasklists
PLMZ Allocation of BOM - items to operations
10.3 Bill of material
STKO BOM - header
STPO BOM - item
STAS BOMs - Item Selection
STPN BOMs - follow-up control
STPU BOM - sub-item
STZU Permanent BOM data
PLMZ Allocation of BOM - items to operations
MAST Material to BOM link
KDST Sales order to BOM link
10.4 Production orders
AUFK Production order headers
AFIH Maintenance order header
AUFM Goods movement for prod. order
AFKO Order header data PP orders
AFPO Order item
RESB Order componenten
AFVC Order operations
AFVV Quantities/dates/values in the operation
AFVU User fields of the operation
AFFL Work order sequence
AFFH PRT assignment data for the work order(routing)
JSTO Status profile
JEST Object status
AFRU Order completion confirmations
PRT’s voor production orders
AFFH PRT assignment data for the work order
CRVD_A Link of PRT to Document
DRAW Document Info Record
TDWA Document Types
TDWD Data Carrier/Network Nodes
TDWE Data Carrier Type
10.5 Planned orders
PLAF Planned orders
10.6 KANBAN
PKPS Kanban identification, control cycle
PKHD Kanban control cycle (header data)
PKER Error log for Kanban containers
10.7 Reservations
RESB Material reservations
RKPF header
10.8 Capacity planning
KBKO Header record for capacity requirements
KBED Capacity requirements records
KBEZ Add. data for table KBED (for indiv. capacities/splits)
10.9 Planned independent requirements
PBIM Independent requirements for material
PBED Independent requirement data
PBHI Independent requirement history
PBIV Independent requirement index
PBIC Independent requirement index for customer req.


11 Project system (PS)
11.1 Basic data
PRHI Work Breakdown Structure, Edges (Hierarchy Pointer)
PROJ Project definition
PRPS WBS (Work Breakdown Structure) Element Master Data

RPSCO Project info database: Costs, revenues, finances
MSPR Project stock

11.2 Equipment
EQUI Equipment master data
EQKT Equipment short text
EQUZ Equipment time segment



12 Plant maintenance (PM)
IHPA Plant Maintenance: Partners
OBJK Plant Maintenance Object List ILOA PM Object Location and Account Assignment
AFIH Maintenance order header
12.1 Human resources
12.2 Settings
T582A Infotypes: Customer-Specific Settings
12.3 Master data
T527X Organizational Units
T528T Position Texts
T554T Attendance and Absence Texts
T501 Employee group
T503 Employee group, subgroup
T503K Employee subgroup
T510N Pay Scales for Annual Salaries (NA)
T549A Payroll Accounting Areas
T750X Vacancy
12.4 Infotypes
PA0001 Org. Assignment
PA0002 Personal Data
PA0006 Addresses
PA0007 Planned Working Time
PA0016 Contract elements
PA0008 Basic pay
PA0105 Communications
PA1007 Vacancies
PA1035 Training
PA2001 Absences