Abap program standards

hi all,
     i need to design flow chart for checking for a program whether it satifies the abap coding standards or not. who to do it. if possible send me graphical representations [flow charts]  or links to find programming standards.
some of my requirements in that folw chart are
  1. how to recognize a blank space in a given program,
  2. how to recognize a comment,
  3. how to check wheteher a keyword is used or not,
  4. how to identify the ' :' symbol
thanks & regards,
suresh babu aluri.

plz go through this documementaion,
i think its helpful.
ABAP Programming StandardsContents
1.     Objective     5
2.     Naming Conventions     5
2.1     Codes for naming conventions     5
2.1.1     Module Codes     5
2.1.2     Free text     6
2.2     Naming Convention of Development Objects     6
2.2.1     Package     6
2.2.2     Executable Program     6
2.2.3     BSP Application     7
2.2.4     Logical Database     8
2.2.5     SAP Scripts /Smartforms     9
2.2.6     Idocs     9
2.2.7     Transaction Code     10
2.2.8     Function Groups     10
2.2.9     Dictionary Objects     11
2.2.10     Message Class     11
2.2.11     Enhancement Projects (User Exits)     11
2.2.12     LSMW Objects     12
2.2.13     Classes     12
2.2.14     BOR Object Types     13
2.2.15     Screen / Transaction Variants     13
2.2.16     Area Menu     13
2.3     Naming of Sub-Objects     13
2.3.1     Program Sub-Objects     13
2.3.2     SAP Script /Smartform sub-objects     14
3.     General Programming Guidelines     14
3.1     Modification Logs     14
3.2     Program Organization     15
3.2.1     Executable Programs     15
3.2.2     Dialog Programs     15
3.3     Package     15
3.3.1     Adding Components to existing objects     15
3.3.2     Creation of New Objects     15
3.4     Program Messages     15
3.4.1     Adding Messages to existing landscapes     15
3.4.2     Creation of New Objects     16
3.5     Dictionary Objects     16
4.     Structure of ABAP Programs     16
4.1     Type     16
4.2     Status     18
4.3     Authority Check     18
4.4     Program Structure     19
4.4.1     Declaration data for global data, classes and selection screens     19
4.4.2     Container for Processing Blocks     19
4.4.3     Calling Processing Blocks     20
4.5     Screen Flow Logic (Dialog Programs)     20
4.5.1     Place the AT EXIT COMMAND at the beginning of the flow logic.     20
4.5.2     Use FIELD and CHAIN statements to keep fields in error open for correction.     20
4.6     Main Program     20
4.6.1     Events     20
5.     General Coding Standards     21
5.1     One command per line     21
5.2     Indented Source Code     21
5.3     Extended Syntax Check     21
5.4     Reusability and Modularity     21
5.5     Text Handling     21
5.6     Usage of System Variables     22
5.7     Chaining Statements     22
5.8     Common Routines     22
5.9     Dialog Messages     22
5.10     Function Keys     23
5.11     Enqueuing and Dequeuing Data Objects     23
5.12     Error Handling (SY-SUBRC)     23
5.13     General Conventions and Hints     24
5.14     Parameters in Sub-Routines     24
6.     Performance Standards     25
6.1     General Tips on Performance Tuning     25
6.1.1     Avoid Redundant code     25
6.1.2     Subroutine Usage     25
6.1.3     Case vs. Nested IF     25
6.1.4     Using the MOVE Statement     25
6.1.5     SELECT Queries     25
6.1.6     Using the READ statement     27
6.1.7     Hashed table     27
6.1.8     Transporting     28
6.1.9     Using LDB     28
6.1.10     Append Lines of     28
6.1.11     Use WHILE     28
6.1.12     DELETE <itab> WHERE     28
6.1.13     Using WHERE clause in LOOP…….ENDLOOP     28
1.     Objective
The objective of this document is to describe general programming guidelines, methodologies, Naming conventions and performance guidelines for all the programs developed for SAP Project.
2.     Naming Conventions
This chapter describes the naming conventions to be followed for naming the programming objects for SAP project.
2.1      Codes for naming conventions
The variable portion of naming convention is given with Code ID given in angle brackets(<>). Use the following tables for replacing code IDs with codes in the object naming.
2.1.1     Module Codes
Code ID:  mm
Code     Description
FI     Finance
CO     Controlling Module
MM     Materials Management
PP      Production Planning
SD     Sales & Distribution
QM      Quality Management
PM     Plant Maintenance
IM     Inventory Management
WM     Warehouse Management
BC     Basis Module
BW     Business Warehouse
WF     Workflows (Master Data Management)
HR     Human Resources
EBP     EBP
PS     Project Systems
PCP     Synpro: Product Costing
PAP     Synpro: COPA
DP     APO :  Demand Planning
SP     APO :  Supply Network Planning
DS      APO : Production Planning & Detailed Scheduling
AT     APO : Global ATP
TP     APO : Transportation Planning/Vehicle Scheduling
CI     Core Interface
LC     Live Cache
2.1.2     Free text
Code ID: ffff
Developer should replace ‘ffff’ with meaningful text. The text can be multiple words separated by underscore.
2.2     Naming Convention of Development Objects
2.2.1     Package
Naming Convention: Z<mm>_<ffff>.
Notes:
1.     Replace <mm> with Module codes given in section 2.1.1 above.
2.     Replace <ffff> with the sub-landscape of the Module that this Message Class caters to as illustrated in examples below.
3.     The maximum permissible length for development class is 30 characters
Examples:
Dev. Class     Description
ZFI_AR     FI: Account Receivables
ZCO_CCA     CO: Cost Center Accounting
2.2.2     Executable Program
Naming Convention: Z<mm>_<ffff>.
Notes:
1.     Replace <mm> with module codes given in section 2.1.1 above.
2.     Replace <ffff> with meaningful text as illustrated in examples below.
3.     The maximum permissible length for program name is 30 characters. However, the name should be restricted to 25 characters to accommodate appropriate Include naming as described in 2.2.2.
Examples:
Program Name     Description
ZFI_VAT_RET     FI:  Report for VAT Return
ZMM_AUTO_GR     MM: Automated Goods Receipt
ZSD_XX_STCK_SHORTAGE     SD: Stock shortage report for stock allocation
2.2.2.1     Includes for executable programs
Naming Convention: Z<mm>_<ffff>_<Inn>.
Notes:
1.     All includes of executable program will be prefixed by Z, followed by the same program name as described in 2.2.2 above.
2.     Replace <Inn> with include type and sequence number. Use the following table for includes.
Include Type ID     Description
TOP     Top Include.
Fnn     Subroutine pool (Forms)
Inn     PAI Modules
Onn     PBO Modules
Xnn     Other Includes
The maximum permissible length for Include name is 30 characters.
Examples:
Include Name     Main Program Name     Description
ZFI_VAT_RET_TOP     ZFI_VAT_RET     FI:  Report for VAT Return – Top Include
ZFI_VAT_RET_F01     ZFI_VAT_RET     FI:  Report for VAT Return – Forms
ZMM_AUTO_GR_TOP     ZMM_FR_AUTO_GR     MM: – Automated Goods Receipt – Top include
ZMM_AUTO_GR_F01     ZMM_FR_AUTO_GR     MM:– Automated Goods Receipt – Forms
2.2.3     BSP Application
2.2.3.1     Main Application
Naming Convention: BSP Applications shall follow the same Naming Convention as Executable Programs i.e. Z<mm>_<ffff>.
Notes:
1.     Replace <mm> with module codes given in section 2.1.1 above.
2.     Replace <ffff> with meaningful text as illustrated in examples below.
2.2.3.2     Pages & Controllers
Naming Convention: <ffff>
Notes:
1.     Replace <ffff> with meaningful text, that adequately describes the function of the page/controller
2.2.3.3     Theme
Naming Convention: Z_<ffff>.
Notes:
1.     Replace <ffff> with meaningful text
2.2.3.4     Mime Objects:
Naming Convention: <ffff>
1.     A MIME Object can be logo for the company.
2.     Replace <ffff> with meaningful text, that adequately describes the function of the MIME objects
2.2.3.5     Controller and Handler Classes:
See section Classes (Section 2.2.133)
2.2.3.6     BSP Extension
Naming Convention: Z_<ffff>
Notes:
1.     Replace <ffff> with meaningful text
2.2.3.7     BSP Layout elements id
Label:     lb_fffff
Input field:     if_fffff
Button:     b_fffff
Text Edit:     te_fffff
Text View:     tv_fffff
Radio button Group:     rbg_fffff
Radio button:     rb_fffff
Check Box Group:     cbg_fffff
Check Box     cb_fffff
Tray     tr_fffff
Tabstrip     ts_fffff
Tableview      tab_fffff
1.  Replace <fffff> with meaningful text
2.2.4     Logical Database
Naming Convention: Z<mm>_<ffff>.
Notes:
1.     Replace <mm> with module codes given in section 2.1.1 above.
2.     Replace <ffff> with meaningful text
3.     The maximum permissible length for LDB name is 20 characters. However, the name should be restricted to 15 characters to accommodate appropriate Include naming
4.     LDB Program and LDB Program Includes shall follow the naming convention Auto-Generated by SAP
2.2.5     SAP Scripts /Smartforms
Naming Convention: ZF<mm>_<ffff>.
Notes:
1.     Replace <mm> with module codes given in section 2.1.1 above.
2.     Replace <ffff> with meaningful text as illustrated in examples below.
Examples:
Form Name     Description
ZFFI_EMP_CONF     Employee Confirmation Letter
ZFFI_ANN_TO     Annual Turnover Letter To Customers and Vendors
2.2.6     Idocs
2.2.6.1     Idoc Types
Basic Type :
Naming Convention : ZB<FFFF>NN
Notes:
1.Replace <NN> with sequence number.
3.     Replace <ffff> with meaningful text.
Extension Type : ZX<Basic type name>_NN
Notes:
1.     Replace <NN> with sequence number .
2.2.6.2     Message Types
Naming Convention :  ZM<mm><ffff>.
Notes :
1.   Replace <mm> with module codes given in section 2.1.1 above.
2.  Replace <ffff> with meaningful text .
2.2.6.3      Process Code
Naming Convention :  Z<ffff>.
Notes :
1.     Replace <ffff> with meaningful text ..
2.2.6.4     IDOC Segments
Naming Convention :  Z1<ffff>.
Notes :
1.Replace <ffff> with meaningful text as illustrated in examples below.
2.2.7     Transaction Code
Notes:
1.     The tcode name is provided by SAP TIN The Developer must write a mail to SAP Tin asking for the T-Code name with a filled form.
The form can be found at :
2.2.8     Function Groups
Naming Convention: Z<mm><ffff>
Notes:
1.     Replace <mm> with relevant module code as given above
2.     Replace <ffff> with meaningful text.
2.2.8.1     Function Group Include Programs
Naming Convention: LZ<Function Group><Inn>.
Notes:
1.     All includes of Function Group program will be prefixed by LZ, followed by the Function Group name
2.     Replace <Inn> with include type and sequence number. Use the values from the table given in 2.2.2.1
Examples:
Include Name     Function Group Name     Description
SAPLZMMPURCHASING     ZMMPURCHASING     F.Group-Purchasing: Main Program
LZMMPURCHASINGO01     ZMMPURCHASING     F.Group-Purchasing: PBO
LZMMPURCHASINGI01     ZMMPURCHASING     F.Group-Purchasing: PAI
LZMMPURCHASINGF01     ZMMPURCHASING     F.Group-Purchasing: Forms
LZMMPURCHASINGTOP     ZMMPURCHASING     F.Group-Purchasing: Data Declarations
2.2.8.2     Function Modules
2.2.8.2.1     Normal Function Modules
Convention: Z_<mm>_<ffff>.
Notes:
1.     Replace <mm> with relevant module code as given above.
2.     Replace <ffff> with meaningful text.
2.2.8.2.2     IDOC Function Modules
Convention: Z_IDOC_<mode>_<msg type>.
Notes:
1.     Replace <mode> with INPUT or OUTPUT depending on whether the function processes incoming or outgoing IDOC.
2.     Replace <msg type> with the IDOC message type.
2.2.9     Dictionary Objects
Tables:      Z<mm><ffff>
Structures:      ZS<mm><ffff>
Views:      ZV<mm><ffff>
Data Element:      ZDE<mm><ffff>
Domain:      ZDO<mm><ffff>
Table Type:      ZTT<mm><ffff>
Type Group:      Z<ffff>
Search Help:      ZSH<mm><ffff>
Lock Object:      EZ<mm><ffff>
Notes:
1.     Replace <mm> with module code given above.
2.     Replace <ffff> with meaningful text.
2.2.10     Message Class
Naming Convention: Z<mm>_<ffff>.
Notes:
1.     Replace <mm> with Module codes given in section 2.1.1 above.
2.     Replace <ffff> with the sub-landscape of the Module that this Message Class caters to as illustrated in examples below.
3.     The maximum permissible length for development class is 30 characters
Examples:
Msg. Class     Description
ZFI_AR     FI: Account Receivables
ZCO_CCA     CO: Cost Center Accounting
2.2.11     Enhancement Projects (User Exits)
Convention: Z<XX><nn>.
Notes:
1.     XX is the application area code e.g. for sales it is SD etc.
2.     'nn'  is one up number for one application area. It starts with 001.
3.     Maximum length of the Project name is 8.
Example:  The name of the SD enhancement project can be ZSD001.
2.2.12     LSMW Objects
2.2.12.1     Project
Naming Convention: ZM_<ffff>.
Notes:
1.     1.     Replace <ffff> with meaningful text
2.     The maximum permissible length for Project name is 16 characters. But please limit it to 12.
Example : ZM_VENDOR
2.2.12.2     SubProject
Naming Convention: ZM_<ffff>_<n>.
Notes:
     Suffix Project name with a running sequence no.
