14/11/2011

ABAP All Topics Interview Q and A


1. What is the typical structure of an ABAP program?
   Modular Structure
--------------------------------------------------------------------------------
2. What are field symbols and field groups.? Have you used "component idx of structure" clause with field groups?
Field-Symbol.
A field-symbol is a pointer you can dynamically assign to a field. After assignment, you use the field-symbol anywhere in your program in place of the actual field name. Use the field-symbol statements to define a field-symbol and use assign to assign a field to it. The field-symbol name must begin and end with angle brackets. A simple example.
Report ztest.
Data f1(3) value ‘ABC’.
Field-symbols <f>.
Assign f1 to <f>.   “<f> can now be used in place of f1.
Write :/ <f>.       “write the contents of f1
<f> = ‘XYZ’.        “assigns a new value to f1.
Write :/ f1.
Field group.
A field group combines several existing fields together under one name. You use the INSERT statement to determine which fields belong to a field group at runtime.

Example

FIELD-GROUPS: HEADER, ORDER, PRODUCT.

Note

Neither defining a field group (statically) using FIELD-GROUPS nor filling a field group (dynamically) with INSERT generates more memory. Rather, there exists for each field group element a pointer to an (existing) field.
You cannot define groups in methods.
--------------------------------------------------------------------------------
3. What should be the approach for writing a BDC program?
1.  Analyzing data from local file.
2.  Analyzing transaction
3.  Declaring internal table
-          First Internal table similar to structure like local file
-          Declaring internal table like BDCDATA
4.  Transferring data from local file to internal table
5.  Population of BDCDATA.
From Internal table the data is transferred to database table by two ways. I.e. Session method or Call transaction.
--------------------------------------------------------------------------------
4. What is a batch input session?
   In this method you transfer data from internal table to database table through sessions.

   In this method an ABAP/4 program reads the external data that is to be entered in the SAP system and stores the data in a session. A session stores the actions that are required to enter your data using normal SAP transactions. I.e. Data is transferred to session, which in turn transfer data to database table.
Session is intermediate step between internal table and database table. Data along with its action is stored in session i.e. Data for screen fields to which screen it is passed, the program name behind it, and how next screen is processed.

When the program has finished generating the session, you can run the session to execute the SAP transactions in it. You can either explicitly start and monitor a session or have the session run in the background processing system.

Unless session is processed, the data is not transferred to database table.
--------------------------------------------------------------------------------
5. What is the alternative to batch input session?
   Call Transaction Method
--------------------------------------------------------------------------------
6. A situation: An ABAP program creates a batch input session. We need to submit the program and the batch session in background. How to do it?
The transaction for background processing is SM36.
Defining background jobs.
It is two steps process
-          You first define the job and then you have to release it.
A Job in background processing is a series of steps that can be scheduled and step is a program for background processing. Step involves the following
. Job Name
. Job Class
. Jon Steps
--------------------------------------------------------------------------------
7. What is the difference between a pool table and a transparent table and how they are stored at the database level?
A transparent table in dictionary has one-to-one relationship with a table in the database. For each transparent table definition in the dictionary, there is one associated table in the database. The database table has the same names as the R/3 table definition.
A pooled table in the R/3 has a many-to-one relationship with a table in the database. For one table in the database has a different name than the tables in the DDIC, it has a different number of fields and the fields have different names as well. Pooled tables are a SAP proprietary construct.
--------------------------------------------------------------------------------
8. What are the problems in processing batch input sessions? How is batch input process different from processing online?
If batch-input session is terminated with errors, it appears in the list of INCORRECT session and it can be processed again. To correct session, first you can analyze the session. The analysis function allows to determine which screen and value produced error. If you find small errors in the data, you can correct them interactively, otherwise you need to modify batch input program, which are generated the session or many times even the data file.
While batch input is a two-step procedure, call transaction does both steps online one right after the other. In this method, you call a transaction from your program.
--------------------------------------------------------------------------------
9. What do you define in the domain and data element?
   Domain: Parameters to be passed
   1. Data Type: where you need to enter the data type available in SAP
   2. Field Length: Field Length in the number of valid position
   3. Value Table: name of a table to be entered, the fields referring to the  
      domain may only assume values contained in the value table.
   Data Element: Parameters to be passed when creating a data element.
   1. Short Text: Mandatory Fields
   2. Domain: A mandatory field.
   3. Text Element: You can enter description in short or long text for the
      field. This text is used when entering data for these fields.
--------------------------------------------------------------------------------
10. What are the different types of data dictionary objects?
1.  Tables
2.  Structures
3.  Views
4.  Data Element
5.  Domains
6.  Lock Objects
7.  Math code objects
--------------------------------------------------------------------------------
11. How many types of tables exists and what are they in data dictionary?
1.  Transparent Tables
2.  Pooled Tables
3.  Cluster Tables
Transparent tables do exists with the same structure both in data dictionary as well as in the database, exactly with same data and fields while other two are not transparent in the sense that they are not manageable directly using database system tools. You cannot use native SQL on these tables. Pool or cluster tables are logical tables, which are arranged as records of transparent tables.
--------------------------------------------------------------------------------
12. What is the step-by-step process to create a table in data dictionary?
    Steps to create a table
    1. Create Domain
    2. Create Data Element
    3. Create actual table
--------------------------------------------------------------------------------
13. Can a transparent table exist in data dictionary but not in the database physically?
    No
--------------------------------------------------------------------------------
14. What are the domains and data elements?
    Domain: They are formal definition of data types from a technical point of view. They set attributes such as data type, length possible value range and so.
    Data Element: They are definitions of the properties and type for a table field. It is an intermediate object between the object type domain and the table field. A field in R/3 system is always associated with a data element, which at the same time is related to domain.
