You are on page 1of 21

Chapter No 1 : FUNDAMENTALS This chapter explains the concepts of the SAP architecture and the main elements of the

SAP development environment.

Topics : 1. SAP R/3 ARCHITECHTURE 2. DATA DICTIONARY 3. DATA STRUCTURES 4. MODULARIZATION UNITS 5. MESSAGES

SAP R/3 ARCHITECHTURE

Topic 1 : SAP R/3 ARCHITECHTURE This chapter explains the concepts of SAP R/3 client/ server architecture, Role of each server, Types of work process and role of each work process.

SAP R/3 Client / Server Architecture

Server roles: Presentation server: This layer has SAP GUI which is used to connect SAP. This layer is accessed by the user to make requests to other two layers Application server: This layer has the kernel of the SAP System all the application logic resides in this layer. The request from the presentation layer comes to application layer and if needed redirect it to the database layer Database server: This serves as data store consisting of tables.

Types of Work Processes:

Role of work processes

Dialog Work process

Deals with the active user requests and executes dialog steps

Update Work Process

Executes database update requests.

Background Work process

Processes programs that can be executed without user interaction (background jobs).

Enqueue Work process

Administers a lock table in the shared memory area

Spool Work process

Passes sequential datasets to a printer

Message work process

Used for load balancing in a scenario where there are more than one application servers

Gateway work process

Used whenever there is used to establish a connection between SAP and NON-SAP systems

INTERVIEW QUESTIONS: 1. Explain client server architecture with example 2. What are the differences between 2-tier and 3-tier architecture and give example of both 3. What are the advantages of 3-tier over 2-tier architecture 4. What is the meaning of real-time with example 5. What are the other products from sap AG

DATA DICTIONARY

Chapter No 1 : Topic 2 : DATA DICTONARY This Topic explains the concepts of Domain, Data element, Tables , Technical settings, Foreign key relationship, Views and types of views, Search helps and types of search helps, Lock objects and Type groups

DATA FIELD FEATURES: DOMAIN Gives technical description (data type & length) of the field. The value range can be limited by specifying fixed values. Example: integer, 10 Gives the label or English name of the field. It contains primarily the field help (F1 documentation) and the field labels in the screen. Example: Customer name

DATA ELEMENT

NOTE: Data element and Domain are Meta data. One can share Data elements and Domains across fields. It is possible to create a field without data element but the domain is mandatory and is not recommended

TABLES:

It consists of columns (fields) and rows (entries). It has a unique name and attributes, such as delivery class and maintenance authorization. A field has a unique name and attributes. Every table must have a unique primary key which identifies a unique record of the table.

COMPOSITE PRIMARY KEY is Combination of two or more primary key fields. All the key fields are considered when the record is retrieved

You must specify a reference table for fields containing a currency (data type CURR) or quantity (data type QUAN). It must contain a field (reference field) with the format for currency keys (data type CUKY) or the format for units (data type UNIT). The field is only assigned to the reference field at program runtime.

TABLE MAINTENANCE GENERATOR (SE54) is a utility which is used to maintain mass data in the tables. Referential integrity is checked in Table maintenance generator but not in single entry

TECHNICAL SETTINGS OF TABLES:

1. You must maintain the technical settings when you define a transparent table in the ABAP Dictionary. 2. The technical settings are used to individually optimize the storage requirements and accessing behavior of database tables. 3. The technical settings can be used to define how the table should be handled when it is created on the database, whether the table should be buffered and whether changes to entries should be logged. 4. The table is automatically created on the database when it is activated in the ABAP Dictionary. 5. The storage area to be selected (tablespace) and space allocation settings is determined from the settings for the data class and size category. 6. The settings for buffering define whether and how the table should be buffered. You can define whether changes to the table entries should be logged.

FOREIN KEY RELATIONSHIP:

1. One can create foreign key if the two fields of different tables have the same DOMAIN but field names or data elements can be different. Referential integrity in SAP is covered under the foreign

key relationship 2. CHECK TABLE is the table that has check field containing values that is checked by foreign key of FOREIGN KEY TABLE. 3. Check table can also be created on non-primary key field. a. ADVANTAGES OF CHECK TABLE: (1)Ensures the data integrity (2)Provides F4 or INPUT HELP E.g. ZDEP-depid ZEMP-empid CHECK TABLE FOREIGN KEY TABLE