Example : ZM_VENDOR_1
2.2.12.3     Object
Naming Convention: ZM_<ffff>_<n><n>.
Notes:
     Suffix Subproject name with a running sequence no.
Example : ZM_VENDOR_11
2.2.13     Classes
Naming Convention: ZCL_[IM/DF/BSPCO/BSPHN/BADI]_<ffff>.
1.     IM: Implementation Class;
DF: Definition Class
BSPCO: BSP Controller class
BSPHN: BSP Handler class
BADI : BADI implementation
2.     Replace <ffff> with meaningful text: In case of Implementation classes, it should preferably be the same as that of the Definition Class
3.     Example:
IMPLEMENTATION Class: ZCL_IM_REBATE_SETTL
DEFINITION: ZCL_DF_REBATE_SETTL
2.2.14     BOR Object Types
Object     Convention     Example
Supertype     Z<ffff>     ZLVAPPL
SubType     Z<SuperType><nn>     ZZLVAPPL01
Program     <Subtype>     ZZLVAPPL01
1.     Replace <nn> with a running 2 digit serial Number
2.     Replace <ffff> with meaningful text
2.2.15     Screen / Transaction Variants
Naming Convention: <tcode>_<ffff>
Where:
1.     Replace <tcode> with the t-code that will be assigned to this Variant
2.     Replace ffff with a meaningful text
E.g.:
For an SE16 variant for table KONA that will be used by T-Code Z_CH_SD_001:
Z_CH_SD_001_KONA
2.2.16     Area Menu
Naming Convention: Z<mm>_<Main Menu>_<Sub Menu>…<ffff>
Where:
1.     Replace <mm> with the Module code
2.     Followed by the hierarchical position of the immediate parent of this Area Menu
3.     Followed by a Meaningful text for this Menu
E.g.:
ZSD
ZSD_TAB
ZSD_TAB_VIEW
ZSD_TAB_UPDT
Notes:
1.     Clusters of Transactions should be introduced as Sub-Menus rather than as Folders
2.     As a gradual process, the current Clusters that exist as Folders should also be replaced with Sub-Menus
2.3     Naming of Sub-Objects
2.3.1     Program Sub-Objects
Naming of all the internal components of a program will be consistent across the project.
Naming Convention: <Prefix>ffff.
Notes:
1.     Replace <Prefix> with the component prefix values given in the table below.
Program Component     Prefixed by
Program Constants     C_
Global Variables     W_
Types Definition     T_
Global Structures     WA_
Global Internal Tables     I_
Select-Options     SO_
Parameters     PO_
Table Type     TT_
Field Symbols     FS_
Ranges     R_
Local Constants     LC_
Local Variables     L_
Local Static Variables     LS_
Local Internal Tables     LI_
Local Work Area     LWA_
Local Range     LR_
Field Groups     FG_
Container      CO_
Macro     MA_
Important: The Same sequence as above must be followed in the Data declaration part of all the ABAP/4 programs.
2.3.2     SAP Script /Smartform sub-objects
Naming of all the internal components of a SAPScript/SmartForm shall follow the same convention as for Programs (2.2.2), with the addition of the Field Label on the FRS. E.g. if the FRS has labeled a field for Sales Order Number as Field 27 on the Layout, the variable name should be W_27_VBELN.
3.     General Programming Guidelines
3.1     Modification Logs
At the top of every ABAP Object Modified by a Developer, there should be a Modification Log Every Line Created/Changed by the developer should be Identifiable by the TR Number.
ABAP Patterns: Following Patterns should be used for Uniform ModLogs:
Nature of Change     Pattern to Use
New Development     ZZNEWPROG
In-Line Logs     ZZLINE
Modification Logs at the Top of Object     ZZMODLOG
3.2     Program Organization
All the programs will be organized as described below.
3.2.1     Executable Programs
TOP Include: For global data declarations
Form Include: For definition of all the FORMs.
3.2.2     Dialog Programs
TOP Include: For global data declarations
Form Include: For definition of all the FORMs.
PBO Include: Include for PBO Modules
PAI Include: Include for PAI Modules
3.3     Package
All the related objects within a sub-module of SAP will be developed under a single Package.
3.3.1     Adding Components to existing objects
When adding new workbench components to existing Objects, the same Package will be used as has been used for the existing Components
3.3.2     Creation of New Objects
When creating new Objects or new Sub-lanscapes, Packages used should have the Naming convention as in Section 2 Above
3.4     Program Messages
All the messages within a sub-module of SAP will be grouped under a single Message Class.
3.4.1     Adding Messages to existing landscapes
When adding new messages for existing Objects, the same Message Class will be used as has been used for the existing Objects
3.4.2     Creation of New Objects
When creating new Objects or new Sub-landscapes, Message classes used should have the Naming convention as in Section 2 Above
3.5     Dictionary Objects
Whenever you create a Z table in  system always include MANDT field as the first field, except when the table contains client independent data. Also create the table with attribute Data Class as USER.
4.     Structure of ABAP Programs
4.1     Type
•     When an ABAP program is run, its processing blocks are called. ABAP programs are controlled from outside the program itself by the processors in the current work process. For the purposes of program flow, we can summarize the screen processor and ABAP processor into the ABAP runtime environment. The runtime environment controls screens and ABAP processing blocks. It contains a range of special control patterns that call screens and processing blocks in certain orders. These sections are also called processors. When a ABAP program is run, the control passes between various processors.
•     In the R/3 System, there are various types of ABAP program. The program type determines the basic technical attributes of the program, and must be set when created. The main difference between the different program types is the way in which the runtime environment calls its processing blocks.
•     When an application program is run, it must at least call the first processing block from outside the program, that is, from the runtime environment. This processing block can then either call further processing blocks or return control to the runtime environment. When an ABAP program is started, the runtime environment starts a processor (dependent on the program type), which calls the first ABAP processing block.
•     The following program types are relevant to application programming:
Type 1
•     Type 1 programs have the important characteristic that they do not have to be controlled using user-defined screens. Instead, they are controlled by the runtime environment, which calls a series of processing blocks (and selection screens and lists where necessary) in a fixed sequence. User actions on screens can then trigger further processing blocks.
Type M
•     The most important technical attribute of a type M program is that it can only be controlled using screen flow logic and run via a transaction code which is linked to the program and one of its screens (initial screen).
•     ABAP programs with type M contain the dialog modules belonging to the various screens. They are therefore known as module pools.
Type F
•     Type F programs are containers for function modules, and cannot be started using a transaction code or by entering their name directly.
•     Type F programs are known as function groups. Function modules may only be programmed in function groups. The Function Builder is a tool in the ABAP Workbench that is used to create function groups and function modules. Apart from function modules, function groups can contain global data declarations and subroutines. These are visible to all function modules in the group. They can also contain event blocks for screens in function modules.
Type K
•     Type K programs are containers for global classes in ABAP Objects. Type K programs are known as class definitions. The Class Builder is a tool in the ABAP Workbench that can be used to create class definitions.     
Type J
•     Type J programs are containers for global interface in ABAP Objects. Type J programs are known as interface definitions and are created in the Class Builder.
Type I
•     Type I programs - called includes - are a means of dividing up program code into smaller, more manageable units. The coding of an include program can be inserted at any point in another ABAP program using the INCLUDE statement. There is no technical relationship between include programs and processing blocks. Includes are more suitable for logical programming units, such as data declarations, or sets of similar processing blocks. The ABAP Workbench has a mechanism for automatically dividing up module pools and function groups into include programs.
4.2     Status
P = SAP standard production program
K = Customer production program
S = System program
T = Test program
Application
•     Categorize the program according to the purpose it fulfills.
4.3     Authority Check
Authority checks will be carried out as given in the respective FRS’s.
4.4     Program Structure
ABAP programs are responsible for data processing within the individual dialog steps (ie. events) of an application program. This means that the program cannot be constructed as a single sequential unit, but must be divided into sections that can be assigned to the individual dialog steps. To meet this requirement, ABAP programs should have a modular structure. Each module is called a processing block. A processing block consists of a set of ABAP statements. When a program is run, effectively a series of processing blocks is called. Therefore, they should not be nested but modularized.
•     Each ABAP program consists of the following two parts:
4.4.1     Declaration data for global data, classes and selection screens
•     The first part of an ABAP program is the declaration part for global data, classes, and selection screens. This consists of:
•     All declaration statements for global data. Global data is visible in all internal  processing   blocks and should be defined using declarative statements that appear before the first processing block, in dialog modules, or in event blocks. Local data should not be declared in dialog modules or event blocks.
•     All selection screen definitions.
•     All local class definitions (CLASS DEFINITION statement). Local classes are part of ABAP Objects, the object-oriented extension of ABAP.
•     Declaration statements which occur in procedures (methods, subroutines, function modules) form the declaration part for local data in those processing blocks. This data is only visible within the procedure in which it is declared.
4.4.2     Container for Processing Blocks
•     The second part of an ABAP program contains all of the processing blocks for the program. The following types of processing blocks are allowed:
1.     Dialog modules (no local data area)
2.     Event blocks (no local data area)
3.     Procedures (methods, subroutines and function modules with their own local data area).
•     Whereas dialog modules and procedures are enclosed in the ABAP keywords which define them, event blocks are introduced with event keywords and concluded implicitly by the beginning of the next processing block.
•     All ABAP statements (except declarative statements in the declaration part of the program) are part of a processing block. Non-declarative ABAP statements, which occur between the declaration of global data and a processing block are automatically assigned to the START-OF-SELECTION processing block.
4.4.3     Calling Processing Blocks
•     Processing blocks can be called from either the ABAP program or using ABAP commands which are themselves part of a processing block. Dialog modules and event blocks are called from outside the ABAP program. Procedures are called using ABAP statements in ABAP programs.
•     Calling event blocks is different from calling other processing blocks for the following reasons:
•     An event block call is triggered by an event. User actions on selection screens and lists, and the runtime environment trigger events that can be processed in ABAP programs. Define event blocks for the events that the program needs to react to (whereas a subroutine call, for example, must have a corresponding subroutine). This ensures that while an ABAP program may react to a particular event, it is not forced to do so.
4.5     Screen Flow Logic (Dialog Programs)
4.5.1     Place the AT EXIT COMMAND at the beginning of the flow logic.
Example:
PROCESS AFTER INPUT
   MODULE EXIT_1170 AT EXIT-COMMAND.
   MODULE PAINT_1170.