--------------------------------------------------------------------------------
15. Can you create a table with fields not referring to data elements?
    Yes
--------------------------------------------------------------------------------
16. What is the advantage of structures? How do you use them in the ABAP programs?
You can use structures to define identical work area in multiple programs. You can include a structure within another structures and tables.
Like a table, it can be used within a program on the tables’ statement to define a work area.
--------------------------------------------------------------------------------
17. What does an extract statement do in the ABAP program?
Writes all fields of the field group fg (FIELD-GROUPS) as an entry in a sequential dataset. If you have defined a field group HEADER, its fields precede each entry as a sort key. Afterwards, you can use SORT and LOOP… ENLOOP to sort or process the dataset respectively. No further EXTRACT statements are possible after this.
General:
  1. As soon as you have extracted a dataset using EXTRACT, you can no longer extend the field group-using INSERT. In particular, you cannot change the HEADER field group at all after the first EXTRACT (regardless of the field group to which it applied).
  2. Large extract datasets are not stored in main memory. Instead, they are kept in an external auxiliary file. You can set the directory in which this file is created using the SAP profile parameter DIR_EXTRACT. The default directory is the SAP data directory (SAP profile parameter DIR_DATA).
--------------------------------------------------------------------------------
18. What is a collect statement? How is it different from append?
Collect searches in the internal table for an entry, all of whose alphanumeric fields are identical with those of the entry in the work area or header line. If such an entry is found, COLLECT adds all numeric fields from work area or header line to the corresponding fields in the table entry. Otherwise the collect statement appends the contents of the work area or header line to the end of the table.
The APPEND statement stores the contents of the header line at the end of the internal table.
--------------------------------------------------------------------------------
19. What is open sql vs native sql?
Open SQL allow you to access database tables declared in the ABAP dictionary regardless of the database platform that you R/3 system is using. Native SQL allows you to use database specific SQL statements in an ABAP program. This means that you can use database tables that are not administered by the ABAP dictionary and therefore integrate data that is not part of the R/3 system.
As a rule, an ABAP program containing database-specific SQL statements will not run under different database system. If your program will be used on more than one database platform, only use Open SQL statements.
--------------------------------------------------------------------------------
20. What does an EXEC SQL stmt do in ABAP? What is the disadvantage of using it?
Executes the Native SQL statements enclosed between EXEC SQL and ENDEXEC statements. Unlike Open SQL Native SQL statements can address tables that are not declared in the ABAP Dictionary.

Example

Creating the Table AVERI_CLNT:
EXEC SQL.
  CREATE TABLE AVERI_CLNT (
         CLIENT   CHAR(3)  NOT NULL,
         ARG1     CHAR(3)  NOT NULL,
         ARG2     CHAR(3)  NOT NULL,
         FUNCTION CHAR(10) NOT NULL,
         PRIMARY KEY (CLIENT, ARG1, ARG2)
                          )
ENDEXEC.
In a Native SQL statement, data is passed between the ABAP program and the database using host variables. A host variable is an ABAP variable that is identified as such in the Native SQL statement by a preceding colon (:).

Example

Displaying an extract from the table AVERI_CLNT:
DATA: F1(3), F2(3), F3(3).
F3 = ' 1 '.
EXEC SQL.
  SELECT CLIENT, ARG1 INTO :F1, :F2 FROM AVERI_CLNT
         WHERE ARG2 = :F3
ENDEXEC.
WRITE: / F1, F2.
To simplify the form of the INTO lists in the SELECT statement, you can, as in Open SQL, specify a single structure as the target area.
--------------------------------------------------------------------------------
21. What is the meaning of ABAP editor integrated with ABAP data dictionary?
Integration means if you double-click an object to select it, the Workbench automatically launches the tool that was used to create the object.
SAP has developed the Object Navigator to help you to organize your application development in this integrated environment. It provides a context that makes it easier for you to trace the relationships between objects in a program. Rather than working with tools and recalling development objects, you work with objects and allow the Workbench to launch the appropriate tool for an object.
--------------------------------------------------------------------------------
22. What are the events in ABAP language?
    An ABAP/4 using events that are invoked by the user actions. Processing blocks are defined by event-keywords and are executed on invocation of certain relevant events.