VIEWS: Data for an application object is often distributed on several database tables. Database systems therefore provide you with a way of defining application-specific views on data in several tables. These are called views. Types of views These can be created on more than one table and preferably these tables should DATABASE VIEWS be linked using check table. 1 One can retrieve data from database views using select statement PROJECTION VIEWS: Exactly same as database view except that it can be created on only one table These can be created on one or more tables but one cannot retrieve data using select statement

MAINTENANCE VIEWS

HELP VIEWS

These can be created to be used in the search helps

SEARCH HELP

It is a mechanism used to search data within SAP A) Selection method: This can be a database table or help view B) Dialog behavior: This determines the way in which data should be exported back to the screen C) Parameter Interface: Import parameters form the input search help where as export parameters form the output of the search help It is a container of multiple elementary search helps. After the creation of search help, it should be assigned to the corresponding table field

1 ELEMENTARY SEARCH HELPS: These has three components

2 COLLECTIVE SEACH HELPS:

LOCK OBJECTS:

The R/3 system synchronizes simultaneous access of several users to the same data records with lock mechanism Apart from database lock mechanism, SAP provides with the help of lock objects. These should not be created using Z or Y. once it is created the system generates automatically two function modules ENQUEUE-<Table Name> DEQUEUE-<Table Name>

TYPE GROUPS:

These are globally defined data types which can be accessed from any ABAP program. While referring type groups from a program, one must use the key word TYPE-POOLS

TYPES

TABLE TYPES: DATA ELEMENTS: STRUCTURES:

There are three different type categories in the ABAP Dictionary and are available to all the programs Describes the structure of an internal table. Describe an elementary type by defining the data type, length and possibly decimal places. Consist of components that can have any type.

LAB EXERCISES: 1. 2. 3. 4. Create a employee table and a department table Create a append structure and include structure Create database, projection, maintenance, and help views Create a search help that allows us to search emp numbers both based on empid and depid (collective search help)

INTERVIEW QUESTIONS: 1. 2. 3. 4. 5. What is buffering of tables and its types. What do you understand by table index? Difference between primary and secondary index Different types of search helps and how they are used Purpose of the following T-codes a. SE11 b. SE12 c. SE13 d. SE14 e. SE16 f. SM30 What are two level domain concepts? What is conversion routine and where it is assigned What are fixed values? Define the following a. Data element b. Domain c. Check table d. Reference table e. Value table

6. 7. 8. 9.

10. 11. 12. 13. 14. 15. 16. 17. 18.

Different types of tables and views Difference between structure and table Difference between include structure append structure What is customer includes What is lock object and purpose of it? what is the purpose of table maintenance generator Define type groups Different types of tables What are text tables

DATA STRUCTURES
Chapter No 1 : Topic 3 : DATA Structures This Topic explains the concepts of work area, Internal tables, internal table operations types of internal tables and Performance tuning

DATABASE (SE11)

ABAP EDITOR (SE38)


DATA DECLARATIONS . DATA SELECTIONS .. DATA OUTPUT

Selection Screen

1 2 5a 5b
List screen

TABLES STRUCTURES VIEWS

3 4

EMAIL

(1) Control goes to selection screen from ABAP Editor to get the user request (2) User sends the request from selection screen to ABAP Editor (3) ABAP Editor sends the request to the Database (4) Database sends the request of data to ABAP Editor. (5a) Control goes to again selection screen if the user given data do not exist in Database. (5b) If the user given data exist in Database, it outputs the data in the list screen Or EMAIL. WORK AREA: It can hold only single record and works as interface between internal table and list output. It can also work as interface between database and internal table but it is a performance issue.

10

INTERNAL TABLE: Internal tables can hold multiple records and are defined by using the syntax TYPE TABLE OF Internal tables can be defined either with an implicit work area or an explicit work area. There are two ways of filling internal tables either through work area or directly into the body. However, one has to make use of either an implicit or an explicit work area to output the data. Default memory of ITAB is 8 KB and can increase dynamically.

Internal Table Operations

OPERATIONS ON INTERNAL TABLE: 1 COLLECT This statement helps in performing mathematical operations on ITAB this statement works on ITAB both as modify statement if a record already exists with the same key and as append statement if a record exists with the different key. This statement reads the given line of records at an index level. If duplicate is found, it retrieves first entry. To read multiple records, we keep it in loop and endloop.

READ