4.5.2     Use FIELD and CHAIN statements to keep fields in error open for correction.
Example:
   PROCESS AFTER INPUT.
   MODULE EXIT_1170 AT EXIT-COMMAND.
   CHAIN.
      FIELD BTCH1170-JOBNAME.
      FIELD BTCH1170-USERNAME.
      FIELD BTCH1170-FROM_DATE.
      FIELD BTCH1170-FROM_TIME.
      MODULE PAINT_1170.
   ENDCHAIN.
4.6     Main Program
4.6.1     Events
The Program MUST NOT be coded without the use of Proper Coding blocks
•     Initializations
•     Top-of-page during line-selection
•     At Selection-Screen
•     At Line-Selection
•     At User-Command
•     At Pfn
•     Start-Of-Selection
•     Top-Of-Page
•     Get
•     End-Of-Page
•     End-Of-Selection
NOTE: The coding for each event should be logically split into forms (subroutines). That is to say, each event will comprise mostly of ‘PERFORM’ statements.
5.     General Coding Standards
5.1     One command per line
Each ABAP/4 command consists of a sentence ending with a period. Multiple commands can be on one line; however, as a standard start each new command on a new line. This will allow for easier deleting, commenting, and debugging.
5.2     Indented Source Code
The ABAP/4 editor has a "Pretty Printer" command to indent by 2 positions specific lines of code and add subroutine comments. Event keywords are typically not indented.
5.3     Extended Syntax Check
Extended Program Check (EPC) to be done on each object to make sure the code is Syntactically correct. There should be no Error/warning messages in the code.
5.4     Reusability and Modularity
If a block of code is executed more than once, it should be placed in a subroutine at the bottom of the code. This makes the code more readable, requires less indentation, and is easier to debug since the debugger can jump through an entire subroutine via a PF key. Also, when possible parameters should be passed to and from subroutines to make the purpose easier to understand and reduce the need for global variables. Always document the purpose of each parameter.
5.5     Text Handling
Text elements must be used to display any text messages.
5.6     Usage of System Variables
The system variables should be used wherever possible. The SY-SUBRC is to be checked after any function call, selection operation, etc.
5.7     Chaining Statements
•     Consecutive sentences with an identical beginning shall be combined into a chained statement.
Example:
Instead of the statements
MOVE SY-MANDT TO D00001-MANDT.
MOVE SY-LANGU TO D00001-SPRAS.
A chained statement shall be used
MOVE:
             SY-MANDT TO D00001-MANDT,
             SY-LANGU TO D00001-SPRAS,
             SY-UNAME TO D00001-BNAME.
5.8     Common Routines
•     Standard sub-routines should be implemented as FUNCTION's rather than a FORM (ie. SUBROUTINE). A FUNCTION is easier to maintain and can be easily tested without a calling program. Standard SAP function modules are also available and the function library should be used to check if function modules already exist for a function that needs to be performed i.e.POPUP_TO_CONFIRM_LOSS_OF_DATA etc.
•     Includes can also be created for re-usable or common code e.g. common data declaration statements.
5.9     Dialog Messages
Dialogue messages are stored in table T100. Programmers shall check to see if an appropriate message exists before adding a new message. Programs shall use the message-id which corresponds to the SAP module that the program most relates to.
5.10     Function Keys
PF-keys should be programmed to execute functions where required. SAP Standard function keys should be used where appropriate. The most commonly used buttons should be displayed as pushbuttons in the application toolbar.
5.11     Enqueuing and Dequeuing Data Objects
•     All database objects being processed by a program, for purposes other than for display, shall be enqueued before such processing is executed. If the enqueue is unsuccessful, then a message shall be returned stating why the enqueue was unsuccessful.
•     Enqueue and Dequeue objects should be created via the data dictionary.
5.12     Error Handling (SY-SUBRC)
•     Return codes shall always be checked immediately after an event which returns a code.  
Eg. Function calls, Select statements, Updates etc.
•     The value of SY-SUBRC is 0 when successful and generally produces a value of 4 when unsuccessful (there are a few exceptions).
Therefore, rather check SY-SUBRC with:
           IF SY-SUBRC <> 0
than with
         IF SY-SUBRC = 4  (which is redundant and makes the system do a double check)
•     Error messages displayed to the user must be clear and descriptive.
•     Remember to group related / dependant steps together and to Rollback all changes for steps in that group should any one of them fail, thus maintaining the integrity of the system.
•     Check whether an Error Log, (file), must be produced by your program and if so check on the format of the file.
•     If any Error Logging is done to a custom table in the database then make sure this table is maintained and monitored correctly. (Dev. Note)
•     Transaction SE91 provides the facility to create and utilize messages in their appropriate message class. Elaborate on the message if necessary, using the long text documentation for that message number.
5.13     General Conventions and Hints
•     There should be NO hard coding of values in programs – easy maintainability
•     For amounts, use the CURRENCY command in write statements to automatically convert fields into their correct decimal format. The currency specified in the write statement is treated as a key for the table TCURX. If no entry exists for the currency specified, the system assumes two decimal places.
•     For quantities, use the UNIT command in write statements to automatically convert fields into their correct decimal format. The contents of the unit specified are used on table T006. If no entry exists for the unit specified, the formatting has no effect.
•     Use the ‘LIKE’ statement as often as possible to declare ‘DATA’ variables instead of an explicit ‘TYPE’ declarations.
•     Try to use the ‘INCLUDE’ statement with standard SAP structures and tables for your structures and internal tables where possible.  If you use the include statement to include other program components in your code then document what those components are, what they do and how to use them.
•     Try to make use of standard SAP Function Modules wherever possible rather than building your own. Use the pull down functionality in transaction SE37 to find suitable standard function modules.
•     Make use of the SAP PATTERN tool to automatically insert the standard code for:
•     CALL FUNCTION
•     MESSAGE ID
•     SELECT*FROM
•     PERFORM
•     AUTHORITY-CHECK
•     WRITE
•     CASE
•     CALL DIALOG
•     The standard date format to use is ‘DD/MM/YYYY’. (Dev. Note)
The standard time format to use is ‘HH:MM:SS’.
5.14     Parameters in Sub-Routines
Naming convention for Parameters in subroutine is P_
6.     Performance Standards
6.1     General Tips on Performance Tuning
6.1.1     Avoid Redundant code
Avoid leaving "dead" code in the program. Comment out variables that are not referenced and code that is not executed. To analyze the program, use the Program Analysis function in SE38 -> Utilities -> Program Analysis.
6.1.2     Subroutine Usage
For good modularization, the decision of whether or not to execute a subroutine should be made before the subroutine is called.
Example:
IF f1 NE 0.
  PERFORM sub1.
ENDIF.
FORM sub1.
ENDFORM.
6.1.3     Case vs. Nested IF
When testing fields "equal to" something, one can use either the nested IF or the CASE statement. The CASE is better for two reasons. It is easier to read and after about five nested IFs the performance of the CASE is more efficient.
6.1.4     Using the MOVE Statement
When records a and b have the exact same structure, it is more efficient to MOVE a TO b than to MOVE-CORRESPONDING a TO b.
6.1.5     SELECT Queries
The performance of  any ABAP program mainly depends on the ABAP Queries used in it. More optimum the queries , better the performance. Take care of the points mentioned nin the following sections while writing any ABAP queries.
6.1.5.1     Using all the keys in SELECT statement
When using the SELECT statement, study the key and always provide as much of the left-most part of the key as possible. The SELECT * command is to be avoided everywhere.
6.1.5.2     Fetching Single Record
If the entire key can be qualified, code a SELECT SINGLE not just a SELECT. If all the keys are not available, we should use SELECT UPTO 1 ROWS if we are interested only in the first record.
6.1.5.3     Avoid SELECT-ENDSELECT
Selecting data into an internal table using an array fetch versus a SELECT-ENDELECT loop will give at least a 2x performance improvement.  After the data has been put into the internal data, then row-level processing can be done.  
Example:
select ... from table <..>
           into <itab>
           where ...
loop at <itab>
  <do the row-level processing here>