By default, the event start-of-selection is attached to all events in ABAP/4. In your programs you can define a processing block and attach this block to an event keyword.
--------------------------------------------------------------------------------
23. What is an interactive report? What is the obvious difference of such report compared with classical type reports?
A classical report connects of one program that creates a single list. This means that when the list is displayed, it has to contain all data requested, regardless of the number of details the user wants to see.
Interactive reporting allows the user to participate in retrieving and presenting data at each level during the session. Instead of presenting one extensive and detailed list with classified information. With interactive reporting you can create a condensed basic list from which the user can call detailed information by positioning the cursor and entering commands.
Detailed information is presented in secondary list. A secondary list may either overlay the basic list completely or appear in an additional dialog window on the same screen. The secondary list can itself be interactive again. The basic list is not deleted when secondary list is created.
User can interact with system by
-          double clicking or pressing f2
-          selecting menu option
Like classical report the interactive report is also event driven. Both the action mentioned above trigger events and code is written to handle these events. The events triggered by this action are as follows
-          At line-selection
-          At user-command
Interactive report consists of one basic list and 20 secondary list. Basic list is produced by START-OF_SLECTION event. When the user double clicks on the basic list or chooses the menu option, the secondary list is produced. All the vents associated with classical report except end-of-page are applicable only to basic list.
--------------------------------------------------------------------------------
24. What is a drill down report?
Interactive reports are called drill down report.
--------------------------------------------------------------------------------
25. How do you write a function module in SAP? Describe.
Function modules are procedures that are defined in function groups (special ABAP programs with type F) and can be called from any ABAP program. Function groups act as containers for function modules that logically belong together. You create function groups and function modules in the ABAP Workbench using the Function Builder.
Function modules allow you to encapsulate and reuse global functions in the R/3 System. They are stored in a central library. The R/3 System contains a wide range of predefined function modules that you can call from any ABAP program. Function modules also play an important role in database updates and in remote communication between R/3 Systems or between an R/3 System and a non-SAP system.
Unlike subroutines, you do not define function modules in the source code of your program. Instead, you use the Function Builder. The actual ABAP interface definition remains hidden from the programmer. You can define the input parameters of a function module as optional. You can also assign default values to them. Function modules also support exception handling. This allows you to catch certain errors while the function module is running. You can test function modules without having to include them in a program using the Function Builder.
The Function Builder also has a release process for function modules. This ensures that incompatible changes cannot be made to any function modules that have already been released. This applies particularly to the interface. Programs that use a released function module will not cease to work if the function module is changed.
Function modules perform tasks of general interest to other programmers. Usually these tasks are well-defined functions that all users need, regardless of application. Some well-defined tasks include performing tax calculations, determining factory calendar dates, and calling frequently used dialogs.
When you write ABAP routines that other programmers might use, you should define these routines as function modules. This means that you develop them in the Function Builder as follows:
  1. Check whether a suitable function module already exists. If not, proceed to step 2.
  2. Create a function group, if no appropriate group exists yet.
  3. Create the function module.
  4. Define the function module interface by entering its parameters and exceptions.
  5. Write the actual ABAP code for the function module, adding any relevant global data to the TOP include.
  6. Activate the module.
  7. Test the module.
  8. Document the module and its parameters for other users.
  9. Release the module for general use.
Runtime Considerations
There are some runtime considerations you should be familiar with when writing function modules:
  • The CALL FUNCTION statement can pass import, export, and changing parameters either by value or by reference. Table parameters are always transferred by reference.
  • If you declare the parameters with reference to ABAP Dictionary fields or structures, the system checks the type and length when the parameters are transferred. If the parameters from the calling program do not pass this check, the calling program terminates.
  • At runtime, all function modules belonging to a function group are loaded with the calling program. As a result, you should plan carefully which functions really belong in a group and which do not. Otherwise, calling your function modules will unnecessarily increase the amount of memory required by the user.
------------------------------------------------------------------------------------------------------------------------
26. What are the exceptions in function module?
Our function module needs an exception that it can trigger if there are no entries in table those meets the selection criterion. For example the exception NOT_FOUND serves this function.
--------------------------------------------------------------------------------
27. What is a function group?
Function groups are containers for function modules. You cannot execute a function group. When you call a function module, the system loads the whole of its function group into the internal session of the calling program (if it has not already been loaded).
The name of a function group can be up to 26 characters long. This is used by the system to create the components of the group (main program and corresponding include programs). When you create a function group or function module in the function builder, the main program and include programs are generated automatically.
--------------------------------------------------------------------------------
28. How are the date abd time field values stored in SAP?
1.  Date is stored in SY-DATUM.
2.  Time is stored in SY-UZEIT.
--------------------------------------------------------------------------------
29. What are the fields in a BDC_Tab Table?
    BDCTAB is like BDCDATA. The fields are…
1.  Program: Name of module pool program associated with the screen set this field only for the first record for the screen.
2.  Dynpro: Number of the screen. Length(4). Set this field only in the first record for the screen.
3.  Dynbegin: Indicates the first record for the screen. Length(1). Set this period to ‘X’ only for the first record for the screen. (Reset to ‘ ‘ blank for all other records).
4.  Fnam: Name of a field in the screen. Length(35). The Fnam field is not case-sensitive.
5.  Fval: Value for the field named in Fnam. Length(132). The fval field is case-sensitive. Values assigned to this field are always padded on the right if they are less than 132 characters. Values must be in character format.
--------------------------------------------------------------------------------
30. Name a few data dictionary objects?
1. Tables
 2. Structures
3.  Views
4.  Data Element
5.  Domains
6.  Lock Objects
7.  Math code objects
--------------------------------------------------------------------------------
31. What happens when a table is activated in DD?
When tables, types (data elements, structures, table types) and views are activated, they are placed at the disposal of the runtime environment in the form of runtime objects. These runtime objects contain the information about the object in a form that is optimal for access by ABAP programs and screens. The runtime objects are buffered so that ABAP programs and screens can access the information relevant to them quickly.
--------------------------------------------------------------------------------
32. What is a check table and what is a value table?
Check table specified in the foreign key for the field. A foreign key links two tables T1 and T2 by assigning fields of table T1 to the primary key fields of table T2.
The T1 is called foreign key table (dependent table) and table T2 the check table (referenced table).
In some cases you can see when you define a domain that all the table fields or structure components referring to this domain should be checked against a certain table. This information can be stored in the domain by entering a value table.
The system proposes the value table as check table when you try to define a foreign key for the field or component. This proposal can be overridden.
Example:
Domain S_CARR_ID (data type CHAR, length 3) in the flight Model describes the three-place code of the airlines. All the airlines are listed together with their codes in table SCARR. It is generally advisable to check fields referring to domain S_CARR_ID against table SCARR. SCARR is therefore entered as value table for domain S_CARR_ID. If you want to define a foreign key for a field referring to S_CARR_ID, SCARR is proposed as the check table.
A check is not implemented by simply entering a value table! The check against the value table only takes effect when a foreign key has been defined.
--------------------------------------------------------------------------------
33. What are match codes? Describe?
A matchcode is a means of finding data records stored in the system. The matchcode is defined in the ABAP Dictionary in two steps:
  • You first define the relevant tables and fields for the search in a matchcode object. A matchcode object describes the set of all possible search paths for a search string.
  • You then create one or more matchcode IDs for a matchcode object. A matchcode ID describes a special search path for a search string. The matchcode ID defines the fields or field combinations to be used in the search.