11

SINGLE RECORD READING Read Table IT_EMP INTO WA_EMP INDEX 5. WRITE: / WA_EMP-EMPID, / WA_EMP-EMPNM, / WA_EMP-SALARY, / WA_EMP-ADDRESS. MULTIPLE RECORDS READING LOOP Read Table IT_EMP INTO WA_EMP INDEX 5. WRITE: / WA_EMP-EMPID, / WA_EMP-EMPNM, / WA_EMP-SALARY, / WA_EMP-ADDRESS. ENDLOOP. 3 MODIFY This statement modifies the contents of one or more records of the ITAB. One can modify it using an index or key of the table. WA_EMP-EMPID = 21 WA_EMP-EMPNM = corp WA_EMP-OPERA = APPEND IS MODIFIED INDEX 6. MODIFY IT_EMP from WA_EMP transporting OPERA. This statement adds the record at the end of all the records in table. WA_EMP-EMPID = 21 WA_EMP-EMPNM = corp WA_EMP-OPERA = APPEND . APPEND WA_EMP to IT_EMP.

APPEND

DELETE

SORT

This statement deletes the record wherever we specify with index. DELETE TABLE IT_EMP INDEX 5. This statement sorts the table in ascending or descending order according to the given field.

12

INSERT

This statement inserts the new record at the given index. DATA: OPERA (10) TYPE C. WA_EMP-EMPID = 25 WA_EMP-EMPNM = HNC WA_EMP-OPERA = INSERT .

INSERT WA_EMP into IT_EMP INDEX 2. DESCRIBE This statement describes the number lines of the ITAB at runtime. REFRESH This statement removes all the contends of data from internal table This statement removes all the data from workarea.

10 CLEAR

Access Types: Overview

TYPES OF TABLES : 1 STANDARD TABLE By default all ITABS are standard table. One can perform ITAB operations with the help of either table index or key of the table. one can perform ITAB operations with the help
13

2 SORTED TABLE

of either table index or key of the table As it is a sorted table, we need not to perform SORT operation. 3 HASHED TABLE Note: SY-TABIX: Every ITAB has a record index called as SY-TABIX. This index hence perform internal table operations To find out the access type of an internal table at runtime, use the statement DESCRIBE TABLE <itab> KIND <charfield>. This table has to be created only with an explicit key that has to be always unique.

INTERNAL TABLE KEY: Comprises character fields or character set (CHAR and NUMC) of columns of leftmost of an ITAB. To do the collect statement operations, the processor uses the key of the ITAB. If the key is not specified, it always takes the leftmost character set of columns. This adds all the non-character fields by comparing all the character fields of the table (performance problem). LAB EXERCISES: 1. Write programs to demonstrate the following Unstructured data type Workarea Single access (internal table) Multiple access (internal table) Implicit workarea 2. Write programs to demonstrate selection screen variants 3. Write a program using internal table operations 4. Write a program using database table operations 5. Write two programs one with inner join and another one with for all entries

14

INTERVIEW QUESTIONS: 1. 2. 3. 4. 5. What is Work Area? Difference between work area and internal table. Different types of internal tables. What are the various operations possible on internal table? Describe the following ABAP syntax: DO LOOP CLEAR REFRESH FREE STOP EXIT REJECT DESCRIBE CONCATENATE FIND REPLACE SHIFT OVERLAY TRANSLATE CONVERSION ROUTINE OFFSET WRITE SKIP
PERFORMANCE TUNING

1. While writing SELECT statement makes sure you SELECT only relevant fields. 2. Avoid using SELECT *. 3. Always user WHERE clause. 4. Avoid using SELECT, ENDSELECT. 5. Always pass full primary key to get the data. 6. Avoid nested loops. 7. Avoid using more than 3 nested if, alternately use CASE statement. 8. Never use OUTER JOIN. 9. Avoid using MOVE-CORRESPONDING. 10. Restrict the usage of GLOBAL Variables. 11. Do not define unnecessary variables.

15

MODULARIZATION UNITS
Chapter No 1 : Topic 4 : Modularization This Topic explains the concepts of modularization units like macros, subroutines, function modules and includes.

Modularization techniques are used to break the program into small modules which are more readable, understandable and reusable.
Techniques Call Called Number of parameters MAX = 9 LIMITED A=F Reusability

MACROS

MACRO <macro>