endloop.
6.1.5.4     Using Indexs
Use indexes wherever possible. Tune the Query so that optimum Indexing will happen.
6.1.5.5     Provide all the keys
Give as many keys as possible in the WHERE clause to optimize the database fetching. Use the Index fields in the first position to optimize performance.
6.1.5.6     Avoid “INTO CORRESPONDING”
Avoid using INTO CORESPONDING FIELDS of Table. Instead, explicitly mention the fields. Else, The Table Fields should be in the same sequence as the selection
6.1.5.7     SELECT statement inside LOOP
Do not write SELECT statements inside the loop. Instead, use the FOR ALL ENTRIES Command
Before using FOR ALL ENTRIES command, check that the
1.     Corresponding Internal table is not empty. If the Internal table is empty, the statement will select ALL the entries in the Database
2.     The Internal table is sorted by the Filed used in the Where Clause: This makes selection faster
6.1.5.8     Nested SELECT statement
Avoid Using nested SELECT statements. Instead, make use of different internal tables to fetch the data, and Use Nested LOOPS to read them.
6.1.5.9     Select Distinct
Whenever its possible avoid SELECT DISTINCT, instead select data into internal table, sort and use DELETE ADJACENT DUPLICATES
6.1.5.10     Use of OR in Where Clause
Do not use OR when selecting data from DB table using an index because The optimizer generally stops if the WHERE condition contains an OR expression.
e.g.
Instead of
     SELECT * FROM spfli WHERE carrid = ‘LH’
                               AND (cityfrom = ‘FRANKFURT’ OR
             city from = ‘NEWYORK’)
Use
     SELECT * FROM spfli WHERE (carrid = ‘LH’ AND cityfrom = ‘FRANKFURT’)
                                  OR (carrid = ‘LH’ AND cityfrom = ‘NEWYORK’).
6.1.5.11     Order By
ORDER BY will Bypass buffer. So, performance will decrease. If you want to sort data, it is efficient to SORT them in INTERNAL TABLE rather than using ORDER BY. Only use an ORDER BY in your SELECT if the order matches the index, which should be used.
6.1.6     Using the READ statement
When reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ. The table needs to be sorted by the Key fields and the command READ TABLE WITH KEY BINARY SEARCH is to be used.
6.1.7     Hashed table
If the number of entries in the Internal Table is high then use Hashed Table with Keys to access the table.
6.1.8     Transporting
With READ or MODIFY Statements use TRANSPORTING
6.1.9     Using LDB
In order to improve performance in case of an LDB, individual tables can be excluded from selection. Under the section ‘Table Selection’ in the Documentation of LDB the fields with proper description has been given those fields can be set in the application report at the time of INITIALIZATION or at the START OF SELECTION. This can enhance the performance.
6.1.10     Append Lines of
Whenever it is possible use APPEND LINES OF to append the internal Tables instead of using loop and then APPEND Statement.
6.1.11     Use WHILE
Use WHILE instead of a DO+EXIT-construction, as WHILE is easier to understand and faster to execute
6.1.12     DELETE <itab> WHERE
Use DELETE <itab> WHERE…for deleting records from an internal table.
e.g.
Instead of
LOOP AT <itab> WHERE <field> = ‘0001’
     DELETE <itab>.
ENDLOOP.
Use
DELETE <itab>  WHERE <field> = ‘0001’.
6.1.13     Using WHERE clause in LOOP…….ENDLOOP
Use:
Sort ITAB by NAME.
Loop at itab where name EQ SY-UNAME
Endloop.
Instead Of:
Read itab with key name = SY-UNAME.
L_tabix = sy-tabix.
Loop at itab from l_tabix.
If name eq ‘bijoy’
Endif.
Endloop.