A material number must be entered in a screen field. Since the user cannot be expected to know this number, it must be possible to search for this number using the attributes of the corresponding material.
Several search paths are possible for this search. For example, you can search for the material number with the material name, the material class or the material manufacturer.
The corresponding match code object then comprises the fields for the material number, material name, material class and manufacturer. One match code ID corresponds to each search path. For example, ID A could describe the search for the material number by manufacturer. This ID only contains the fields for the material number and manufacturer.

The tables relevant for the search are included in a match code object. The table selection is based on one primary table. Further secondary tables can also be included, which are linked with the primary table by foreign keys. The fields of the match code object can then be selected from the base tables.
A match code object is not stored physically. It only describes a complete logical view on one or more tables.
--------------------------------------------------------------------------------
34. What transactions do you use for data analysis?
    ST05
--------------------------------------------------------------------------------
35. What is table maintenance generator?
    SE55
The Generate table maintenance dialog component creates standardized maintenance dialogs for tables and views. These dialogs can also be used to maintain table or view contents.
Integration
The component provides a standardized maintenance interface for many customizing activities. It is also useful as a customer table or view input tool.
Table or view maintenance dialogs are created in the ABAP/4 Workbench under the menu path Development ® Other tools ® Gen.tab.maint.dialog. To maintain table or view contents choose Services ® Ext. tab.maint. at any time.
Maintenance dialogs and data which were created, changed or deleted with the maintenance dialog can be transported into other R/3 Systems.
Functionality
The component creates maintenance dialogs which are standardized in their:
  • functionality
  • interface
  • maintenance screen     
  • navigation
  • enhancement options
  • maintenance
--------------------------------------------------------------------------------
36. What are ranges? What are number ranges?
You can use the RANGES statement to create internal tables of the same type as selection tables.
RANGES <rangetab> FOR <f>.
This statement is simply a shortened form of the following statements:
DATA: BEGIN OF <rangetab> OCCURS 0,
              SIGN(1),
              OPTION(2)
              LOW  LIKE <f>,
              HIGH LIKE <f>,
           END OF <rangetab>.
Internal tables created with RANGES have the same structure as selection tables, but they do not have the same functionality.
Selection tables created with RANGES are not components of the selection screen. As a result, no relevant input fields are generated. Also, you cannot use a RANGES table as a data interface in program <prog> called by the following statement:
SUBMIT <prog> WITH <rangetab> IN <table>.
However, you can use RANGES to create the table <table> in the calling program. The main function of RANGES tables is to pass data to the actual selection tables without displaying the selection screen when executable programs are called.
Although you can use RANGES tables like actual selection tables in the WHERE clause of Open SQL statements and in combination with the IN operator in logical expressions, they are not linked to a database table. This means that RANGES tables:
  • are not passed like selection criteria to logical databases.
  • cannot be used with the shortened form of selection tables in logical expressions.
  •  cannot be used like selection criteria in GET events
REPORT DEMO1.
RANGES S_CARRID FOR SPFLI-CARRID.
S_CARRID-SIGN = 'I'.
S_CARRID-OPTION = 'EQ'.
S_CARRID-LOW = 'LH'.
APPEND S_CARRID.
SUBMIT DEMO2 WITH CARRID IN S_CARRID.
In this example, RANGES table S_CARRID is created with reference to column CARRID of database table SPFLI. Fields S_CARRID-LOW and S_CARRID-HIGH have the same type as CARRID. The header line of internal table S_CARRID is filled and appended to the table. Program DEMO2 is called. If DEMO2 is linked to logical database F1S, its selections screen contains the fields of selection criterion CARRID from the logical database. These fields are filled with the contents of the RANGES table. 

Number Ranges

You can specify the number manually or it can be determined by the system from a pre-defined area (number range). 
 
Example:
The relevant area of the Accounting document numbers in each company code per document type.
--------------------------------------------------------------------------------
37. What are select options and what is the diff from parameters?
Select options you specify are displayed on the selection screen for the user to enter values.
Incase of select option user can enter a range of values. But in parameters user can enter only single value.
--------------------------------------------------------------------------------
38. How do you validate the selection criteria of a report? And how do you display initial values in a selection screen?
You can validate selection criteria of a report using at selection-screen event. You can display the initial values using default option of select-options.
--------------------------------------------------------------------------------
39. What are selection texts?
Description of specified selection text (SELECT-OPTION, PARAMETER). This description appears on the selection screen.
Texts on the selection screen are stored as language-specific selection-texts in the program text elements.
--------------------------------------------------------------------------------
40. What is CTS and what do you know about it?
A change request is a list in the system, where mainly contains the object to be transported. It also contains the transport type, the request category and the target system.
When the change request is created either manually or automatically the system assigns a number to it automatically and this number is known as change request number.
The change request records all modifications made to development object.
When the changes have been made and the change tasks have been released, the change request can be released.
SE09 will display and check all the change request.
--------------------------------------------------------------------------------
41. When a program is created and need to be transported to production does selection texts always go with it? if not how do you make sure? Can you change the CTS entries? How do you do it?
Whenever selection texts are changed or created it will ask for change request, if a development class is assigned to the program. Using the change request number you can transport the selection texts.
Yes. You can change the CTS entries using transaction se09.
--------------------------------------------------------------------------------
42. What is the client concept in SAP? What is the meaning of client Independent?
One of the most used client/server configurations with R/3 system is the tired architecture, which separates a system’s computer into 3 functional group.
Database server
Application Server
Presentation Server
Communication among the 3 tries is accomplished by standard protocol servers like TCP/IP or CPIC (Common Programming Interface Communication).
Client Independence, which means that it is independent of all clients across the SAP system.
--------------------------------------------------------------------------------
43. Are programs client dependent?
    Yes