DEFINE <macro> ------------------ENE-OFDEFINITION FORM <sub> ----------------ENDFORM

SUBROUTINES

PERFORM<sub>

NO LIMIT BETTER A=F

FUNCTION MODULES

CALL FUNCTION <func>

FUNCTION NO LIMIT <func> ------------------------------------------- Need not be ENDFUNCTION A = F

BEST

CLASSES

CLASS<cls> DEFINITION --------------------------------ENDCLASS

CLASS <cls> IMPLEMENTAT ION --------------------------------------ENDCLASS

NO LIMIT BEST Need not be A=F

INCLUDES

INCLUDE <inc>

No INCLUDE <inc> parameters

BETTER

16

ACTUAL PARAMETERS (A) are global variables that store the actual values. Actual parameters are defined in the call program FORMAL PARAMETERS (F) are local variable that are defined in the interface of the modularization technique or called program

(1) MACROS:

In macros, the called should always be first and call follows it. Nested macros are possible. If we want to use macros in another program, we have to define call program again in that program. Macros are stored in TRMAC table

(2) SUB-ROUTINES: Methods of Passing Data

USING parameters are input parameters CHANGING parameters are output parameters

17

CALL BY REFERENCE: The actual and formal parameters point to the same memory address hence any change to the either of the parameters is reflected in the other parameters. By default all subroutines are call by reference

CALL BY VALUE: The actual and formal parameters have the different memory address hence any change to the either of the parameters is not reflected in the other parameters. One can make a parameter or parameters as call by value by adding value key word to the using set of parameters

CALL BY VALUE and RESULT: One can make a parameter or parameters as call by value and result by adding value key word to the changing set of parameters

(3) FUNCTION MODULES: (SE37)

FUNCTION MODULE PARAMETERS:

ATTRIBUTES parameters describes what type of function module it is IMPORT parameters are input parameters EXPORT parameters are output parameters CHANGING parameters can be input or output parameters of WA TABLES parameters can be input or output parameters of ITABS EXCEPTIONS: Information is passed to handle runtime errors and these are generally negative SOURCE CODE: In this we write code for the function module

18

THERE ARE 3 TYPES OF FUNCTION MODULES (1) NORMAL (2) REMOTE-ENABLED (3) UPDATE SY-SUBRC EQ 0: The function module is executed successfully SY-SUBRC EQ 1: The function module is not executed due to the exception number 1 Function pool = Collection of function modules STEP TO IMPLEMENT STANDARD FUNCTION MODULES:
(1) Identify the FM using search helps that will give one or more function modules. Study the documentation provided and select which is the closest to our Requirement (2) Understand the parameters of the interface of the FM (3) Test the function module that will again help us identifying whether this FM will suit our requirement or not (4) Finally call the function module into the program

(4) CLASSES:

These are based on object oriented programming concepts. Classes created locally using ABAP editor (SE38) are available to that program only and Classes created globally using class builder (SE24) will be available to all the programs

(5) INCLUDES:

It is used to hold another programs code that is subroutines, function modules

19

LAB EXERCISES: 1. Write a program to demonstrate macros 2. Write a program to demonstrate subroutines with the following methods i. Call by reference ii. Call by value iii. Call by value and result 3. Write a program to demonstrate a function module 4. Create two function modules, First function module with I_DEPID and T_EMP parameters and Second function module with I_EMPID and C_EMP parameters, Fetch data into first function module from the employee database table. Using first function module data, give EMP details from second first function module

INTERVIEW QUESTIONS: 1. 2. 3. 4. 5. 6. Differences among various Modularization Techniques. What is a Function Group What are exceptions in Function Module Types of Function Modules Name Few Function Modules. How do you call a subroutine from another program?

20

MESSAGES

Topic 5: MESSAGES

Messages are created in SE91 and stored in table T100. Messages can either be displayed in modal dialog boxes, or in the status bar of the screen. You can send messages using the ABAP statement MESSAGE. The statement specifies the message class, number, and type of the message.

MESSAGE TYPES E ERROR W WARNING A ABEND S SUCCESS I INFORMATION X SHORT DUMP MESSAGE Class MESSAGE Number (ZHNC) (FROM 000 TO 999)

Example: message s220(ZHNC) with text. & PLACE HOLDERS that means we can use the same message number with different messages dynamically at runtime. Example: message s220(ZHNC) with Enter Vendor Number

21

You might also like