Similar Messages

  • ABAP programming standards for SELECT...ORDER BY....

    I recently saw a set of programming standards that stated it was better not to use an ORDER BY clause on a SELECT statement. Instead SELECT into an internal table and use SORT. The actual statement was....."In most cases it is preferable to do the sorting within the ABAP program instead of on the database server.  That means: fill the internal table via a SELECT statement and then sort via the SORT statement instead of coding a SELECT u2026 ORDER BY.  The sorting of large amounts of data on the database server affects the performance of all users on the system, whereas the sorting within the ABAP program u2018onlyu2019 affects the application server.  However, if an index exists on the table that can be used for the sorting then the SELECT u2026 ORDER BY doesnu2019t cause any undue strains on the system."
    I think this is no longer correct particularily with regards to Systemi/iSeries which we normally run in 2 tier mode.
    What are people opinion on this?

    Peter,
    the correct answer for DB2 on IBM i is "it depends". To implement "ORDER BY", the optimizer has basically these choices:
    - If an index with the columns of the "ORDER BY" clause exists, the database can access the data through this index, which returns them in the desired order. However, the data needs to be fetched row by row, so for each returned row you need one I/O request.
    - If such an index does not exist, the database can choose to perform a sequential read into a temporary storage and sort the temporary result set before returning the data to the caller. This is basically the same as reading the data into an internal table and let ABAP do the sort. Even if an index exist, reading the whole table into memory and sorting it there may be faster, because on a sequential read, the database can execute a "blocked" fetch rather than many individual I/O operations. You may see this if the table is relatively small.
    - If such an index does not exist, the database could also choose to create a temporary index and access the data through the temporary index. For the first execution, you don't gain much, but subsequent executions may perform much better. However, after an IPL you loose all temporary indexes, so the index needs to be built again on the first execution after the IPL.
    If you code your ABAP to read the table sequentially and sort it in memory, you are forcing the second implementation. If you code ABAP with the ORDER BY in the SELECT statement, you allow the database optimizer to choose the best possible implementation depending on the size of the table, the size of the result set, and the available indexes.
    If your table is relatively large but the result set (based on the WHERE clause) is relatively small, make sure to have an index that combines the WHERE clause elements returning only one value with the ORDER BY clause elements.
    For example, if you have a query like:
    SELECT * FROM T
    WHERE A = ? AND B = ? AND C IN (?, ?, ?)
    ORDER BY D, E
    you should have an index over columns A, B, D, and E for the best possible performance. A and B in the index can be used to limit the result set without any influence on the sort order D, E, but C cannot.
    Kind regards,
    Christian Bartels.

  • ABAP Programming Standards

    Hi ,
    Does SAP give any guidelines / document on Programming standards ? I understand that it is specific to individual implementations , but wondered if there could be any guideline by SAP .
    Regards ,
    Sujatha

    Lots of things can be included in standards.
    It somewhat depends on your system size, number of users, how much development etc. as to how detailed you want to get.
    Some of the common (programming) standards I have used at various sites:
    P_ for parameters
    s_ for select options
    gv_ for global variables
    lv_ for local variables
    pv_ for passed variables in forms
    gt_ for global itabs
    lt_ for local itabs
    gs_ for global structures
    ls_ for local structures
    co_ for constants
    V_ = For local & global Variables; Field Strings.
    W_ = For workflow container elements.
    I_ = For internal tables 
    Program names need to be something that you and your company are comfortable with. Many sites used to do something like
    Z - custome prefix
    FI - module
    R - report
    nnnn
    reward points if it is usefull ..
    Girish

  • Flow chart for Checking Abap Programming standards

    hey im developing a tool for checking some standards to be maintained in abap coding. for that how to develop a flow chart initialy.
    thanks in advance,
    suresh babu aluri.

    hi praveen,
    how can i go to Microsoft-Visio flowchart. give me full details or even the navigation part for accessing it.
    thanks in advance,
    suresh babu aluri.

  • Abap program standards [designing a tool]

    hi all,
    actually my requiremnet is we r developing a tool for checking all the coding standards of a report program for that first i need to design a flow chart for that standards, how to do it even for a few of them . [graphically presentation and if possible code for standard checking]
    thanks & regards
    suresh babu aluri.

    use the following statemets
    READ REPORT......
    SYNTAX-CHECK FOR itab MESSAGE mess LINE lin WORD wrd
                     [PROGRAM prog] [DIRECTORY ENTRY dir]
                     [error_handling]
                     [internal_options].
    check F1 help

  • Standard ABAP program for process chains

    Hi gurus,
      Is there any standard ABAP program to trigger process chains?
    I do not have authorization for RSPC_API_CHAIN_START. So is there any alternative function module or any standard ABAP program that I could use?
    Please help.

    Hi Apara,
      Did you try scheduling the chain via rspc1? If not then follow the steps as given below and see if it is successful
    1) Goto RSPC1.
    2) Enter your chain technical name.
    3) Go to display variant by right clicking the chain. Select the immediate option. save the settings.
    4) Come back to the process chain screen. Click on execute button. See if this succeeds.
    or in case if the chain has been already scheduled once:
    Just open the PC in RCPC1/RCPC
    right click on the start variant (i.e the first process in the PC)
    and select display scheduled jobs...
    this will show you the released jobs for this pC
    just selsct the check box in front of the released job and the select the menu option Job - > selct Repeat scheduling.
    selct immediate and remove the periodic tick mark and save which will run your process chain immediately.
    But i doubt if you will be able to schedule the process chain via a function module or a ABAP code without prior authorization. Maybe you can request some one from your team to run the chain for you until you get access.
    You will surely need to get access for running the chain without which it should not be possible to run the chain.
    Thanks
    Pawan

  • Abap program to find the list of SAP STANDARD reports in complete

    Please send me if you have any program since when i run TRDIRT Table in se16 it gives all the program now how to distinguish by business area like sd mm fi its tedious to open every program and check what it is . is there any ABap program that put together the list of all the reports for FI, AP, AR and MM
    Soniya Kapoor

    Hi,
      IN the table TRDIR give the application (TRDIR-APPL) and check the results..
    Cross-Application            
    A Asset Accounting             
    B Business Information Warehouse
    C PPC                          
    D DASS (control station)       
    E RIVA                         
    F Financial accounting         
    G General ledger               
    H Personnel Planning           
    I Plant maintenance            
    J Publishing                   
    K Cost accounting              
    L Inventory management         
    M Materials management         
    N Hospital                     
    P Human Resources              
    Q QSS (Quality assurance)      
    R Unknown application          
    S Basis                        
    U Enterprise Data Model        
    V Sales                        
    W MMS (Merchandise mgt. system)
    Y Customer head office         
    Z Customer branch              
    Thanks,
    Naren

  • How to upload Excel file in BI using function module in abap program

    How to upload Excel file in BI using function module in abap program?

    Hi Anuj,
    To upload the file , you can try a standard program "RSEPSFTP" .
    while you execute the program , a selection screen appears in which the inputs should be give as
    RFC destination - The target server name
    FTP command- PUT
    local file - your file name
    local directory - path of your local file
    remote file - your target file name
    remote directory - where it has to be stored
    Hope this is useful for you
    Thanks & regards
    Anju

  • How to create the condition record by ABAP program

    Hi Friends,
    I want to create/change the condition record of PR00 by ABAP program. It seems that there have no such BAPI/standard function can help on this. Can any one of you point out a way to me?? Thanks in addvance.
    Joe GR.

    Joe,
      Check with below FM..
    BAPI_PRICES_CONDITIONS.
    Check this link:
    Re: Sample code for  BAPI_PRICES_CONDITIONS
    examples....
    http://www.4ap.de/abap/bapi_prices_conditions.php
    Two useful threads on Same topic
    Re: Sample code for  BAPI_PRICES_CONDITIONS
    Re: Problem with BAPI_PRICES_CONDITIONS
    BAPI_PRICES_CONDITIONS
    Please check this sample code from other thread.
    wtable1-table_no = '306'.
    wtable1-applicatio = 'V'.
    wtable1-cond_type = 'ZPR0'.
    wtable1-operation = '009'.
    wtable1-varkey = '13001001USD 000000000050068946'.
    wtable1-valid_to = '99991231'.
    wtable1-valid_from = '20051101'.
    wtable1-cond_no = '$000000001'.
    APPEND wtable1 TO table1.
    wtable2-operation = '009'.
    wtable2-cond_no = '$000000001'.
    wtable2-created_by = sy-uname.
    wtable2-creat_date = '20051022'.
    wtable2-cond_usage = 'A'.
    wtable2-table_no = '110'.
    wtable2-applicatio = 'V'.
    wtable2-cond_type = 'ZPR0'.
    wtable2-varkey = '13001001USD 000000000050068946'.
    wtable2-valid_from = '20051101'.
    wtable2-valid_to = '99991231'.
    APPEND wtable2 TO table2.
    wtable3-operation = '009'.
    wtable3-cond_no = '$000000001'.
    wtable3-cond_count = '01'.
    wtable3-applicatio = 'V'.
    wtable3-cond_type = 'ZPR0'.
    wtable3-scaletype = 'A'.
    wtable3-scalebasin = 'C'.
    wtable3-scale_qty = '1'.
    wtable3-cond_p_unt = '1'.
    wtable3-cond_unit = 'EA'.
    wtable3-calctypcon = 'C'.
    wtable3-cond_value = '454'.
    wtable3-condcurr = 'USD'.
    APPEND wtable3 TO table3.
    CALL FUNCTION 'BAPI_PRICES_CONDITIONS'
    EXPORTING
    PI_initialmode = 'X'
    PI_BLOCKNUMBER =
    TABLES
    ti_bapicondct = table1
    ti_bapicondhd = table2
    ti_bapicondit = table3
    ti_bapicondqs = table4
    ti_bapicondvs = table5
    to_bapiret2 = table6
    to_bapiknumhs = table7
    to_mem_initial = table8
    EXCEPTIONS
    update_error = 1
    OTHERS = 2
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    READ TABLE table6 WITH KEY type = 'E' TRANSPORTING NO FIELDS.
    IF sy-subrc = 0.
    loop at table6 into ret.
    write: / ret-type, ret-message, ret-id, RET-LOG_NO, RET-LOG_MSG_NO,
    RET-MESSAGE_V1, RET-MESSAGE_V2, RET-MESSAGE_V3, RET-MESSAGE_V4,
    RET-PARAMETER,RET-ROW,RET-FIELD.
    endloop.
    ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    *EXPORTING
    WAIT =
    IMPORTING
    return = ret
    ENDIF.
    Don't forget to reward if useful....

  • How to extract data from BPC InfoCube via ABAP program?

    Hi experts!!
    I tried to extract data from a BPC InfoCube via ABAP program, but I did'n have succeed.
    I used the function 'RSDRI_INFOPROV_READ' to extract data from standard InfoCubes such as '0COPC_C07' and it run OK! However, when I change the InfoCube name to '/CPMB/WAIX8NE' (BPC InfoCube), everything goes wrong...
    Is there any difference between extracting data from BPC and standard InfoCubes?
    Thank you all!

    Moderator message - Welcome to SCN.
    But please do not cross and duplicate post.
    Thread locked.
    Rob

  • Error in executing ABAP program. Error occurred when creating dataset

    hi,
    when I use LKM SAP ERP to Oracle (SQLLDR) to extract data from SAP ERP server. I execute my interface, and it's stop at extract data step.
    This is message:
    java.lang.RuntimeException: Error occured in open tool execute method...Error in executing ABAP program...Error in executing ABAP program...Error occurred when creating dataset/abc/ZODI_13001_6001_GLOBAL.txt
    I tried others path name, tried slash or backslash. This is content in code tab
    OdiSAPAbapExecute "-UPLOAD=1" "-EXECUTE=1" "-EXECUTEBASE_RKM=0" "-ZRFC_RUN_INSTALL=1" "-ABAP_PROGRAM_NAME=ZODI_13001_6001" "-HOST=10.86.87.24" "-USER=sv_hoa" "-PASSWORD=<@=snpRef.getInfo("SRC_PASS") @>" "-SAP_CLIENT=800" "-SAP_LANGUAGE=EN" "-SAP_SYSTEM_NUMBER=02" "-SAP_FUNCTION_GROUP_NAME=ZODI_FGR_13001" "-CONNECTION_POOL_NAME=SAP_ODI_ERP_POOL_10.86.87.24" "-CONNECTION_POOL_SIZE=10" "-FILE_DELIMITER=<@=""+(char)8@>" "-FILE_NAME=ZODI_13001_6001_GLOBAL.txt" "-FTP_HOST=10.86.82.108" "-FTP_USER=anh" "-FTP_PASSWORD=<@=sFtpPassword@>" "-FTP_PASSIVE_MODE=1" "-FTP_TRANSFER_TIMEOUT=100000" "-ODI_VARIABLE_NAMES=" "-ODI_VARIABLE_VALUES=" "-USER_ABAP_PARAMETER_NAMES=IV_DELIMITER,CHAR3;IV_FILENAME,CHAR255;IV_USER,CHAR35;IV_PWD,CHAR35;IV_HOST,CHAR35;IV_HASHVALUE,CHAR35;IV_PATH,CHAR35;IV_MAX_ROW_CNT,SYTABIX;IV_FETCH_BATCH_SIZE,SYTABIX;" "-USER_ABAP_PARAMETER_VALUES=<Value>" "-USER_ABAP_PARAMETER_SEPARATOR=<Value>" "-ABAP_TABLE_PARAMETERS=RETURN,BAPIRETURN;ET_FILE_RETURN,BAPIRET2" "-ABAP_EXPORT_PARAMETERS=ERRORMESSAGE;SY-MSGV1" "-LOG_FILE_NAME=C:\Users\anh\AppData\Local\Temp\SapAbapExecuteOpenTool_13001.log" "-FTP_PATH=/abc/" "-DEV_CLASS=ZODI_DEVCLASS" "-MAX_ROW_COUNT=" "-FETCH_BATCH_SIZE=100000" "-HASH_VALUE_MARKER=HVM" "-ABAP_PROGRAM_BODY=
    *Final Type declarations
    TYPES : BEGIN OF ty_final,
    Y03HOCSINH_HOCSINH_ID TYPE
    Y03HOCSINH-HOCSINH_ID,
    Y03HOCSINH_MA_HOC_SINH TYPE
    Y03HOCSINH-MA_HOC_SINH,
    Y03HOCSINH_TEN_HOC_SINH TYPE
    Y03HOCSINH-TEN_HOC_SINH,
    Y03HOCSINH_GIOI_TINH TYPE
    Y03HOCSINH-GIOI_TINH,
    Y03HOCSINH_DIA_CHI TYPE
    Y03HOCSINH-DIA_CHI,
    Y03HOCSINH_GHI_CHU TYPE
    Y03HOCSINH-GHI_CHU,
    END OF ty_final.
    *Final Temp Type Declarations
    TYPES : BEGIN OF ty_final_tmp,
    Y03HOCSINH_HOCSINH_ID TYPE
    Y03HOCSINH-HOCSINH_ID ,
    Y03HOCSINH_MA_HOC_SINH TYPE
    Y03HOCSINH-MA_HOC_SINH ,
    Y03HOCSINH_TEN_HOC_SINH TYPE
    Y03HOCSINH-TEN_HOC_SINH ,
    Y03HOCSINH_GIOI_TINH TYPE
    Y03HOCSINH-GIOI_TINH ,
    Y03HOCSINH_DIA_CHI TYPE
    Y03HOCSINH-DIA_CHI ,
    Y03HOCSINH_GHI_CHU TYPE
    Y03HOCSINH-GHI_CHU ,
    END OF ty_final_tmp.
    *Final Target Type Declarations
    TYPES : BEGIN OF ty_final_target,
    C0_Y03HOCSINH_HOCSINH_ID TYPE
    Y03HOCSINH-HOCSINH_ID,
    C1_Y03HOCSINH_MA_HOC_SINH TYPE
    Y03HOCSINH-MA_HOC_SINH,
    C2_Y03HOCSINH_TEN_HOC_SINH TYPE
    Y03HOCSINH-TEN_HOC_SINH,
    C3_Y03HOCSINH_GIOI_TINH TYPE
    Y03HOCSINH-GIOI_TINH,
    C4_Y03HOCSINH_DIA_CHI TYPE
    Y03HOCSINH-DIA_CHI,
    C5_Y03HOCSINH_GHI_CHU TYPE
    Y03HOCSINH-GHI_CHU,
    END OF ty_final_target.
    * Table type for Y03HOCSINH
    TYPES : BEGIN OF ty_Y03HOCSINH,
    HOCSINH_ID TYPE
    Y03HOCSINH-HOCSINH_ID,
    MA_HOC_SINH TYPE
    Y03HOCSINH-MA_HOC_SINH,
    TEN_HOC_SINH TYPE
    Y03HOCSINH-TEN_HOC_SINH,
    GIOI_TINH TYPE
    Y03HOCSINH-GIOI_TINH,
    DIA_CHI TYPE
    Y03HOCSINH-DIA_CHI,
    GHI_CHU TYPE
    Y03HOCSINH-GHI_CHU,
    END OF ty_Y03HOCSINH.
    TYPES: BEGIN OF gs_text,
    line(843) TYPE c,
    END OF gs_text.
    *Structure Declarations
    DATA: wa_final_string TYPE string,
    wa_final TYPE ty_final,
    wa_final_target TYPE ty_final_target,
    wa_Y03HOCSINH TYPE ty_Y03HOCSINH,
    *Table Declarations
    tt_final TYPE STANDARD TABLE OF ty_final,
    tt_Y03HOCSINH TYPE STANDARD TABLE OF ty_Y03HOCSINH,
    tt_final_target TYPE STANDARD TABLE
    OF ty_final_target,
    tt_final_tmp TYPE STANDARD TABLE OF ty_final_tmp,
    tt_final_tmp1 TYPE STANDARD TABLE OF ty_final,
    gt_result TYPE STANDARD TABLE OF gs_text,
    *Variable Declarations
    lv_path TYPE string,
    lv_flag TYPE char1,
    C0_Y03HOCSINH_HOCSINH_ID TYPE
    STRING,
    C1_Y03HOCSINH_MA_HOC_SINH TYPE
    STRING,
    C2_Y03HOCSINH_TEN_HOC_SINH TYPE
    STRING,
    C3_Y03HOCSINH_GIOI_TINH TYPE
    STRING,
    C4_Y03HOCSINH_DIA_CHI TYPE
    STRING,
    C5_Y03HOCSINH_GHI_CHU TYPE
    STRING,
    wa_final_tmp TYPE ty_final_tmp,
    lv_file TYPE string,
    lv_datum TYPE sy-datum,
    lv_date TYPE char10,
    wa_result TYPE string,
    lv_delimiter type string,
    lv_cnt TYPE sytabix,
    *-Cursor Declaration
    lv_Y03HOCSINH_dbcur TYPE cursor,
    lv_tabix_frm TYPE sy-tabix.
    lv_delimiter = iv_delimiter.
    IF iv_hashvalue = 'HVM'.
    *Open/delete output file
    CONCATENATE iv_path iv_filename INTO lv_path.
    *Check for file existence, if found, delete it
    OPEN DATASET lv_path FOR INPUT
    IN TEXT MODE
    ENCODING DEFAULT.
    IF sy-subrc EQ 0.
    DELETE DATASET lv_path.
    ENDIF.
    *Open/create output file
    OPEN DATASET lv_path FOR APPENDING
    IN TEXT MODE
    ENCODING DEFAULT.
    IF sy-subrc EQ 0.
    *Batch Processing
    OPEN CURSOR WITH HOLD lv_Y03HOCSINH_dbcur FOR
    SELECT HOCSINH_ID
    MA_HOC_SINH
    TEN_HOC_SINH
    GIOI_TINH
    DIA_CHI
    GHI_CHU
    FROM Y03HOCSINH.
    DO.
    *Check for the counter, only for first batch
    *process new line is required...
    lv_cnt = lv_cnt + 1.
    REFRESH tt_Y03HOCSINH.
    FETCH NEXT CURSOR lv_Y03HOCSINH_dbcur
    APPENDING TABLE tt_Y03HOCSINH
    PACKAGE SIZE IV_FETCH_BATCH_SIZE.
    IF NOT tt_Y03HOCSINH IS INITIAL.
    ELSE.
    EXIT.
    ENDIF.
    LOOP AT tt_Y03HOCSINH INTO wa_Y03HOCSINH.
    MOVE wa_Y03HOCSINH-HOCSINH_ID
    TO wa_final_tmp-Y03HOCSINH_HOCSINH_ID.
    MOVE wa_Y03HOCSINH-MA_HOC_SINH
    TO wa_final_tmp-Y03HOCSINH_MA_HOC_SINH.
    MOVE wa_Y03HOCSINH-TEN_HOC_SINH
    TO wa_final_tmp-Y03HOCSINH_TEN_HOC_SINH.
    MOVE wa_Y03HOCSINH-GIOI_TINH
    TO wa_final_tmp-Y03HOCSINH_GIOI_TINH.
    MOVE wa_Y03HOCSINH-DIA_CHI
    TO wa_final_tmp-Y03HOCSINH_DIA_CHI.
    MOVE wa_Y03HOCSINH-GHI_CHU
    TO wa_final_tmp-Y03HOCSINH_GHI_CHU.
    APPEND wa_final_tmp TO tt_final_tmp.
    ENDLOOP.
    free : tt_Y03HOCSINH.
    LOOP AT tt_final_tmp INTO wa_final_tmp.
    MOVE wa_final_tmp-Y03HOCSINH_HOCSINH_ID
    TO wa_final_target-C0_Y03HOCSINH_HOCSINH_ID.
    MOVE wa_final_tmp-Y03HOCSINH_MA_HOC_SINH
    TO wa_final_target-C1_Y03HOCSINH_MA_HOC_SINH.
    MOVE wa_final_tmp-Y03HOCSINH_TEN_HOC_SINH
    TO wa_final_target-C2_Y03HOCSINH_TEN_HOC_SINH.
    MOVE wa_final_tmp-Y03HOCSINH_GIOI_TINH
    TO wa_final_target-C3_Y03HOCSINH_GIOI_TINH.
    MOVE wa_final_tmp-Y03HOCSINH_DIA_CHI
    TO wa_final_target-C4_Y03HOCSINH_DIA_CHI.
    MOVE wa_final_tmp-Y03HOCSINH_GHI_CHU
    TO wa_final_target-C5_Y03HOCSINH_GHI_CHU.
    Append wa_final_target to tt_final_target.
    ENDLOOP.
    free : tt_final_tmp.
    Clear wa_final_target.
    IF NOT iv_max_row_cnt IS INITIAL.
    Loop at tt_final_target into
    wa_final_target TO iv_max_row_cnt.
    MOVE wa_final_target-C0_Y03HOCSINH_HOCSINH_ID
    TO C0_Y03HOCSINH_HOCSINH_ID.
    MOVE wa_final_target-C1_Y03HOCSINH_MA_HOC_SINH
    TO C1_Y03HOCSINH_MA_HOC_SINH.
    MOVE wa_final_target-C2_Y03HOCSINH_TEN_HOC_SINH
    TO C2_Y03HOCSINH_TEN_HOC_SINH.
    MOVE wa_final_target-C3_Y03HOCSINH_GIOI_TINH
    TO C3_Y03HOCSINH_GIOI_TINH.
    MOVE wa_final_target-C4_Y03HOCSINH_DIA_CHI
    TO C4_Y03HOCSINH_DIA_CHI.
    MOVE wa_final_target-C5_Y03HOCSINH_GHI_CHU
    TO C5_Y03HOCSINH_GHI_CHU.
    CONCATENATE
    C0_Y03HOCSINH_HOCSINH_ID
    C1_Y03HOCSINH_MA_HOC_SINH
    C2_Y03HOCSINH_TEN_HOC_SINH
    C3_Y03HOCSINH_GIOI_TINH
    C4_Y03HOCSINH_DIA_CHI
    C5_Y03HOCSINH_GHI_CHU
    INTO wa_final_string
    SEPARATED BY lv_delimiter.
    IF sy-tabix EQ 1 AND lv_cnt EQ 1.
    CONCATENATE wa_final_string
    lv_delimiter INTO wa_final_string.
    ELSE.
    CONCATENATE '<@=""+(char)8@>' lv_delimiter wa_final_string
    lv_delimiter INTO wa_final_string.
    ENDIF.
    APPEND wa_final_string TO gt_result.
    CLEAR : C0_Y03HOCSINH_HOCSINH_ID,
    C1_Y03HOCSINH_MA_HOC_SINH,
    C2_Y03HOCSINH_TEN_HOC_SINH,
    C3_Y03HOCSINH_GIOI_TINH,
    C4_Y03HOCSINH_DIA_CHI,
    C5_Y03HOCSINH_GHI_CHU.
    ENDLOOP.
    ELSE.
    Loop at tt_final_target into wa_final_target.
    MOVE wa_final_target-C0_Y03HOCSINH_HOCSINH_ID
    TO C0_Y03HOCSINH_HOCSINH_ID.
    MOVE wa_final_target-C1_Y03HOCSINH_MA_HOC_SINH
    TO C1_Y03HOCSINH_MA_HOC_SINH.
    MOVE wa_final_target-C2_Y03HOCSINH_TEN_HOC_SINH
    TO C2_Y03HOCSINH_TEN_HOC_SINH.
    MOVE wa_final_target-C3_Y03HOCSINH_GIOI_TINH
    TO C3_Y03HOCSINH_GIOI_TINH.
    MOVE wa_final_target-C4_Y03HOCSINH_DIA_CHI
    TO C4_Y03HOCSINH_DIA_CHI.
    MOVE wa_final_target-C5_Y03HOCSINH_GHI_CHU
    TO C5_Y03HOCSINH_GHI_CHU.
    CONCATENATE
    C0_Y03HOCSINH_HOCSINH_ID
    C1_Y03HOCSINH_MA_HOC_SINH
    C2_Y03HOCSINH_TEN_HOC_SINH
    C3_Y03HOCSINH_GIOI_TINH
    C4_Y03HOCSINH_DIA_CHI
    C5_Y03HOCSINH_GHI_CHU
    INTO wa_final_string
    SEPARATED BY lv_delimiter.
    IF sy-tabix EQ 1 AND lv_cnt EQ 1.
    CONCATENATE wa_final_string
    lv_delimiter INTO wa_final_string.
    ELSE.
    CONCATENATE '<@=""+(char)8@>' lv_delimiter wa_final_string
    lv_delimiter INTO wa_final_string.
    ENDIF.
    APPEND wa_final_string TO gt_result.
    CLEAR : C0_Y03HOCSINH_HOCSINH_ID,
    C1_Y03HOCSINH_MA_HOC_SINH,
    C2_Y03HOCSINH_TEN_HOC_SINH,
    C3_Y03HOCSINH_GIOI_TINH,
    C4_Y03HOCSINH_DIA_CHI,
    C5_Y03HOCSINH_GHI_CHU.
    ENDLOOP.
    ENDIF.
    free : tt_final_target.
    IF NOT gt_result IS INITIAL.
    CLEAR wa_result.
    LOOP AT gt_result INTO wa_result.
    TRANSFER wa_result TO lv_path.
    ENDLOOP.
    ENDIF.
    REFRESH gt_result.
    *End of main loop for batching
    ENDDO.
    *Close dataset
    CLOSE DATASET lv_path.
    CLOSE CURSOR lv_Y03HOCSINH_dbcur.
    ELSE.
    DATA: lv_mesg TYPE string.
    CLEAR et_file_return.
    et_file_return-type = 'E'.
    CONCATENATE
    'Error occurred when creating dataset' lv_path
    INTO lv_mesg.
    et_file_return-message = lv_mesg.
    Append et_file_return.
    ENDIF.
    ELSE.
    CLEAR et_file_return.
    et_file_return-type = 'E'.
    et_file_return-message =
    'Installed ABAP program does not match interface definition'.
    APPEND et_file_return.
    ENDIF.
    Thanks for help

    r u able to figure it out..........i got the same error .......can someone help me fix this issue

  • Abap program to maintain variants in RSRPARAMETRIZA

    Hi,
    SAP provided an ABAP example to maintain 3.5 variants in NW04s
    Report Z_MASS_VARIANT_MAINTENANCE is available in the next u2018how tou2019 document.
    [http://www.sapadvisors.com/resources/HowtoInformationBroadcasting.pdf]
    This is only helpfull if you use 3.5 workbooks.
    7.0 workbook variants are not save in RSRVARIANT anymore. 7.0 variants are saved in table-field RSRPARAMETRIZA-STRING (xml field with selection values).
    I need to develop a program to maintain this variants. Can anybody save me some time and send me similar abap program for 7.0 workbooks ?
    Thanks,
    Pedro

    Hi,
    Bruno is right about class CL_RSR_PARA.
    This is an abap example is used to maintain 'ZRT_M4M_Q0016' Query variants. In this case variant BC_SALST001 is updated.
    If you need to update different report variant you have to change the 'form create_variant'.
    In this variant I'm updating:
    - 0S_MAT: empty
    - 0S_MATGR: 5300-5399
    - ZMM_STA2: Z0;ZZ
    *& Program to mass update BEx Variants within SAP Netwever 2004s
    REPORT Z_MASS_FR_BROADCAST_0003 .
    constants: C_PARAMNM type RSPARAMNM value 'BC_SALST001'.
    ---> TYPE DEFININTIONS --->
    NOTE: Ripped from class CL_RSR_PARA
    TYPES: BEGIN OF t_sx_int_var_value,
             vnam   TYPE rszvnam,
             data_prov TYPE string,
             range   TYPE STANDARD TABLE OF rrrange  WITH DEFAULT KEY
                                                     INITIAL SIZE 1,
       END OF  t_sx_int_var_value.
    TYPES: t_tx_int_var_value TYPE STANDARD TABLE OF t_sx_int_var_value
                                   WITH DEFAULT KEY
                                   INITIAL SIZE 1.
    <- TYPE DEFININTIONS <-
    DATA: l_s_rsrparametriza type rsrparametriza.
    DATA: l_s_range type rrrange.
    DATA: l_s_sx_int_var_value type t_sx_int_var_value.
    DATA: r_tsx_values type t_tx_int_var_value.
    perform create_variant.
    l_s_rsrparametriza-paramnm = c_paramnm.
    l_s_rsrparametriza-objvers = 'A'.
    l_s_rsrparametriza-parentcomponent = '1'.
    l_s_rsrparametriza-workbookid = ''.
    l_s_rsrparametriza-eltuid = 'ZRT_M4M_Q0016'.
    l_s_rsrparametriza-plnfuncnm = ''.
    l_s_rsrparametriza-template = ''.
    l_s_rsrparametriza-planningseqeunce = ''.
    l_s_rsrparametriza-version = ''.
    l_s_rsrparametriza-personal = ''.
    l_s_rsrparametriza-owner = sy-uname.
    CALL TRANSFORMATION
      id
      SOURCE page = r_tsx_values
      RESULT XML l_s_rsrparametriza-content.
    get time stamp field l_s_rsrparametriza-timestmp.
    l_s_rsrparametriza-conttimestmp = ''. " fix
    *For security reasons I just change existing variants field.
    update rsrparametriza
       set content = l_s_rsrparametriza-content
    where PARAMNM eq c_paramnm
       and OBJVERS eq 'A'.
    If sy-subrc eq '0'.
      Write: 'Update sucessfull'.
    else.
      Write: 'No update: Probably variant does not exist'.
    endif.
    form create_variant.
    *0S_MAT
      clear l_s_sx_int_var_value.
      l_s_sx_int_var_value-vnam = '0S_MAT'.
      l_s_sx_int_var_value-data_prov = 'DP_4'.
      " no selections
      append l_s_sx_int_var_value to r_tsx_values.
    *0S_MATGR
      clear l_s_sx_int_var_value.
      l_s_sx_int_var_value-vnam = '0S_MATGR'.
      l_s_sx_int_var_value-data_prov = 'DP_4'.
      clear l_s_range.
      l_s_range-sign = 'E'.
      l_s_range-opt = 'BT'.
      l_s_range-low = '5300'.
      l_s_range-high = '5399'.
      append l_s_range to l_s_sx_int_var_value-range.
      append l_s_sx_int_var_value to r_tsx_values.
    *ZMM_STA2
      clear l_s_sx_int_var_value.
      l_s_sx_int_var_value-vnam = 'ZMM_STA2'.
      l_s_sx_int_var_value-data_prov = 'DP_4'.
      clear l_s_range.
      l_s_range-sign = 'I'.
      l_s_range-opt = 'EQ'.
      l_s_range-low = 'ZO'.
      l_s_range-high = ''.
      append l_s_range to l_s_sx_int_var_value-range.
      l_s_range-low = 'ZZ'.
      append l_s_range to l_s_sx_int_var_value-range.
      append l_s_sx_int_var_value to r_tsx_values.
    That's all
    Pedro

  • ABAP Program to Create TRs in SOLMAN

    Currently, we are creating TRs through SOLMAN_WORKCENTER transaction. It is being done manually by going to 'Change management' Tab in 'SOLMAN_WORKCENTER'->'PROJECTS'(QGATE Project not CHARM)-> TR is being created for a specific project using 'Create Transport Request' button.
    I was wondering, whether this process can be automated, so that developers can directly create a TR, through a web application or email. The frontend application will be creating TR in backend in SOLMAN after some validations.
    I'm trying to write an ABAP program to create TRs in backend in SOLMAN, following the same process, which is being followed now using SOLMAN_WORKCENTER. This program will be called by the frontend application. This way developers can create a TR, without having direct access to SOLMAN.
    I tried to use CL_CTS* classes, but it's not working. Kindly suggest some BAPIs or classes available for it.
    If anybody has already worked in development of a similar solution, kindly share the technical knowhow. Also, please let me know any solutions from SAP available for it.
    Thanks in advance for your help....

    Thanks a lot for responding Guilherme.....
    But, we wanted to add our own validations as per our standards like naming convention of TRs, project to be used etc...
    Otherwise, the TRs created by developers in an incorrect approach, will be very hard to manage.
    That's why I was looking for an ABAP code to create a TR in SOLMAN_WORKCENTER, so that we can add our own validations to it before creating the TR. If the validations fail, it should't create the TR.
    Using the webdynpro link for SOLMAN_WORKCENTER as suggested, some of the functionalities can be controlled by authorizations maybe. But, we'll not able able to add any extra validations required.

  • ABAP Performance standards good piece

    ABAP Performance Standards
    Following are the performance standards need to be following in writing ABAP programs:
    <b>1. Unused/Dead code</b>
    Avoid leaving unused code in the program. Either comment out or delete the unused situation. Use program --> check --> extended program to check for the variables, which are not used statically.
    <b>2. Subroutine Usage</b>
    For good modularization, the decision of whether or not to execute a subroutine should be made before the subroutine is called. For example:
    This is better:
    IF f1 NE 0.
    PERFORM sub1.
    ENDIF.
    FORM sub1.
    ENDFORM.
    Than this:
    PERFORM sub1.
    FORM sub1.
    IF f1 NE 0.
    ENDIF.
    ENDFORM.
    <b>3. Usage of IF statements</b>
    When coding IF tests, nest the testing conditions so that the outer conditions are those which are most likely to fail. For logical expressions with AND , place the mostly likely false first and for the OR, place the mostly likely true first.
    Example - nested IF's:
    IF (least likely to be true).
    IF (less likely to be true).
    IF (most likely to be true).
    ENDIF.
    ENDIF.
    ENDIF.
    Example - IF...ELSEIF...ENDIF :
    IF (most likely to be true).
    ELSEIF (less likely to be true).
    ELSEIF (least likely to be true).
    ENDIF.
    Example - AND:
    IF (least likely to be true) AND
    (most likely to be true).
    ENDIF.
    Example - OR:
    IF (most likely to be true) OR
    (least likely to be true).
    <b>4. CASE vs. nested Ifs</b>
    When testing fields "equal to" something, one can use either the nested IF or the CASE statement. The CASE is better for two reasons. It is easier to read and after about five nested IFs the performance of the CASE is more efficient.
    <b>5. MOVE statements</b>
    When records a and b have the exact same structure, it is more efficient to MOVE a TO b than to MOVE-CORRESPONDING a TO b.
    MOVE BSEG TO *BSEG.
    is better than
    MOVE-CORRESPONDING BSEG TO *BSEG.
    <b>6. SELECT and SELECT SINGLE</b>
    When using the SELECT statement, study the key and always provide as much of the left-most part of the key as possible. If the entire key can be qualified, code a SELECT SINGLE not just a SELECT. If you are only interested in the first row or there is only one row to be returned, using SELECT SINGLE can increase performance by up to three times.
    <b>7. Small internal tables vs. complete internal tables</b>
    In general it is better to minimize the number of fields declared in an internal table. While it may be convenient to declare an internal table using the LIKE command, in most cases, programs will not use all fields in the SAP standard table.
    For example:
    Instead of this:
    data: t_mara like mara occurs 0 with header line.
    Use this:
    data: begin of t_mara occurs 0,
    matnr like mara-matnr,
    end of t_mara.
    <b>8. Row-level processing and SELECT SINGLE</b>
    Similar to the processing of a SELECT-ENDSELECT loop, when calling multiple SELECT-SINGLE commands on a non-buffered table (check Data Dictionary -> Technical Info), you should do the following to improve performance:
    o Use the SELECT into <itab> to buffer the necessary rows in an internal table, then
    o sort the rows by the key fields, then
    o use a READ TABLE WITH KEY ... BINARY SEARCH in place of the SELECT SINGLE command. Note that this only make sense when the table you are buffering is not too large (this decision must be made on a case by case basis).
    <b>9. READing single records of internal tables</b>
    When reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ. This means that if the data is not sorted according to the key, the system must sequentially read the table. Therefore, you should:
    o SORT the table
    o use READ TABLE WITH KEY BINARY SEARCH for better performance.
    <b>10. SORTing internal tables</b>
    When SORTing internal tables, specify the fields to SORTed.
    SORT ITAB BY FLD1 FLD2.
    is more efficient than
    SORT ITAB.
    <b>11. Number of entries in an internal table</b>
    To find out how many entries are in an internal table use DESCRIBE.
    DESCRIBE TABLE ITAB LINES CNTLNS.
    is more efficient than
    LOOP AT ITAB.
    CNTLNS = CNTLNS + 1.
    ENDLOOP.
    <b>12. Performance diagnosis</b>
    To diagnose performance problems, it is recommended to use the SAP transaction SE30, ABAP/4 Runtime Analysis. The utility allows statistical analysis of transactions and programs.
    <b>13. Nested SELECTs versus table views</b>
    Since releASE 4.0, OPEN SQL allows both inner and outer table joins. A nested SELECT loop may be used to accomplish the same concept. However, the performance of nested SELECT loops is very poor in comparison to a join. Hence, to improve performance by a factor of 25x and reduce network load, you should either create a view in the data dictionary then use this view to select data, or code the select using a join.
    <b>14. If nested SELECTs must be used</b>
    As mentioned previously, performance can be dramatically improved by using views instead of nested SELECTs, however, if this is not possible, then the following example of using an internal table in a nested SELECT can also improve performance by a factor of 5x:
    Use this:
    form select_good.
    data: t_vbak like vbak occurs 0 with header line.
    data: t_vbap like vbap occurs 0 with header line.
    select * from vbak into table t_vbak up to 200 rows.
    select * from vbap
    for all entries in t_vbak
    where vbeln = t_vbak-vbeln.
    endselect.
    endform.
    Instead of this:
    form select_bad.
    select * from vbak up to 200 rows.
    select * from vbap where vbeln = vbak-vbeln.
    endselect.
    endselect.
    endform.
    Although using "SELECT...FOR ALL ENTRIES IN..." is generally very fast, you should be aware of the three pitfalls of using it:
    Firstly, SAP automatically removes any duplicates from the rest of the retrieved records. Therefore, if you wish to ensure that no qualifying records are discarded, the field list of the inner SELECT must be designed to ensure the retrieved records will contain no duplicates (normally, this would mean including in the list of retrieved fields all of those fields that comprise that table's primary key).
    Secondly, if you were able to code "SELECT ... FROM <database table> FOR ALL ENTRIES IN TABLE <itab>" and the internal table <itab> is empty, then all rows from <database table> will be retrieved.
    Thirdly, if the internal table supplying the selection criteria (i.e. internal table <itab> in the example "...FOR ALL ENTRIES IN TABLE <itab> ") contains a large number of entries, performance degradation may occur.
    <b>15. SELECT * versus SELECTing individual fields</b>
    In general, use a SELECT statement specifying a list of fields instead of a SELECT * to reduce network traffic and improve performance. For tables with only a few fields the improvements may be minor, but many SAP tables contain more than 50 fields when the program needs only a few. In the latter case, the performace gains can be substantial. For example:
    Use:
    select vbeln auart vbtyp from table vbak
    into (vbak-vbeln, vbak-auart, vbak-vbtyp)
    where ...
    Instead of using:
    select * from vbak where ...
    <b>16. Avoid unnecessary statements</b>
    There are a few cases where one command is better than two. For example:
    Use:
    append <tab_wa> to <tab>.
    Instead of:
    <tab> = <tab_wa>.
    append <tab> (modify <tab>).
    And also, use:
    if not <tab>[] is initial.
    Instead of:
    describe table <tab> lines <line_counter>.
    if <line_counter> > 0.
    <b>17. Copying or appending internal tables</b>
    Use this:
    <tab2>[] = <tab1>[]. (if <tab2> is empty)
    Instead of this:
    loop at <tab1>.
    append <tab1> to <tab2>.
    endloop.
    However, if <tab2> is not empty and should not be overwritten, then use:
    append lines of <tab1> [from index1] [to index2] to <tab2>.
    Hope this will help you all in writing the ABAP program.<b></b>

    ABAP Performance Standards
    Following are the performance standards need to be following in writing ABAP programs:
    <b>1. Unused/Dead code</b>
    Avoid leaving unused code in the program. Either comment out or delete the unused situation. Use program --> check --> extended program to check for the variables, which are not used statically.
    <b>2. Subroutine Usage</b>
    For good modularization, the decision of whether or not to execute a subroutine should be made before the subroutine is called. For example:
    This is better:
    IF f1 NE 0.
    PERFORM sub1.
    ENDIF.
    FORM sub1.
    ENDFORM.
    Than this:
    PERFORM sub1.
    FORM sub1.
    IF f1 NE 0.
    ENDIF.
    ENDFORM.
    <b>3. Usage of IF statements</b>
    When coding IF tests, nest the testing conditions so that the outer conditions are those which are most likely to fail. For logical expressions with AND , place the mostly likely false first and for the OR, place the mostly likely true first.
    Example - nested IF's:
    IF (least likely to be true).
    IF (less likely to be true).
    IF (most likely to be true).
    ENDIF.
    ENDIF.
    ENDIF.
    Example - IF...ELSEIF...ENDIF :
    IF (most likely to be true).
    ELSEIF (less likely to be true).
    ELSEIF (least likely to be true).
    ENDIF.
    Example - AND:
    IF (least likely to be true) AND
    (most likely to be true).
    ENDIF.
    Example - OR:
    IF (most likely to be true) OR
    (least likely to be true).
    <b>4. CASE vs. nested Ifs</b>
    When testing fields "equal to" something, one can use either the nested IF or the CASE statement. The CASE is better for two reasons. It is easier to read and after about five nested IFs the performance of the CASE is more efficient.
    <b>5. MOVE statements</b>
    When records a and b have the exact same structure, it is more efficient to MOVE a TO b than to MOVE-CORRESPONDING a TO b.
    MOVE BSEG TO *BSEG.
    is better than
    MOVE-CORRESPONDING BSEG TO *BSEG.
    <b>6. SELECT and SELECT SINGLE</b>
    When using the SELECT statement, study the key and always provide as much of the left-most part of the key as possible. If the entire key can be qualified, code a SELECT SINGLE not just a SELECT. If you are only interested in the first row or there is only one row to be returned, using SELECT SINGLE can increase performance by up to three times.
    <b>7. Small internal tables vs. complete internal tables</b>
    In general it is better to minimize the number of fields declared in an internal table. While it may be convenient to declare an internal table using the LIKE command, in most cases, programs will not use all fields in the SAP standard table.
    For example:
    Instead of this:
    data: t_mara like mara occurs 0 with header line.
    Use this:
    data: begin of t_mara occurs 0,
    matnr like mara-matnr,
    end of t_mara.
    <b>8. Row-level processing and SELECT SINGLE</b>
    Similar to the processing of a SELECT-ENDSELECT loop, when calling multiple SELECT-SINGLE commands on a non-buffered table (check Data Dictionary -> Technical Info), you should do the following to improve performance:
    o Use the SELECT into <itab> to buffer the necessary rows in an internal table, then
    o sort the rows by the key fields, then
    o use a READ TABLE WITH KEY ... BINARY SEARCH in place of the SELECT SINGLE command. Note that this only make sense when the table you are buffering is not too large (this decision must be made on a case by case basis).
    <b>9. READing single records of internal tables</b>
    When reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ. This means that if the data is not sorted according to the key, the system must sequentially read the table. Therefore, you should:
    o SORT the table
    o use READ TABLE WITH KEY BINARY SEARCH for better performance.
    <b>10. SORTing internal tables</b>
    When SORTing internal tables, specify the fields to SORTed.
    SORT ITAB BY FLD1 FLD2.
    is more efficient than
    SORT ITAB.
    <b>11. Number of entries in an internal table</b>
    To find out how many entries are in an internal table use DESCRIBE.
    DESCRIBE TABLE ITAB LINES CNTLNS.
    is more efficient than
    LOOP AT ITAB.
    CNTLNS = CNTLNS + 1.
    ENDLOOP.
    <b>12. Performance diagnosis</b>
    To diagnose performance problems, it is recommended to use the SAP transaction SE30, ABAP/4 Runtime Analysis. The utility allows statistical analysis of transactions and programs.
    <b>13. Nested SELECTs versus table views</b>
    Since releASE 4.0, OPEN SQL allows both inner and outer table joins. A nested SELECT loop may be used to accomplish the same concept. However, the performance of nested SELECT loops is very poor in comparison to a join. Hence, to improve performance by a factor of 25x and reduce network load, you should either create a view in the data dictionary then use this view to select data, or code the select using a join.
    <b>14. If nested SELECTs must be used</b>
    As mentioned previously, performance can be dramatically improved by using views instead of nested SELECTs, however, if this is not possible, then the following example of using an internal table in a nested SELECT can also improve performance by a factor of 5x:
    Use this:
    form select_good.
    data: t_vbak like vbak occurs 0 with header line.
    data: t_vbap like vbap occurs 0 with header line.
    select * from vbak into table t_vbak up to 200 rows.
    select * from vbap
    for all entries in t_vbak
    where vbeln = t_vbak-vbeln.
    endselect.
    endform.
    Instead of this:
    form select_bad.
    select * from vbak up to 200 rows.
    select * from vbap where vbeln = vbak-vbeln.
    endselect.
    endselect.
    endform.
    Although using "SELECT...FOR ALL ENTRIES IN..." is generally very fast, you should be aware of the three pitfalls of using it:
    Firstly, SAP automatically removes any duplicates from the rest of the retrieved records. Therefore, if you wish to ensure that no qualifying records are discarded, the field list of the inner SELECT must be designed to ensure the retrieved records will contain no duplicates (normally, this would mean including in the list of retrieved fields all of those fields that comprise that table's primary key).
    Secondly, if you were able to code "SELECT ... FROM <database table> FOR ALL ENTRIES IN TABLE <itab>" and the internal table <itab> is empty, then all rows from <database table> will be retrieved.
    Thirdly, if the internal table supplying the selection criteria (i.e. internal table <itab> in the example "...FOR ALL ENTRIES IN TABLE <itab> ") contains a large number of entries, performance degradation may occur.
    <b>15. SELECT * versus SELECTing individual fields</b>
    In general, use a SELECT statement specifying a list of fields instead of a SELECT * to reduce network traffic and improve performance. For tables with only a few fields the improvements may be minor, but many SAP tables contain more than 50 fields when the program needs only a few. In the latter case, the performace gains can be substantial. For example:
    Use:
    select vbeln auart vbtyp from table vbak
    into (vbak-vbeln, vbak-auart, vbak-vbtyp)
    where ...
    Instead of using:
    select * from vbak where ...
    <b>16. Avoid unnecessary statements</b>
    There are a few cases where one command is better than two. For example:
    Use:
    append <tab_wa> to <tab>.
    Instead of:
    <tab> = <tab_wa>.
    append <tab> (modify <tab>).
    And also, use:
    if not <tab>[] is initial.
    Instead of:
    describe table <tab> lines <line_counter>.
    if <line_counter> > 0.
    <b>17. Copying or appending internal tables</b>
    Use this:
    <tab2>[] = <tab1>[]. (if <tab2> is empty)
    Instead of this:
    loop at <tab1>.
    append <tab1> to <tab2>.
    endloop.
    However, if <tab2> is not empty and should not be overwritten, then use:
    append lines of <tab1> [from index1] [to index2] to <tab2>.
    Hope this will help you all in writing the ABAP program.<b></b>

  • How to get data in ABAP program from multicube in external BW system

    Hi friends,
         I want to get data from one multicube which resides in an external BW system, in my ABAP program internal table. Is there any SAP standard RFC / BAPI for this or is there any other way around or I have to design my own program to get the data ?
        To make my requirement clearer, my ABAP program is in one BW box and the above mentioned multicube in another BW box. I want to get data from the multicube into my program.
        Any help is appreciated with points.

    Look at the following FM; you may find the FM RSDRI_INFOPROV_READ_RFC useful.
    Call the FM in your program and read data and update.
    RSAD_INFOCUBE_READ_REMOTE_DATA
    RSDRI_INFOPROV_READ_RFC
    Ravi Thothadri

Maybe you are looking for

  • How do I make Iphone proritise answering with bluetooth rather than ringing on phone?.

    Previously, when I received a phone call in my car, the bluetooth radio would ring and then I would take the call by pushing button on steering wheel. Ever since installing latest IOS the bluetooth device connects but the phone just vibrates (doesn't

  • Getting Page Count for a Multi-Page PDF file using Illustrator script?

    Does anyone know how to get the page count of a multi page PDF file?  I know you can then open each page using the PDFFileOptions (pagetoopen).  But I need to know up front how many pages there are to loop thru to open each page and process each page

  • Linking primary puchase accounts has not been completed

    Hi all, when I click on any Purchase - A/P document, I receive following message and the document screen is not opened. " Linking primary puchase accounts has not been completed " When I click on Purchase Order, I do not receive above message, and th

  • Transform old table(xmlsequence)  to modern XMLTABLE

    Hi, could You please help with translating SELECT  SSS_task_id,  extractValue(value(taskhist),'/task/taskId') taskId,               extractValue(value(taskhist),  '/task/id') id_,               extractValue(value(typeId),  '/typeId') typeId,         

  • Resizing Images for a Beginner

    When I teach students who are just learning to use a digital camera, one of their first questions is:  How can I make my images smaller to attach to an email? At this early stage, I want something easy.  On Windows OS, it is just a right/click away w