--------------------------------------------------------------------------------
44. Name a few system global variables you can use in ABAP programs?
1.  SY-INDEX -  Loops, number of current pass
2.  SY-PAGNO -  List creation, current page
3.  SY-TABIX -  Loops, number of current pass
4.  SY-TFILL -  Internal tables, current number of lines
5.  SY-DBCNT -  DB operations, number of table lines processed
6.  SY-SUBRC -  Return value, return value after ABAP statements
7.  SY-LANGU -  R/3 System, current language
8.  SY-TCODE -  ABAP program, current transaction code
9.  SY-UCOMM -  Screens, function code triggered by PAI
10.SY-DATUM - Date and time, current (application server) date
--------------------------------------------------------------------------------
45. What are internal tables? How do you get the number of lines in an internal table? How to use a specific number occurs statement?
You can consider the following cases:
1.  You want to organize the contents of the table
2.  You want to modify few details of table and then display the contents of the table to user
3.  You want to perform table calculations on subset of database table.
In above cases you need to perform table calculations on subset of database contents. In ABAP/4 you work mainly with tables. Long life data is stored in database table. In such cases where you cannot work directly with database table. Hence need of intermediate table where you put in all the data from database table and work with this data thus avoiding accidental loss of data.
These intermediate tables are called Internal tables in ABAP/4 and are created only during runtime i.e., no memory is reserved for internal tables.
The occurs parameter see to it that an internal table is created not a field string.
After occurs, you have to specify a numerical literal.
Note: When you know that your internal table will be smaller than 8 KB you can specify the number of table lines in the occurs parameters.
The memory area for this size is then allocated accordingly. This is of particular importance for nested structures. If the memory area is not sufficient, more blocks of 8 KB or 16 KB are created.
Note: If you do not know the size of the internal table beforehand, you can set the occurs parameters to 0.
Depending on the line width, blocks of 8KB or 16 KB are created to accommodate the table lines. The new memory management stores the internal table in the extended memory, a memory area you can address directly.
--------------------------------------------------------------------------------
46. How do you take care of performance issues in your ABAP programs?
  • Always use SQL trace (ST05) to examine the SQL statements in your code to determine whether statements are scanning tables or using the index of a table.

  • Always use runtime analysis (SE30) to find out how well a program is running and where it is spending most of its time.  

  • Do not use select-exit-endselect logic.  Use select single or select up to 1 rows.  The trace shows this is more efficient. 

  • Avoid using select-endselect loop with logic in the middle.  This keeps unnecessary communication to DB2 open.  Instead, select the data you need into an internal table and loop at the internal table for your looping logic.

  • Order your WHERE clause exactly to the primary key or index, the optimizer might try to use a secondary index when in fact you wish to use the primary key.  Use SQL trace and do explains on any suspect statements.  This is prevalent when using joins. 

  • Avoid using select * and Select individual fields instead where practical. 

  • In order to use the addition ‘FOR ALL ENTRIES IN <TABLE>’,  make sure the table is not empty or it will select all rows. 

  • Avoid using the addition ‘INTO CORRESPONDING FIELDS OF TABLE <TABLE>’, we have seen that it is very CPU intensive.  Order the fields in the internal table and the select statement the same and use ‘INTO TABLE <TABLE>’.

  • The usage of commits in the proper locations is very important especially for DB2. See note 105737 for a description of how DB2 requires commits for read only transactions.   For reports that do not update the database, commit work at beginning and end of program and after every 1000 reads of the database. Do not place commit work statements within loops without a counter.

  • Mandatory selection criteria should be used as much as possible. The criteria should match the table keys and/or indexes. Also, make sure to fill in fields that you want them to fill in, in order  for the program to run efficiently.  Use the ‘OBLIGATORY’ addition to select-options and parameters to require fields.

  • Do not use logical databases whenever possible. They might be convenient but they do not run efficiently.

  • Do not write reports that give the user the ability to drill down. This might look nice and fancy but it does not allow them to run in the background and it takes up an enormous amount of memory.

  • Sort in ABAP and not at the database level. Use sort instead of order by. We have a lot more CPU utilization at the UNIX level where as we do not have a lot on the mainframe.   The only exception may be if the set is > 10 Meg.  The database may be able to sort using an index, which would be faster.

  • Table Buffering.  Whenever creating an application table, it should be buffered whenever technically possible.  Please see a Basis administrator when doing so for guidance

  • Avoid Exec SQL statements.  These are non-portable and always bypass the SAP buffers, which can be a performance drain.

  • Be careful with the ‘OR’  and ‘IN” operators in the where clause of an SQL statement.  Their use can exclude the use of existing secondary indexes. 
--------------------------------------------------------------------------------
47. What are datasets?
Files on application server are sequential Files. A sequential file is also called a dataset.
--------------------------------------------------------------------------------
48. How to find the return code of a stmt in ABAP programs?
    Using SY_SUBRC.
    If the operation is successful, sy-subrc = 0.
    If an operation is unsuccessful, sy-subrc <> 0.
--------------------------------------------------------------------------------
49. What are interface/conversion programs in SAP?
         In interface data is transferred from an external system into the SAP R/3 System.
         Conversion:
  • Determine which fields can be transferred directly from your existing data. There is a direct match between an existing data field and the corresponding SAP data field.
  • Check which fields must be converted to adapt the existing data to the requirements of the R/3 System.
--------------------------------------------------------------------------------
50. Have you used SAP supplied programs to load master data?
    RMDATIND – Transfer Material Master
--------------------------------------------------------------------------------
51. What are the techniques involved in using SAP supplied programs?
Do you prefer to write your own programs to load master data? Why?
--------------------------------------------------------------------------------
52. What are logical databases? What are the advantages/disadvantages of logical databases?
Logical databases are special ABAP programs that retrieve data and make it available to application programs. The most common use of logical databases is still to read data from database tables by linking them to executable ABAP programs.
However, from Release 4.5A, it has also been possible to call logical databases using the function module LDB_PROCESS. This allows you to call several logical databases from any ABAP program, nested in any way. It is also possible to call a logical database more than once in a program, if it has been programmed to allow this. This is particularly useful for programs with type 1.
Logical databases contain Open SQL statements that read data from the database. You do not therefore need to use SQL in your own programs. The logical database reads the program, stores them in the program if necessary, and then passes them line by line to the application program or the function module LDB_PROCESS using an interface work area.

Advantages of Using Logical Databases

Logical databases save you having to define a selection screen and read data from the database in every program. The program does not have to specify how to retrieve the data, but instead only has to process it and display it on the screen.
An executable program can only work with one logical database, but each logical database can be used by several programs. This offers considerable advantages over integrating the database accesses with SELECT statements into each executable program. It means that you only have to code identical access paths once. The same applies to coding authorization checks.
When you use logical databases, most executable programs benefit from having
  • An easy-to-use and standard user interface
  • Check functions, which check that user input is complete, correct, and plausible
  • Meaningful data selection
  • Central authorization checks for database accesses
  • Good read access performance (for example, with views) while retaining the hierarchical data view determined by the application logic.
  • Even though you are using central logical databases, the program itself remains flexible because:
  • You can still create your own selection screens for each program
  • You can code your own functions in any event block in the program. For example, you may want to write user dialogs for further authorization or plausibility checks on the selection screen.
Disadvantages of Using Logical Databases.
Takes lots of memory resources
--------------------------------------------------------------------------------
53. What specific statements do you using when writing a drill down report?
1.  At line-selection.
2.  At user-command.
--------------------------------------------------------------------------------
54. What are different tools to report data in SAP? What all have you used?

55. What are the advantages and disadvantages of ABAP query tool?

56. What are the functional areas? User groups? and how does ABAP query work in relation to these?
--------------------------------------------------------------------------------
57. Is a logical database a requirement/must to write an ABAP query?
    No
--------------------------------------------------------------------------------
58. What is the structure of a BDC sessions.
1.  Program: Name of module pool program associated with the screen set this field only for the first record for the screen.
2.  Dynpro: Number of the screen. Length(4). Set this field only in the first record for the screen.
3.  Dynbegin: Indicates the first record for the screen. Length(1). Set this period to ‘X’ only for the first record for the screen. (Reset to ‘ ‘ blank for all other records).
4.  Fnam: Name of a field in the screen. Length(35). The Fnam field is not case-sensitive.
5.  Fval: Value for the field named in Fnam. Length(132). The fval field is case-sensitive. Values assigned to this field are always padded on the right if they are less than 132 characters. Values must be in character format.
--------------------------------------------------------------------------------
59. What are Change header/detail tables? Have you used them?

60. What do you do when the system crashes in the middle of a BDC batch session?
--------------------------------------------------------------------------------
61. What do you do with errors in BDC batch sessions?
If batch-input session is terminated with errors, it appears in the list of INCORRECT session and it can be processed again. To correct session, first you can analyze the session. The analysis function allows to determine which screen and value produced error. If you find small errors in the data, you can correct them interactively, otherwise you need to modify batch input program, which are generated the session or many times even the data file.
--------------------------------------------------------------------------------
62. How do you set up background jobs in SAP? What are the steps? What are the events driven batch jobs?
The transaction for background processing is SM36
Or
System-àServices--àJobs

Components of the background Jobs
A job in background processing is series of steps that can be scheduled and step is a program for background processing.
·         Job Name: Defines the name assigned to the job. It identifies the job. You can specify up to 32 characters for the name.
·         Job Class: Indicates the type of background processing priority assigned to the job. The job class determines the priority of a job. The background system admits three types of job classes: A,B & C which corresponds to job priority.
·         Job steps: Parameter to be passed for this screen are as follows:
-          Program Name
-          Variant if it is report program
-          Start criteria for the job. Option available for this are as follows
1.  Immediate allow you to start a job immediately.
2.  Date/Time allows you to start a job at a specific time.
3.  After job you can start a job after a particular event.
4.  At operation mode allows you to start a job when the system switches to a particular operation mode.

Defining Background Jobs.
It is two step process: you first determine the job and then you have to release it.
When users define a job and save it, they are actually scheduling the job components, the steps, the start time.
When users schedule program for background processing, they are instructing the system to execute an ABAP/4 report or an external program in the background. Scheduled jobs are not executed until they are released. When jobs are released, they are sent for execution to the background processing system, at the specified start time. Both scheduling and releasing of jobs require authorizations.
--------------------------------------------------------------------------------
63. Is it possible to run host command from SAP environment? How do you run?

64. What kind of financial periods exist in SAP? What is the relevant table for that?
--------------------------------------------------------------------------------
65. Does SAP handle multiple currencies? Multiple languages?
Yes.
--------------------------------------------------------------------------------
66. What is a currency factoring technique?
--------------------------------------------------------------------------------
67. How do you document ABAP programs? Do you use program documentation menu option?
Using Documentation selection field, we can document ABAP programs.
Enter here a description of the program, explaining   
                                                       
 o   what it does and                                   
                                                       
 o   when it is used.                                  
                                                       
                                                       
 You can describe prerequisites, for example:          
                                                       
 o   Tables that must be maintained                    
                                                       
 o   Programs that must be run                          
                                                       
                                                       
 You can describe the possible report output:          
                                                                           
     o   Sort sequences                                                   
                                                                          
     o   Display formats                                                  
                                                                           
                                                                          
You can also specify examples that explain the report functions and possible settings.                                                    
--------------------------------------------------------------------------------
68. What is SAP script and layout set?
SAP script is the Sap systems own text-processing system. You’ll find that it looks and feels a lot like other leading text-processing systems that you may use on your personal computer.
SAP script is integrated text management system of the SAP r/3 system. The tcode (Transaction code) is SE71.
A layout set is defined as page design for a document. A layout set specifies the page design by defining one or more windows and arranging them on a page.
Layout set on its own does not contain any data.
The selection of data for the document is done through the print program.
The print program selects the data from database table and feeds it to the layout set.
When the print program is executed the document is printed.
--------------------------------------------------------------------------------
69. What are the ABAP commands that link to a layout set?
1.  CASE: It is similar to ABAP/4 editor command ‘CASE’: only one symbol can be queried.
2.  DEFINE: Value can be assigned to text symbol by DEFINE keyword.
3.  IF: Conditional output
4.  NEW-PAGE
5.  NEW-WINDOW
6.  Set Country
7.  Set date mask
8.  set time mask
9.  TOP…ENDTOP
10.ADDRESS
11.BOTTOM
--------------------------------------------------------------------------------
70. What is output determination?
--------------------------------------------------------------------------------
71. What are IDOCs?
The IDOC interface is used for electronic data communication between different computers and/or systems. Its function is to generate a standard SAP format that is purely message oriented. This format is referred to as an intermediate document or IDOC.
--------------------------------------------------------------------------------
72. What is screen painter? Menu painter? Gui status? . Etc.
Screen Painter:
The Screen Painter is a ABAP Workbench tool that allows you to create screens for your transactions. You use it both to create the screen itself, with fields and other graphical elements, and to write the flow logic behind the screen.

In older documentation, screens are sometimes referred to as dynpros. This is short for "Dynamic Program", and means the combination of the screen and its accompanying flow logic.
Menu Painter:
ABAP programs contain a wide variety of functions, which fall into different categories within the user interface. It is important for users to be able to differentiate between these categories, and to choose the right function easily. In the R/3 System, you arrange functions using the Menu Painter.
An instance of the user interface, consisting of a menu bar, a standard toolbar, an application toolbar, and a function key setting, is called a GUI status. The
GUI status and GUI title defines how the user interface will look and behave in an ABAP program.
--------------------------------------------------------------------------------
73. What is screen flow logic? What are the sections in it? Explain PAI and PBO.
    You can go to this screen either by
    Initial Screen of screen painter --à Flow Logic.
    Or
    From Screen attributes screen --à Flow logic.
When transaction is executed, the screen is displayed, user enters few fields, selects few functions. Then the screen is processed and processing of screen is done by floe logic. The events that are associated with screen are as follows
-          Process before output (PBO)
-          Process after input (PAI)
-          Process on value request (POV)
-          Process on help request (POH)
The system automatically displays two very important events or modules in flow logic i.e. PAI and PBO.
PBO event.
This event is triggered before the screen is displayed. The processing of screen before the screen is displayed. I.e. done in this event for example filling in default value in the screen fields.
PAI event: This event is responsible for processing of screen after the user enters the data and clicks the pushbutton. The processing of screen can include displaying another screen, or just displaying list or quitting the transaction itself and many things, usually it is displaying another screen. These operations can be carried out in the PAI event. OKCODE plays an important role in these operations.
-------------------------------------------------------------------------------
74. Overall how do you write transaction programs in SAP?
Steps involved to create a complete transaction is as follows
  • Create Module Pool program
  • From Screen painter create screens
  • Write flow logic for each screen
  • Write code for all the events in module pool program
  • Click for any error in screen and flow logic
  • Generate each and every component of screen. I.e. flow logic and screen
  • Single screen can be tested using screen painter
  • Create transaction code through object browser
  • Generate the transaction code
  • User can execute the transaction by entering the transaction code in the command field.
--------------------------------------------------------------------------------
75. Does SAP has a GUI screen painter or not? If yes what operating systems is it available on? What is the other type of screen painter called?
--------------------------------------------------------------------------------
76. What are step loops? How do you program page down page up in step loops?
A step loop is a repeated series of field-blocks in a screen. Each block can contain one or more fields, and can extend over more than one line on the screen.
Step loops as structures in a screen do not have individual names. The screen can contain more than one step loop, but if so, you must program the LOOP...ENDLOOPs in the flow logic accordingly. The ordering of the LOOP...ENDLOOPs must exactly parallel the order of the step loops in the screen. The ordering tells the system which loop processing to apply to which loop. Step loops in a screen are ordered primarily by screen row, and secondarily by screen column.
--------------------------------------------------------------------------------
77. Is ABAP a GUI language?
    Yes
--------------------------------------------------------------------------------
78. Normally how many and what files get created when a transaction program is written? What is the XXXXXTOP program?

--------------------------------------------------------------------------------
79. What are the include programs?
    Contain program code that cannot be run on its own.                         
    You call them from another program using INCLUDE statements. 
--------------------------------------------------------------------------------                   
80. Can you call a subroutine of one program from another program?
    YES. The other program should be added as INCLUDE.
--------------------------------------------------------------------------------
81. What are user exits? What is involved in writing them? What precautions are needed?

--------------------------------------------------------------------------------
82. What are RFCs? How do you write RFCs on SAP side?
    Remote Function Call: Remote Function Call allows users to call an R/3 function module or an external function "remotely". RFC development libraries exist for OS/2, Windows, Windows NT, and for all UNIX platforms supported by SAP. These help you to communicate with external programs (C and C++). The R/3 Function Builder also contains an RFC generator that you can use to generate external programs and download them onto your front end system.

In a remote function call, a series of tasks is performed automatically:
  • Data conversion
  • Logon to the SAP partner system
  • Conversion of all RFC data types
  • Control of the communication flow
Using the transaction SM59 you can display & maintain RFC Destination
--------------------------------------------------------------------------------
83. What are the general naming conventions of ABAP programs?
 The SAP standard says that the Customer developed object names have to start   with 'Z' or 'Y'. The World Kitchen rule will be:
·         Use 'Z' for those objects that are intended to go eventually to the production machine.
·         Use 'Y' for those play/test objects, not intended to go to the production machine.
 ABAP/4 programs.
·         The 2nd position is reserved for the letter corresponding with the application area.
·         The 3rd and 4th positions are reserved for subdividing the application area.
·         The 5th position is reserved for indicating the type of program.
Type  Type of Program
I     Include programs
R     Report programs
U     Update/Interface programs
C     Conversion
·         Position 6, 7, & 8 contains an identification number.  Normally this is a sequential number starting at 001.  In some cases it makes sense to group some programs by number.  For example 301, 302, 303.

--------------------------------------------------------------------------------
84. How do you find if a logical database exists for your program requirements?
Goto--àAttributes. The attribute screen will tell whether a logical database exists for the program.
--------------------------------------------------------------------------------
85. How do you find the tables to report from when the user just tells you the transaction he uses? And all the underlying data is from SAP structures?
    Using Function Keys F1 & F9.
    Incase if you get a structure field, double click on it, it shall take you    to the structure display, again by double clicking that field you will get a    display component window, if there is a check table you can take from it.
--------------------------------------------------------------------------------
86. How do you find the menu path for a given transaction in SAP?
--------------------------------------------------------------------------------
87. What are the different modules of SAP?
1.  SD – Sales & Distribution
2.  MM – Material Management
3.  PM – Plant Maintenance
4.  QM – Quality Management
5.  FI – Financial Accounting
6.  HR – Human Resource
7.  PP – Production Planning
8.  CO – Controlling
--------------------------------------------------------------------------------
88. What is IMG in SAP?
    IMG means Implementation Guide, used for customizing
--------------------------------------------------------------------------------
89. How do you get help in ABAP?
    You can obtain help by using any of the following
1.  Help option from R/3 window, which is compulsory menu item of every R/3  
   window.
     2. ? icon of standard tool bar
     3. F1 Function Key
4.  Another way in which r/3 system provides help or when system displays 
   error messages in the status bar. Double clicking on the status bar shows  
   additional information about the message.
--------------------------------------------------------------------------------
90. What are different ABAP editors? What are the differences?
1.  Front-End editor
2.  Back-End editor with line numbering & Compression Logic
3.  Back-End editor without line numbering & Compression Logic
4.  Back-End editor without line numbering & w/o Compression Logic
5.  Back-End editor with line numbering & w/o Compression Logic
--------------------------------------------------------------------------------
91. What are the different elements in layout sets?
1.  Header
2.  Pages
3.  Windows
4.  Page Windows
5.  Paragraph
6.  Text Elements & Character Strings
--------------------------------------------------------------------------------
92. Can you use if then else, perform ..etc statements in sap script?
    Yes
--------------------------------------------------------------------------------
93. What type of variables normally used in sap script to output data?
    Within ‘&’
--------------------------------------------------------------------------------
94. How do you number pages in Sapscript layout outputs?
    Using &SYST-PAGNO& or &PAGE&
    MenuàInsert-SymbolsàSystem symbols
--------------------------------------------------------------------------------
95. What takes most time in SAP script programming?
    Creating Layout Set.
--------------------------------------------------------------------------------
96. How do you use tab sets in layout sets?
    When defining the paragraph for the text element we can define the TABS    then. There is parameter called TABS to be defined in paragraph definition.
--------------------------------------------------------------------------------
97. How do you backup Sap script layout sets? Can you download and upload? How?
    By downloading you can take a backup. By executing RSTXSCRP you can download and upload SAP script layout sets.
--------------------------------------------------------------------------------
98. What are presentation and application servers in SAP?
    Application Server contains software components to run the program. It contains a SAP kernel, which can run ABAP/4 program.
    The presentation server is your client through which you send your request to application server. Its is also called as SAP graphical user interfaces known as SAPGUI and is available in windows 3.1, Windows NT, windows 95 and Macintosh. They all look similar whatever underlying system they are running on.
--------------------------------------------------------------------------------
99. In an ABAP program how do you access data that exists on a presentation server vs on an application server?
    Presentation Server: Using Upload or ws_upload function Module
    Application Server : Using Open & Read dataset statements
--------------------------------------------------------------------------------
100. What are different data types in ABAP?
     1. Elementary or structured
     2. Predefined or user-defined.
--------------------------------------------------------------------------------
101. What is difference between Batch input Method and Call Transaction?
     1. Tables get updated only when the session is processed.
        Tables get updated immediately incase of call transaction.
     2. No sy-subrc is returned incase of session method
        Sy-sybrc is returned incase of call transaction
     3. Errors log is created for error records.
        Errors need to be handled explicitly incase of call transaction.
  4. Updation in database table is always synchronous in case of session  
    method.
        Updation in database table can be synchronous or Asynchronous.
--------------------------------------------------------------------------------
102. Setting up a BDC program where you find information?
     BDC Data.
--------------------------------------------------------------------------------
103. What has to be done to the packed fields before submitting to a BDCsession.
     You should use write to statement to a character field.
--------------------------------------------------------------------------------