SAP ABAP Certification Notes - prepared by A.V.
Krishna,SAP Certified Consultant & Trainer
Day1 - IT -> ERP ->SAP ->ABAP
Day2 - Pre-requisites, SAP Project, SAP Architecture, Logon procedure, Logoff procedure,
Instance, Client, User concept.
SAP Screen Navigation
Note : SolMan = Solution Manager
is a tool, which is used for SAP Project implementation
ASAP Roadmap is a part of SolMan
is a SAP proprietary tool, which is recommended by SAP
it consist of admin activities ( transport management , tracking project status )
of testing activities
*******************************************************************************
- SAP Business One :
- is a solution for Small scale company , having 100 employees
- was developed with the integration of Microsoft
- is affordable by small companies, which provides drag and drop features
- deployed at customer site / otherwise Cloud solution also available
- it support sales, purchase, finance operations as integrated solutions
- SAP Business ByDesign :
- is cloud solution, available on demand
- suitable application for 100 to 500 employees
- is provided as SaaS( software as service ) to customer
- it fulfills company specific , country specific, regional specific legal and statutory requirements
- SAP All-in-one :
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- is a solution for SMEs , to provide country specific , industry specific requirements
- it provides best practices also
- consist of SAP ERP + SAP CRM + SAP SRM + BI + 25 industry solutions
- suitable for companies having 500 to 2500 employees
- powered by NetWeaver
- SAP Business Suite :
- Powered by NetWeaver
- also Powered by HANA
- solution for large size companies
- consist of Core Applications , Industry specific applications, Enhancement Packages , and Support
Packages
- (SOA is a foundation for NetWeaver,
Business suite built on NetWeaver)
*************************************************************************************
- Presentation Server :
- is connected to application server
- is used for data input / data output
- is used to access SAP system
- is also called as SAP GUI.exe (or) SAP Front End (or) SAP Logon
- SAP GUI is available as 3 types :
- SAP GUI support Windows
- SAP GUI support Java
- SAP GUI support HTML
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- Application Server : is data process area,
is connected to Presentation Server and Database Server
- Database Server : is part of database layer
is used to store large amount of data
database is managed by RDBMS
it stores SAP permanent data
Repository is a special area in the database
Repository is a large size system table available in the database
Repository table name is TADIR
Repository table consist of all Repository Objects information
Repository Object : in SAP Database Table
View
Program
Function Module
Screen
Menus
Global Classes
Forms
- Classification
Built-in Repository Object :
- are developed by SAP developer
- belongs to SAP namespace (SAP objects begins with A....X)
- open in display mode only
- names are in German language, but descriptions are in English
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- objects belongs to SAP defined packages
- status : Active
Custom Repository Object :
- are developed by User (or) Customer
- belongs to Customer namespace (User defined object names begins with Y or Z)
- open in change / display mode also
- names & descriptions both are in english only
- objects belongs to User defined packages
- status : New -> inactive -> active
- Application Server : is a part of Application Layer
is also called as Kernel
it provides BASIS and kernel services
Application Layer consist of Runtime Environment and Development Environment
- Runtime Environment :
- consist of multiple application servers
- message server is connected to all application servers
- message server is used to for internal communication purpose, it communicates from
one application server to another application server
Application Server :
- Every application server consist of one dispatcher
- Dispatcher accepts request from presentation servers and maintain all request under
dispatcher queue
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- Dispatcher is interface between presentation server and work process
- Dispatcher assigns task to work process
- Dispatcher works on FIFO based
- Work Process : accepts the request from Dispatcher
work process is assigned two memory areas
- user context area and roll area
All work processes are using common memory area called Shared
memory
User context consist of user master record (or) user profile
work process checks with user context , if the user authorized to perform current
operation , then Roll area allocates memory to work process (Roll-in) , after operation
memory gets rolled out
- Work Process components :
- Task handler : accepts the request from dispatcher and assigns task to respective areas
- Screen Processor : is also called as Screen Interpreter (or) Dynpro Processor
it executes dialog screen behind flow logic editor code
- ABAP Processor : is also called as ABAP Interpreter
it executes ABAP Editor code
- Database Interface : it performs 2 activities
it establish connection to underlying database and perform SQL
operations
it converts open SQL statements to Native SQL
- Dialog work process : executes dialog steps
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
it handles user actions on dialog screen
- Update work process : it updates screen information to database
- Enqueue work process : it handles lock mechanism
- Background work process : it handles background jobs
- Spool work process : it performs printing activity
- Difference between Open and Native SQL :
Open SQL :
- statements subset of standard SQL
- are mostly used in ABAP
- are database independent commands
- are converted into native SQL by database interface
- result is loaded into buffer
Native SQL :
- are powerful commands, written with respect to database
- are rarely used in ABAP
- are database dependent commands
- are not converted by database interface
- result is not loaded into buffer (by pass buffer)
- syntax : native SQL statements must be written between
EXEC <SQL>.
------------------.
------------------.
ENDEXEC.
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- Screen Processor (or) Dynpro Processor (or) Screen Interpreter :
it executes dialog screen behind flow logic editor code
- ABAP Processor (or) ABAP Interpreter :
executes ABAP Editor code
- Database Interface performs :
- it establish connection to database
- it convert Open SQL statements to Native SQL
- it executes SQL statements
- Buffers : Every application server behind local buffers are available.
buffer data is volatile
buffers stores the database table data temporary
- application layer consist of one gateway server,
all application servers concern dispatchers are connected to gateway server
gateway server mainly used for external communication purpose
- application layer consist of one enqueue server,
it maintains all logical locks temporary
- Application layer consist of Development Environment as ABAP Workbench.
ABAP workbench is a tool used by ABAP consultants
it is closely integrated with many development tools like ABAP Dictionary, ABAP Editor, Screen
Painter, Menu Painter, Class Builder, Function Builder...etc.,
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- 5 types of Work Process :
D - Dialog WP
V - Update WP
E - Enqueue WP
S - Spool WP
B - Background WP
- Login Procedure :
- Start Server
- Logon using Presentation Server ( provide valid client number, username, password )
- open 6 sessions
-Logoff Procedure :
- Save and Close all sessions
- Logout Presentation Server
- Stop Server
- In SAP R/3 (or) SAP ERP system , we can create Instances
- Instance provides some set of services
- can be classified as Central Instance ( installed at application layer,
provides development + runtime environment)
and Database Instance ( installed at database layer,
it stores only large amount of data )
- Instance is a collection of Clients
- Instance is also called as Application Server
- Instance can be represented as 3 letters ( alphanumeric ), unique name
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
Ex :
DEV
QAS
PRD
ZME
- Instance can also represented by unique 2 digit number
- valid number range is 00 to 99
- maximum 100 instances are possible for each SAP system
Client :
- Clients are created under Instance
- Client is a collection of Similar authorization users
- Client is represented by 3 digit number
- valid client number range 000 to 999
- maximum 1000 clients are possible for each instance
- built-in client numbers are 000, 001, 066
000 - standard client (or) reserved client
001 - copy of 000 client
066 - SAP Early Watch client (used by BASIS consultants)
these clients are reserved clients
800,801,810,811,812 - IDES clients - used for training purpose
100, 200, 300 - Non-IDES clients - used for real time development purpose
Client is a collection of data as a unit
Client is a top level organization unit in the functional configuration hierarchy
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- User : are created under client
every user is identified by unique profile
user profile also called as user master record
user profile consist of roles, authorization, profiles...etc.,
*- SAP Screen Navigation :
SAP Easy Access is the initial screen of SAP
- SAP Screen Header :
menu bar
standard tool bar
title bar
application tool bar
SAP Screen Body : main screen
status bar
System menu and Help menu are default menus for every screen
System menu -> Status : provides
- logon data - presentation server details
- SAP data ( Repository data + System data ) - application server details
- data base data + host data - database layer details
- Short cuts used while working with SAP Screens :
F1 - System help
F2 - detail display
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
F3 - back( previous screen )
F4 - search help
F5 - create mode
F6 - change mode
F7 - display mode
F8 - test / direct processing
F9 - technical information
F10 - select first menu item
F11 - save ( Ctrl + S )
F12 - cancel
Ctrl + F1 : switch between display and change mode
Ctrl + F2 : syntax check
Ctrl + F3 : activate
Ctrl + F8 : execute
Shift + F3 : exit (log off)
- Command Field : is available in standard tool bar
is a combo box(user choose a tcode from list, and enter new tcode)
is also called as ok field
is used to enter transaction code
- Transaction code : is also called as Tcode
is a command , which is used to call business operation concern initial
screen
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
is a short cut, used to access particular transaction screen
can be alphanumeric
ABAP Tcodes :
SE01 - Transport Organizer ( Extended view )
SE09 - Transport Organizer - used by ABAP consultant
SE10 - Transport Organizer - used by Functional consultant
SE11 - ABAP Dictionary
SE14 - Database Utility
SE16 - Data Browser
SE16n - New Data Browser
SE18 - BAdI builder - to define BAdI
SE19 - BAdI builder - to implement BAdI
SE21 - Package Builder
SE24 - Class Builder
SE37 - Function Builder
SE38 - ABAP Editor
SE41 - Menu Painter
SE51 - Screen painter
SE71 - Script Form
SE80 - Object Navigator (or) ABAP Workbench
SE81 - Application Hierarchy
SE84 - Repository Information System
SE91 - Message Class
SE93 - Custom tcode creation
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
BASIS Tcodes :
SU01 - User creation
SM04 - Users List
SM01 - Tcode List
SM36 - to schedule Background Job
SM37 - to monitor Background Job
SCC4 - clients list
SM50 – Work process overview
SM51 - System Overview
Command Field Navigation :
<tcode> - to call particular tcode directly from Easy Access
/n<tcode> - open a new tcode with in the same session
/o<tcode> - open a new tcode as parallel session
/i - delete current session
/h - switch to debug mode
/n - switch to Easy Access from any screen
/o - overview of opened sessions
/nex - logoff without dialog prompt(with out save)
/nend - logoff with dialog prompt
Ctrl + / : move cursor to Command field
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
Functional Tcodes :
SD tcodes :
XD01 - create customer
XD02 - change customer
XD03 - display customer
VA01 - create sales order
VA02 - change sales order
VA03 - display sales order
MM tcodes :
MM01 - create material
XK01 - create vendor
ME21 - create purchase order
ME21n - create purchase order ( new screen ) - Enjoy tcode
- SAP Menu : consist of Tools like
- ABAP Workbench is a tool used by ABAP Consultants
- Customizing tool used by Functional Consultants
- Administration tool used by Basis Consultants
- All Tcodes are stored in TSTC database table
- SDMO tcode, is used to search for any tcode, based on text
- Search_sap_menu , tcode provides path in sap menu, for entered text
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- Search_user_menu, tcode provides path in user menu, for entered text
*******************************************************************************
Versions : is a term applicable to business functionality
SAP R/3 -> EE -> ECC
product -> SAP R/3 -> SAP R/3 -> SAP ERP (product name)
versions->3.0 to 4.6c -> 4.7EE -> ECC 5.0 -> ECC 6.0
(1992-2002) -> (2003-04) -> 2005 2006 to till date
(EhP1.........7)
Release : is a term applicable to basis functionality
SAP BASIS -> SAP WAS -> SAP NWAS
3.0 to 4.6c 6.10 6.40
6.20 7.00
6.30 7.01......7.40
(Latest Product : SAP ERP
Latest Version : ECC
Latest Enhancement : EhP7
Latest Release : SAP NW7.40)
*************************************************************************************
*****
Dialog Work process : it executes dialog steps
it handles the user actions on screen
Update Work Process : it performs update to database
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
Lock Management :
- Lock object is required to restrict simultaneous access of table record by several users at a time.
- SAP supports row level (or) record level lock
- Way to work with locks :
- first lock table entry
- perform operation on table record( modify / update / delete )
- finally unlock table entry ( release lock )
- steps to work with lock object :
- step1 : define lock object in ABAP Dictionary
user defined lock object name should begins with EZ (or) EY
specify primary table name
specify lock mode
save, check, activate
lock argument is defined on key fields table
upon activation of lock object, system generates 2 function modules
ENQUEUE_<lock object> : is used to perform lock
DEQUEUE_<lock object> : is used to perform unlock
- step2 : create ABAP executable program
call enqueue function module
pass values
test program
- step3 : perform operation on table entry
- step4 : SM12 - tcode is used to view all logical locks
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- step5 : create abap executable program
call dequeue function module
pass values
test program
Note : physical lock happens on underlying table record
logical lock happen by enqueue work process at application layer
lock server (or) Enqueue sever holds all logical lock entries
Lock mode : specifies type of lock
Type 'E' - Exclusive Lock
the user who sets the lock, he can perform all operations
others users lock request is rejected
it is cumulative ( multiple times allowed )
Type 'S' - Shared Lock
All users can only read the locked data
modification is not allowed by any user
Type 'X' - Extensive Lock
is also exclusive lock
it is not cumulative ( it is allowed only for one time )
***********************************************************************
Unit 8 : ABAP Workbench
- Repository is Client Independent (or) Cross-client
- Application data and Customizing data is client specific (or) client dependent
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- Working with Repository Objects :
- Work with built-in objects : predefined, SAP defined objects
- Create custom objects with customer namespace
- Repository is a collection of Applications
Application is a collection of Components
Components is a collection of Package
Package is a collection of Repository objects
- SAP -> Repository -> Applications -> Components -> Package -> Repository Object
Ex :
SAP -> Repository -> SD -> SLS -> VA ->VBAK table
SAP -> Repository -> MM -> PUR -> ME ->EKKO table
- Search criteria for repository objects :
- execute tcode SE11
- search for custom tables : z* press F4 - system displays all the table names begins with z
- searching for any object using Repository Information System :
RIS - tcode - SE84
it provides application independent search
it provides search criteria based on object name (or) short description (or)
package (or) application component
- SAP is a collection of Applications (or) functional modules (or) functional areas
Application is a collection of Components
Component is a collection of Package
Package is a collection of similar functionality of objects
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- searching using Application Hierarchy
tcode : SE81
it provides application dependent search
- SE80 tcode for Object Navigator (or) ABAP Development Workbench
it is useful to freely navigate between repository objects
it is integrated with - Repository browser,
Repository Information System,
Tag Browser,
MIME Repository,
Transport Organizer
it is used to develop BSP and WebDynpro applications
it is mainly used by ABAP consultant, to develop / change / display objects
All activities can be done using right click ( context menu )
- SE81,SE80,SE84 - are overview tools , integrated with ABAP Workbench
***************************************************************
- Custom Package creation :
- Package can be created directly using SE21 tcode (or) SE80 tcode also
- specify package name begins with Y or Z
- click on create
- specify short description
- specify software component (HOME)
- specify transport layer(transport root)
- package type(development)
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- continue
- click on create request
- specify short description
- save
- notice that system generated a new workbench request number
- continue
- While creating objects, we can save object in custom package
then system automatically proposes transportable workbench request number
- Request number is a recording mechanism of Development Activity
it consist of object name, short description, owner, source client, target client, project, date,
status.
Request number is represent as below
<INSTANCE>k<9xxxxx>.
EX :
ZMEK900021
ZME - instance
k - is constant
request number always begins with 9, maximum 6 digit number
Request is a collection of Task
- system automatically assigns next immediate number as Task number
- Transport Organizer : SE09
It is used to organizes all transport
ABAP consultant is responsible to develop + test + release object
Released objects transported by BASIS consultants using TMS
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- As a rule, all task must be released first, before releasing request
- Project lead creates and releases Request number
- Project member creates and releases Task
- CR : create request / change request
TR : transport request
*************************************************************************************
*****************
ABAP Programming :
ABAP Features :
- Advanced Business Application Programming
- it is 4th generation language
- it is having similarities of COBOL
- it is SAP proprietary programming language
- it is development environment(IDE) of SAP
- using 40% of Assembly language and 60% C,C++ initially ABAP was developed
- it is used to develop SAP in-house applications
- it is High level language
- it is Application programming language
- it is Procedure oriented language
- it is Event driven programming language
- it is Object oriented programming language
- ABAP -> ABAP/4 -> ABAP Objects
- it is not case sensitive
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
WRITE
write
Write
- is typed language
- is interpreter based language
- is upward compatible ( lower version syntax allowed in higher version )
- ABAP Editor Standards :
- ABAP Editor is used to write ABAP program source code
- ABAP programs are executed by ABAP processor (or) ABAP interpreter
- ABAP Editor tcode : SE38
- ABAP Editor is a development tool , which is closely integrated with ABAP Workbench
- ABAP Editor is used to display built-in program and
to create and change custom programs
- ABAP program is also Repository Object
- SAP defined program names begins with A.....X
- User defined program name begins with Y / Z
- Steps to create program :
- execute tcode SE38
- specify program name begins with Y or Z
- click on create
- specify meaningful title
- specify program type as (1 - Executable program)
- save as local object
- enter the program source code
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- save, check, activate
- test / F8
- Note : every program have unique name
every program must belongs to any one of the below program type
Type 1 - Executable program
Type M - Module pool program
Type I - Include program
Type S - Subroutine pool
Type F - Function Group
Type T - Type pool
Type K - Class Pool
Type J - Interface Pool
Type X - XSLT program
Type Q - Database procedure Proxy
Type 1 program is self executable, other programs are not self executable
XSLT : program is used to convert ABAP program to XML and vice versa
- Package : is also called as Development Class(old versions 4.6c)
is a collection of similar functionality objects
Package is also Repository Object
SAP defined package name begins with A...X
User defined package name begins with Y / Z
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
SAP defined objects belongs to SAP package
User defined objects belongs to User defined package (or) $tmp
$tmp is default , built-in package, which stores all local objects
local objects can't transported to other systems
Custom package objects can be transportable
Packages can be created by BASIS consultants,
using Package Builder (SE21 tcode) or
Object Navigator (SE80 tcode)
- while saving program, it writes Repository table(TADIR) as Repository object
while checking program, program code is verified by ABAP interpreter
while activation : program runtime object gets generated
status changed to Active
program is ready to display output
program can be used in other programs
for every change, we have to activate explicitly
*- Basic Rules of ABAP programming :
- First statement must be Report statement
- Every statement begins with keyword ends with period
- Statement can be written in single line (or) several lines
- write is used as output statement
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- string must be placed with in single quotes
- ABAP supports 7 color ids
- we can apply 7 background colors of text
- NEW-LINE. statement provides output in new line
- / provides output in new line
- /<col_pos> provides output at specified column position in new line
- ULINE statement provides underline in the output
- ULINE /<col_pos>(offset length).
provides under line for the specified length
- SKIP provides one blank line in the output
- SKIP <n> provides <n> blank lines in the output
- SKIP TO LINE <line number>.
this statement skips the specified line numbers
- WRITE AT /<col_pos>. this statement displays the output at specified column position
- Every operator and operand must contain before and after space
c = a + b.
- Increment notation
i = i + 1.
add 1 to i.
- Decrement notation
i = i - 1.
subtract 1 from i.
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- pre-increment is not support by ABAP
- Comments : are used for documentation
improves the program readability
comment lines ignored by interpreter
- Single line comment : place * symbol at first column position, then entire line treated as
comment line
- Multiple lines comment : select multiple lines
press Ctrl + < for comment (or) Ctrl + , for comment
press Ctrl + > for uncomment (or) Ctrl + . for uncomment
- In line comment : partial comment
place double quotes in a line
rest of the statement after double quotes is act like comment
* must be at first column position
" can be at any column position
- Operators List :
Every operator identified by unique symbol
Every operator have unique purpose
Arithmetic Operators : are used for Arithmetic (or) Mathematical operations
+ addition operator
- subtraction operator
* multiplication operator
/ general division operator
DIV integer division (quotient is rounded to nearest integer)
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
MOD modulus (remainder based calculation)
** power (or) exponentiation
Logical Operators : used to combine multiple condition statements
AND - both condition matching
OR - any condition matching
NOT - is used for negative matching
Relational Operators : are used for Comparison purpose
= EQ
<> >< NE
> GT
>= GE
< LT
<= LE
LIKE
IS INITIAL
BETWEEN <field1> AND <field2>.
*- Separators : are used to separate two things, do not require space before and after
- hyphen
~ tilde
-> single arrow
=> double arrow
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
/ slash
*- Keywords : are reserved words
every keyword have unique purpose
DATA : keyword is used to declare data objects ( variable, structure, internal table )
TYPES : keyword is used to declare local data types ( elementary, complex data types )
CONSTANTS : keyword is used to declare constant variable
PARAMETERS : keyword is used to accept single value from user
SELECT-OPTIONS : keyword is used to accept range of values from user
SELECT : keyword is used to retrieve data from database
WRITE : keyword is used to display program output
*- Typical Structure of ABAP program :
Declarations
Operations
Output
*- DATA TYPES : describes data object
do not occupy memory
- can be classified as
- Dictionary Data types (or) Integrated types
- Predefined data types
- local data types
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- ABAP Dictionary data types : have global scope
are valid for all programs, all function modules, all global
classes ..and so on.
- Predefined data types : only used in editor ( programs )
ABAP interpreter determines automatically
valid for all programs
- Mapping between predefine and dictionary types
dictionary type predefined type
Char <- c
Numc <- n
Dats <- d
Tims <- t
Int4 <- i
Fltp <- f
Dec <- p
- local data types : are defined based on required
are not predefined
scope is local (valid for that program only)
*- classification of predefined data types :
- Elementary data types
- fixed length
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- character data types
c character
n numeric character
d date
t time
- numeric data types
i integer
f float
p packed decimal
- hexadecimal data type - X
- variable length
- string ( character sequence )
- Xstring ( byte sequence )
- Complex data types
- structure types
- table types
- Reference data types
- data references
- object reference
- classes
- interfaces
Data Object : is a instance of data type, which occupy memory
- Literals : are unnamed data objects
can be classified as
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- Character Literals :
- must be place with in single quotes
- it may have alphanumeric characters
- Ex : 'Ravi'
'WB24 1234'
'SAP R/3'
- Numeric Literals :
- sequence of numbers
- single quotes is optional
- Ex : 123
-456
'789'
- Strings : are sequence of characters
must be places with in single quotes
Write 'Welcome to ABAP/4'.
- Variables : are place holders , which are declared by DATA keyword
are created at program runtime in the memory(RAM)
holds the value dynamically
- Constants : are constant variables , having fixed value in entire program
- Interface Work Areas : Tables and Nodes
- System Fields : also called as System Variables
are SYST structure components
are predefined data objects
can be used in programs, along with write statements
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
SY-DATUM : display current application server date
SY-UZEIT : display current application server time
- Text Symbols : are part of Text pool
are part of Text elements
are used to avoid hard coded text
are used for to display reusable text
supports to write language independent programs
are program dependent
DATA <data object> TYPE <data type>.
*-Syntax to declare variable with out specifying length
DATA <variable> TYPE <data type>.
Ex :
DATA n1 TYPE i.
*- Syntax to declare variable by specifying length
DATA <variable>(length) TYPE <data type>.
DATA <variable> TYPE <data type> LENGTH <length>. "alternative syntax
Ex :
DATA name(5) type c.
DATA name type c length 5.
- data type describes - initial value for data object
initial length in memory for data object
expected values for data object
- Chain statement : is written using colon
: is chain operator
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
it concatenates many statements with comma and finally ends with period
- Static values can be assigned to variables in several ways :
- using VALUE keyword
is used to declared and assign value immediately
DATA <variable> TYPE <data type> VALUE '<val>'.
- using = operator
<field> = '<value>'.
- using MOVE keyword
MOVE '<value>' TO <field>.
= Move are used to assign after declaration
- Assigning common value to several variables in single statement also possible
n1 = n2 = n3 = 10.
- Declaring several variables in single statement
data : n1,n2,n3 type i.
- default data type in ABAP is type C
- n1 and n2 belongs to data type c
- n3 belongs to data type i
- Parameters statement generates selection screen, to accept single value from user,
also creates data object in the memory.
- Initial value for character data type is space (or) blank
and other data type is zero
- CLEAR statement resets assigned value back to initial value
syntax :
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
CLEAR <data object>.
- IS INITIAL is used as a logical query , to check data object status
IS NOT INITIAL
- TYPE followed by data type
LIKE followed by data object
LIKE is used to create new data object , with ref to existing data object
As a result, technical properties(data type, length) of existing data object, copied to current data
object
but Value will not be copied
- Constant variables are declared by CONSTANTS keyword
- have fixed value throughout program
- must be assigned with value using VALUE keyword
- we can't assign value using = (or) MOVE keyword
- its value can't be changed later
- CLEAR statement is not allowed on constant variables
- Working with local data types is 2 step procedure
- step1 : declare local data type using TYPES keyword
syntax
TYPES <t> TYPE <predefined type>.
TYPES <t>(length) TYPE <predefined type>.
TYPES <t> TYPE <predefined type> LENGTH <length>.
Ex :
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
TYPES t_hello type c.
TYPES t_hello(5) type c.
TYPES t_hello type c length 5.
- step2 : declare data object using local data type
DATA <variable> TYPE <local data type>.
Ex :
DATA name type t_hello.
- TYPES keyword creates data type
DATA keyword creates data object
- Note : if the variable is declared by making use of predefined type, length specification is allowed
if the variable is declared by making use of local data type, then length specification is not allowed
- Exploring elementary data types :
Integer : it is converted to INT4 dictionary data type
accepts only whole numbers with leading sign (+ / -)
doesn't print decimal value
it rounds to nearest integer
length specification not allowed
it occupies 10 places internally with sign
Note :
Internal memory allocation depends on operating system and processor
SAP follows Unicode character set
Unicode point of view, one character occupies either 2 bytes (or) 4 bytes
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
Float : supports decimal value
values are displayed in special scientific format (<mantissa>E<exponentiation>)
doesn't support to perform arithmetic operations
it occupies 8 bytes ( internal maximum length16 places )
Accurate values can't be displayed
Float values can't be accepted from user (doesn't supported by PARAMETERS )
length specification is not allowed
Packed : supports decimal values
supports DECIMALS keyword also
is recommended for Arithmetic operation
length specification is allowed
we can accept packed values from the user
it occupies 8 bytes
exact values are displayed thru packed data type
Character : is default data type
default length is 1 place(left justified)
length specification is allowed
it accepts alphanumeric values
Numeric Character : is special data type, which is used to display zip code (or) postal codes
length specification is allowed
default length is 1 place (right justified)
accepting only numbers
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
it converts characters into numbers
Date : is fixed length data type
maximum length 8 places
length specification is not allowed
SAP standard date format YYYYMMDD
program format YYYYMMDD = output format DDMMYYYY
Time : is fixed length data type
maximum length 6 places
length specification is not allowed
SAP standard time format is HHMMSS
X - Hexadecimal : (0123456789abcdef)
are used in SAP graphics
*- variable length elementary data types
String : is variable length data type
length specification is not allowed
dynamically system allocates length
Xstring : is used in bitwise operations
String Operations :
- Shift : shifting character of string
- Translate : translating string to upper case / lower case
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- Streln( ) : function to calculate length of a string
- Condense : removing redundant gap with in the string
- Concatenate : joining two strings into target string
- Split : splitting large string into small sub strings
- Replace : replacing existing string with new string
- Find (or) Search : finding a character in string
- String Comparison Operators :
CO - contains only
CN - contains not only
CA - contains any
NA - not contain any
- this comparison is case sensitive
CS - contain string
NS - not contain string
CP - contain pattern
NP - not contain pattern
- this comparison is not case sensitive
*---Condition based programming : using IF and CASE
using branching statements (or) constructs
- Simple IF : is used to execute if condition is true
is used to test single condition
syntax : IF <condition>.
---<st block>---.
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
ELSE.
---<st block>---.
ENDIF.
- Nested IF : is used to check with multiple conditions
syntax : IF <condition1>.
---<st block1>--.
ELSEIF <condition2>.
---<st block2>--.
ELSEIF <condition3>.
---<st block3>--.
ELSE.
---<statement>--.
ENDIF.
*- CASE : is alternative for Nested IF statement,
easy to compare values
comparison is case sensitive
syntax :
CASE <field>.
WHEN 'val1'.
----<statment1>---.
WHEN 'val2'.
----<statement2>---.
WHEN 'val3'.
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
----<statement3>---.
---------------------------.
---------------------------.
WHEN others.
---<statement>---.
ENDCASE.
*---Loops : also called as Iterative (or) Repetitive statements
4 types of loops available in ABAP
- Do loop : unconditional loop ( exit checking )
- While loop : conditional loop ( entry checking )
- Select...Endselect : is a loop used to fetch data from database table
- Loop...Endloop : is a loop used to read data from internal table
- Do Loop :
syntax :
DO <n> TIMES.
-----<statement block>---.
ENDDO.
this loop repeats for <n> times
sy-index is a system field, which displays index of current loop pass
sy-index default value is zero, when it comes first iteration sy-index value increments 1, in further
subsequent iterations sy-index value automatically incremented
- Terminating Loops :
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- in general <n> times is used to terminate loop
- <n> times is not specified, it leads to infinite loop
- Loop can be terminated explicitly - conditionally using CHECK statement
- unconditionally using CONTINUE and EXIT statement
CONTINUE is used to skip one particular loop pass
- While LOOP :
syntax :
WHILE <condition>.
-----<statement block>---.
ENDWHILE.
- SA38 - tcode is used by end users (or) functional consultants, only to view output of any ABAP
program
- SE38 - tcode to create / change / display program, which is used by ABAP consultant
- ABAP Editor :
- ECC version onwards Front-End new editor is introduced
- Pretty printer is used to standardized the code, and indentation
- Pattern provides all insert statements
- ABAPHELP tcode provides keyword documentation (or)
type any keyword in editor , press F1
- ABAPDOCU tcode provides ABAP demo examples for learners
- SE39 tcode for Split screen editor
- Version Management :
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
while activation of the object , system generates one active version at development database
path : Utilities menu -> versions -> version management
we can generate several versions for each modification and keep it into native version database
path : Utilities menu -> versions -> generate version
we can compare both versions at any time
we can retrieve old version back
- Attributes screen -> Fixed point Arithmetic : is activated by system default for all programs.
so that packed decimal values displayed with appropriate decimals
*************************************************************************************
- variables can be declared using predefined type (or) local type
- variables can also be declared using global dictionary types(data element,
structure component
table field)
- syntax :
DATA <var> TYPE <DB Table>-<field>.
<var> is created by making use of dictionary table field
<var> get the technical properties( datatype,length ) from dictionary field
- we can fill the target variable by using select statement
SELECT statement read the data from database table and fills in target variable
SELECT single statement is used to read single field value from database table
whenever select single is used , it is good practice to specify where condition
so that system reads condition matching field value
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
SY-SUBRC is a system field, and SYST structure component
- is used to know any ABAP operation result
- after execution of ABAP statement , system automatically fills the sy-subrc value
- if the operation result is success then sy-subrc value becomes zero,
otherwise non zero.
- if SELECT statement executed successfully, then sy-subrc becomes zero, otherwise 4
- provides return value of ABAP statement
SELECT SINGLE statement also used to read several field values from database table record
target fields must be specified with in bracket as field list , separated by comma
*************************************************************************************
************
Variables have limitation : variable holds single value at a time
variables are created at different memory address(random)
variables doesn't support to display record
Working with Complex Data types :
Structures : is a collection of fields belong to different data types,
is also called as Field String
is nothing but arranging several variables in a structured order
Syntax :
DATA : BEGIN OF <structure>,
<field1> TYPE <data type>,
<field2> TYPE <data type>,
----------------------------------,
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
----------------------------------,
END OF <structure>.
DATA keyword creates data object with the name <structure> in memory
structure fields can be created with data type ( predefined type / local type / global types )
BEGIN OF keyword begins the structure
END OF keyword ends the structure
Addressing structure field :
<structure>-<field>.
we can assign value to structure field
- using VALUE keyword (declare + assign)
- using = operator
- using MOVE keyword
Structure have limitation : it can only display one record at a time.
New structure creation with ref to existing structure
DATA <new structure> LIKE <existing structure>.
MOVE keyword is used to move source structure field value to target structure
MOVE-CORRESPONDING statement is used to move source structure to target structure for
identical field names
- IS INITIAL is used to check status of structure
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
IS NOT INITIAL
- clear statement is used to reset structure field values back to initial values
- Note : declare structure fields as per database table field order
specify select statement as per database table field order(sequence)
if target fields order and select statement fields order differs from database table fields
order, then we have to SELECT ...into corresponding fields addition
Corresponding fields : only read and move the values for identical field names
which is not recommended by SAP (system needs to compare for every field name, leads to load on
the system)
*- declaring structure with required database table fields
DATA : begin of <structure>,
<field1> TYPE <DB Table>-<field1>,
<field2> TYPE <DB Table>-<field2>,
---------------------------------------------,
end of <structure>.
*- declaring structure with complete database table
DATA <structure> TYPE <DB Table>.
SELECT SINGLE * is used to read single record from database table
to hold single record target must be declared as work area
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
*- Working with Structure types :
- structure type is a complex data type
- structure type doesn't occupy memory
- structure type is used while creation complex data objects ( structure and internal tables )
- structure type can be created as 2 ways :
- local structure type : declared and used with in the program
scope is local
- global structure type : is defined in ABAP Dictionary, valid for all programs
scope is global
- syntax to declare local structure type :
TYPES : BEGIN OF <st_type>,
<component1> TYPE <data type>,
<component2> TYPE <data type>,
-------------------------------------------,
END OF <st_type>.
*- Internal Tables :
- are intermediate tables ,which will be created at application layer
- are temporary tables, which are created on RAM
- are data objects , declared by DATA keyword
- are complex data objects, extinction to structure
- are dynamic objects, which are created at program runtime
- holds the data at run time,
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- it maintains data as line by line (or) row by row
- working with internal table is 3 step procedure :
- declare internal table
- populate internal table
- display internal table (or) perform operations on internal table
- SAP doesn't recommend direct interaction on database tables for number of times.
that is why SAP recommends that create internal table on database table
fetch database table data and populate into internal table
we can perform below operations on internal tables :
- to fill internal table
-1 select statement is used to fill internal table with database table data
-2 append statement is used to fill internal table with our own record at the bottom
-3 insert statement is used to fill internal table with our own record at specified index
position
- to read records from internal table
-4 read
-5 loop...endloop
- other operations
-6 sort
-7 modify
-8 collect
-9 delete
- deleting data
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
-10 clear
-11 refersh
-12 free
- Usage of Internal tables :
- are used to perform SQL operations(SELECT / INSERT / UPDATE / DELETE) on database tables
- internal table data can be displayed on dialog screen
- internal table data can be displayed on report (or) forms
- internal table data can be downloaded into files / uploaded from files
- internal table have special feature as dynamic expansion
- by default it is created with 8kb memory, if 8kb is filled then system allocates 12kb
memory, and so on... up to 2GB
- Internal Tables can be declared as 3 ways as per requirement
- with required database table fields
- with database table
- with two database table fields
- Syntax based Internal Tables can be classified as 2 types :
- Internal Table with header line
- is old syntax
- it consist of 2 components
- header line : is implicit work area, which holds only one record at a time
in general it holds last operation record
is used to perform read / write operations on body
- body : is a storage area, which is extension to header line
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
can hold many records at a time as line by line (or) row by row
- Limitations :
- header line is created automatically by the system
- header and body name is same
if internal table name is itab, header can be address using name itab, but in order to
address body we have to use body operator itab[ ]
- header and body structure is same and memory address also same
- this syntax not support nested internal tables
- this syntax not supported by OOABAP programming
- Internal Table without header line
- is new syntax
- it consist of 2 components
- explicit work area : is created explicitly, which holds only one record at a time
in general it holds last operation record
is used to perform read / write operations on internal table
- internal table : is a storage area
can hold many records at a time as line by line (or) row by row
Advantages :
- work area can be created based on requirement ( not mandatory in all cases )
- work area and internal table names are different
internal table and work area can be addressed directly by its name
- work area and internal table structure is same and memory is different
- this syntax support nested internal tables
- this syntax supported by OOABAP programming
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
Attributes of Internal Tables :
- Table Type : specifies classification of Internal tables
- Index
- Standard Index
- Sorted Index
- Hashed
- Line Type : specifies structure of internal table each line
in genral Internal table rows are created by making use structure type
- Key Type : specifies whether internal table uses key (or) non-key of database tables
can be Unique key (or) Non-Unique key
if the Internal table uses key field of Database table , then it is called as Unique
key, As a result internal table is populated delayed and can't contain duplicate records
if the Internal table uses non-key field of Database table, then it is called as Non-
unique key, As a result internal table is populated quickly, and can contain duplicate records
Standard Index Internal table :
- it maintains records with linear index
- are default internal tables and mostly used in ABAP
- it always uses Non key field of database table
- system uses linear (or) sequential search to find a record
- response time depends on number of entries of internal table
- no limitations
- Index based operations possible
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
Sorted Index Internal table :
- it maintains records with sorted linear index
- are rarely used and recommended If the internal table to be created in a sorted order by
default
- it uses either key (or) non-key field of database table
- system uses binary search to find a record
- response time depends on number of entries of internal table
- limitation : sort command is not allowed
- Index (or) key based operations possible
Hashed Internal table :
- it does not contain index , only hashed key ( is a combination of several lines )
- are rarely used and recommended to store large amount of data in internal table
- it always uses Key field of database table
- system uses hash procedure (or) hash algorithm to find a record
- response time is constant regardless of number of entries of internal table
- limitation : index based operation not possible
- only key based operations possible
*- Working with internal tables :
- declaring internal table with required fields of database table :
step1 : declare structure type ( as line type )
step2 : declare internal table using above line type
step3 : declare work area using above line type
TYPES : begin of ty_kna1,
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
kunnr type kna1-kunnr,
land1 type kna1-land1,
name1 type kna1-name1,
end of ty_kna1.
DATA : it_kna1 type table of ty_kna1,
wa_kna1 type ty_kna1.
- Internal table is created by making use above line type
- components of structure type, becomes columns of internal table and work area
- TABLE OF keyword creates internal table
- with out table of keyword it creates work area with one row
- Note : declare internal table fields as per database table fields order(sequence)
specify select statement fields order as per database table fields sequence ,
to avoid usage of INTO CORRESPONDING FIELDS addition
*- SELECT statement is used to fetch (or) retrieve (or) read data from database table and populate
into internal table
*- LOOP...Endloop : is used to read several records from internal table
for each iteration it reads single record into work area
loop statement always start reading from internal table first record to till
last record
syntax : LOOP AT <itab> INTO <wa>.
-----<display wa content>----.
ENDLOOP. this loop reads all the records of internal table
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
finally it terminates
syntax : LOOP AT <itab> INTO <wa> FROM <indx> TO <indx>.
this syntax only reads index matching records from internal table
syntax : LOOP AT <itab> INTO <wa> WHERE <condition>.
this syntax only reads condition matching records from internal table
*- READ : statement is used to read single record from internal table
statement result is always single record
it is good practice to check SY-SUBRC for READ statement
Syntax of READ using index :
READ TABLE <itab> INTO <wa> INDEX <indxno>.
this syntax only reads index matching record
Syntax of READ statement with key :
READ TABLE <itab> INTO <wa> WITH KEY <field> = 'value'.
this syntax reads the first condition matching record
Whenever WITH key is used , it is recommended to use Binary Search addition for quick search.
Sort internal table before using binary search addition
Syntax of READ statement with table key :
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
READ TABLE <itab> INTO <wa> WITH TABLE KEY <k1> = 'val'... <kn> = 'val'.
this syntax only useful to read only key fields matching record
*- Append : statement is used to add additional records at the bottom of internal table
operation can be done thru work area to internal table
first new entry must be filled in work area, then perform append operation
syntax :
APPEND <wa> TO <itab>.
*- Insert : statement is used to insert new record at specified index position of internal table
this operation can be performed thru work area only
new entry must be filled into work area first, later use insert statement
syntax :
INSERT <wa> INTO <itab> INDEX <indx>. "with index addition
INSERT <wa> INTO TABLE <itab>. "without index addition
*- SORT : statement is used to sort internal table entries
operation can be performed directly on internal table
default sort mode is ascending
explicitly we can sort in descending , by specifying descending keyword
syntax :
SORT <itab>.
SORT <itab> [BY <field>].
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
SORT <itab> BY <field> [<mode>].
SORT <itab> BY <field1> <field2>.
*- MODIFY : statement is used to modify records at internal table level
operation also can be performed thru work area
- first read record from internal table
- change the value at work area level
- finally use modify statement
Syntax of Modify statement without index :
MODIFY <itab> FROM <wa>.
Syntax of Modify statement with Index :
MODIFY <itab> FROM <wa> INDEX <indx>.
Syntax of Modify statement using TRANSPORTING addition
MODIFY <itab> FROM <wa> TRANSPORTING <field1> <field2> WHERE <condition>.
this statement modifies all condition matching records with new values
*- COLLECT : statement is to summarize duplicate recods
this operation also performed thru work area
Syntax :
COLLECT <wa> INTO <itab>.
this statement compares work area record with existing internal table records, if it
finds any duplicate records ( character data type must match), then it performs sum of data i,f,p
values
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
it is useful while accumulating records and deletes duplicate records
*- DELETE : statement is used to delete internal table entries
this operation can be performed directly on internal table
syntax :
DELETE <itab> INDEX <indx>.
DELETE <itab> FROM <indx> TO <indx>.
DELETE <itab> WHERE <condition>.
syntax to delete duplicate records :
SORT <itab> BY <field>.
DELETE ADJACENT DUPLICATES FROM <itab>.
*- CLEAR : statement is used to reset values to initial values
statement can be used on work area (or) Internal Table
syntax :
CLEAR <wa>.
CLEAR <itab>.
Note : it is always good practice to clear work area explicitly
*- REFRESH : statement is used to remove internal table entries
but it doesn't remove memory ( retain internal table memory )
syntax :
REFRESH <itab>.
*- FREE : statement is used to remove internal table entries and allocated memory also
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
syntax :
FREE <itab>.
Note : REFRESH and FREE statements can only used on internal tables
*- IS INTIAL (or) IS NOT initial is used as logical query to check internal table status (whether
it contain entries or not )
*- DESCRIBE TABLE statement is used to find out attributes of internal table
syntax :
DESCRIBE TABLE <itab> LINES <line>
OCCURS <memory>
KIND <type>.
Lines parameter specify total number of lines
Occurs parameter specify initial allocated memory
KIND parameter specifies the type of internal table
T - standard index internal table
S - sorted index internal table
H - hashed internal table
*- working with two internal tables
- creating new internal table with ref to existing internal table
DATA : <new itab> LIKE <existing itab>.
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- moving entries from source internal table to target internal table
MOVE <source itab> TO <target itab>.
<target itab> = <source itab>.
*- appending many records from source internal table to target internal table
APPEND LINES OF <itab1> FROM <indx> TO <indx> TO <itab2>.
*- inserting several records from source internal table into target internal table
INSERT LINES OF <itab1> FROM <indx > TO <indx INTO <itab2> INDEX <indx>.
*- Syntax to declare internal table with database table
DATA : <itab> TYPE TABLE OF <DB table>,
<wa> TYPE <DB table>.
*- sy-dbcnt is a system field, which provides number of records effected after open SQL
operation(INSERT / UPDATE / DELETE / SELECT)
Internal Table Types : is a data type , which do not occupy memory
can be created as local (or) global
local internal table types are declared with TYPES keyword with in the
program, scope is local, valid for same program
global internal table types are created in ABAP Dictionary , scope is global
, valid for all programs
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
internal tables types are used while creating complex data object internal
table in the program
- Syntax to declare local internal table type
TYPES:<t> TYPE <table type> TABLE OF <line type> WITH <key type> <f> INITIAL
SIZE<m>.
Ex :
Types t_kna1 type Standard table of kna1 with non-unique key land1 initial size 0.
Types t_kna1 type Sorted table of kna1 with non-unique key land1 initial size 0.
Types t_kna1 type Sorted table of kna1 with unique key kunnr initial size 0.
Types t_kna1 type Hashed table of kna1 with unique key kunnr initial size 0.
*- with header line syntax :
DATA : BEGIN OF itab occurs 0,
kunnr like kna1-kunnr,
land1 like kna1-land1,
name1 like kna1-name1,
END OF itab.
DATA keyword creates data object internal table ITAB
BEGIN OF ..END of creates header line
occurs creates body with the same structure
0 allocates initial memory 8 kb
*- DATA : Itab type table of kna1 occurs 0 with header line.
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
itab is created by making use of entire KNA1 structure
occurs keyword creates body
0 allocates memory
WITH HEADER LINE creates header line
*************************************************************************************
*************************
Modularization Techniques :
- Modularity is a programming technique, where large size program is divided into small modules (or)
blocks and dealing with individual modules
- Advantages :
- reusability of source code
- avoiding code redundancy
- improves program transparency
- increases program readability
- can be divided into
- Source code modules ( mainly code reusability )
- macros
- includes
- Procedures (called by passing values)
- subroutines
- function modules
- methods ( object oriented procedure )
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- Includes :
Include program belongs to program type 'i'
Include program is a global Repository Object
User defined Include program name should begins with Y or Z
Include program consist of set of statements
Include program is not self executable
Include program can be use in other include (or) executable program
One Include program can be used in several programs ( reusability )
Syntax to use include :
INCLUDE <include prog>.
Parameter passing between include program and executable program is not possible
- Includes are useful to organize program in structured manner
it is mainly useful for program type 'M' and program type 'F'.
- Include classification
INCLUDE <program>top "global data declarations
INCLUDE <program>o01 "PBO modules logic
INCLUDE <program>i01 "PAI modules logic
INCLUDE <program>f01 "Subroutines
INCLUDE <program>e01 "Events
INCLUDE <program>u01 "User-Exit
- refer to program : SAPMSRD0
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
Procedures :
- Subroutine : is also called as routine (or) form
is procedure, mainly used for local modularization
is a set of statements which begins with FORM keyword and ends with
ENDFORM keyword
syntax to declare subroutine
FORM <subroutine>.
----<statements>---.
ENDFORM.
is called by PERFORM statement
syntax of calling statement
PERFORM <subroutine>.
As a rule, Calling statement must exist before subroutine declaration
Nested subroutines not allowed
but one subroutine can call another subroutine
recursive calling leads to runtime error
Subroutines can also created thru forward navigation(double click)
- system prompt for include selection
- if we choose f01 include , then form...endform template generated
in include
- if we choose main program, then form..endform template is generated in
the same program only
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
After subroutine definition, another subroutine definitions are allowed, but general
statements are not accessible
As a standard approach, all Perform statements exist at the top of the program,
and subroutine definitions exist at the end of the program
Every subroutine must have unique name and it performs unique operation
- Terminate subroutine
in general subroutine is terminated endform statement
we can explicitly terminate subroutine conditionally using CHECK statement, and
unconditionally using EXIT statement
#include <stdio.h>
main()
int a, b, c;
a=10;
b=20;
c=add(a,b);
printf("%d",c);
add(x,y)
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
int z;
z=x+y;
return(z);
- We can also perform operations thru subroutines
possible types of operations :
- Pass by reference
- Pass by value
- Pass by value and result
Inorder to perform operations subroutine must be declared with parameters
The parameters which are defined along with PERFORM statement is called as Actual Parameters
The parameters which are defined along with Subroutine is called as Formal Parameters
As a Rule, Number and data type of actual and formal parameters should be same
USING and CHANGING keywords are used to define parameter interface
*- Pass by Reference : while subroutine call perform statement sends (export) address of
actual parameters to subroutine.
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
formal parameter doesn't have separate memory, but in turn they point
to the address of actual parameters
so changes done formal parameters have immediate effect on actual
parameters
USING and CHANGING keywords are same in case of pass by ref.
*- Pass by Value : while subroutine call perform statement sends(export) value of actual
parameters to subroutine.
Formal parameters are declared with VALUE keyword.
VALUE keyword creates separate memory to formal parameters
it receives (import) the values and perform the operation
operation result remains local only
changes done to formal parameters doesn't effect on actual.
formal parameters are created with USING and VALUE keyword
*- Pass by Value and Result : this is also pass by value only
but it is used to return the operation result back to calling
program
result only returns at the end of the subroutine
formal parameters are created with CHANGING and VALUE
keyword
Note : PERFORM statement never contain VALUE keyword
USING followed by parameters are sending/exporting address (or) value
CHANGING followed by parameters are receiving/importing value
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
FORM statement
declared formal parameters with out VALUE keyword are pass by ref(receive
address of actual parameters)
formal parameters USING with VALUE keyword are pass by value (receive value
of actual parameters)
formal parameters CHANGING with VALUE keyword are pass by value and
result
*- Internal Tables can also pass to subroutine
Internal tables can always pass by reference
TABLES keyword is used to pass internal tables
*- Local variables can be defined with in subroutine using DATA (or) STATICS keyword
if the local variable is defined with DATA keyword, then its scope is local, valid with in the program.
if the local variable is defined with STATICS keyword, then it scope is extended to next subroutine
call also.
*- Subroutines can be classified as :
- Internal Subroutines : are created in executable program
are used for local modularization
subroutine and perform statement exist in the same program
- External Subroutines : are created under program type 'S' - subroutine pool
can be called by any program
perform statement exist in executable program(type 1)
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
syntax to call external subroutine :
PERFORM <ex_sub>(program).
*************************************************************************************
***
Function Modules :
- implemented as external subroutines
- created in function builder
Tcode for Function Builder : SE37
Function Builder is used to create to create / change / delete function
group
and create / change / display /test function module
Function Group : is also called as Function Pool (or) Function Library
belongs to program type 'F' - not self executable
can be created using SE37 (or) SE80
is a Repository Object
is a group is a collection of similar functionality of function modules
SAP function group consist of SAP defined function modules
is also collection of dialog screens, status, subroutines, includes..etc.,
after creation function group , system automatically creates function pool
program, sap generated function pool name begins with SAPLz......
steps to create function group :
execute tcode : SE37
goto menu -> function groups -> create group
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
specify group name starting with Y or Z
specify short description
continue
save as local object
Activate function group :
goto menu -> function groups -> display
specify our group
click on master program
activate 2 includes and activate main program, back
Function Module : is procedure, which supports global modularization
every function module belongs to one function group
every function module have unique name and unique functionality
function module also Repository Object
Custom function module name should begins with Y_ (or) Z_
nested function modules not possible
one function module can call another function module
recursive calling leads to runtime error
function module can be created / activated / tested / released
can be called in executable program using below syntax :
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
CALL FUNCTION '<FMODULE>'
one function module can be called in many programs ( reusability )
*- we can perform operations using function modules
- pass by value(import and export tabs)
- pass by value and result(changing tab)
- pass by ref(tables tab)
- exception handling(exceptions tab)
In order to perform operations function module must be declared with formal parameters
calling program must be declared with actual parameters
As a Rule, Formal and Actual parameters number and datatype should be same.
*- working with function module : import and export tabs
scenario1 :
- pass by ref :
- declare import parameters as reference( n1 type i, n2 type i )
- declare export parameter as reference(res type i)
- implement logic in source code with the help of import and export parameters
scenario2 :
- pass by value :
- declare import parameters with default values, check pass value checkbox
- declare export parameters check pass value checkbox
- implement logic with the help of import , export parameters
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
Import tab :
is used to declare import parameters
import formal parameters import (accept) the values send by calling programs
can begin i_ import variable
is_ import structure
it_ import table
can be declared with associate type as - predefined type
- dictionary type (SE11)
- global class / global interface(SE24)
can be defined with default values also
if optional check box is checked, then it act optional import parameter, when function module is
called it is displayed as commented
if pass value check box is activated, then it is pass by value otherwise it is pass by ref
if default values are provided for import parameters, then it is act like optional
- can be defined with short / long description
Export Tab : is used to declare formal export parameters with in the function module
it exports the operation result back to calling program
it can be defined e_ export parameter
es_ export structure
et_ export table
- are by default optional
- they can be pass as reference (or) pass by value
- default values not possible
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
Note : SAP recommends that use Import and Export tabs as Pass by value
Scenairo3 :
Working with Changing Tab :
- declare import parameters with default values, check pass by value check box
- declare changing parameters with pass by value
- specify logic in source code
changing tab is used to return the changed value back to calling program
values are return at the end of function module
it must return the value
Scenario4 :
Working with Tables tab :
Tables tab is used to pass internal tables to function module
Tables tab is used to declare formal internal tables
begins with t_
internal tables are declared with like addition
by default it is created as old syntax internal table ( with header line )
associate type can be global dictionary type
Internal tables always pass by reference
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- create function module
- declare formal internal table in tables tab
- populate it thru select statement in the source code
- activate , test
- while calling in the program
we have to declare actual internal table and pass to function module
values can be passed as bi-directional
Scenario 5 : working with Exceptions :
- while processing function module, if system come across typical statements, it triggers runtime
error
- runtime errors are handled by exceptions
- we can plan in advance and implement exceptions ,in order to avoid runtime error
- exceptions are handled by messages
- working with exceptions is 2 step procedure :
step1 : declare exceptions in exceptions tab
step2 : raise exceptions under some conditions in the source code
syntax to raise exception :
RAISE <exception>.
- while calling function module in executable program, system automatically fills and assigns sy-
subrc value to exceptions
sy-subrc is zero if function module executed successfully,
its value is 1 for exception1 and so on...
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
Notes :
- source code tab is used to specify main logic of function module
souce code can be implemented with the help of local interface
logic must be written between function...endfuntion
requirement based we can declare local data objects
- Attributes tab :
- based on processing type function modules are 3 types
- Normal function module : by default function module type
can be called by any program with in the server
calling syntax :
call function 'FMODUE'
- Remote-Enabled function module : are RFC function module
can be called from any server , any program
is used to exchange data between cross servers
calling syntax :
call function 'FMODULE' destination 'RFC DESTINATION'.
- Update function modules :
- are used to update vb* tables asynchronous
- screen changes are immediately updated to temporary vb* tables
- calling syntax :
call function 'FMODULE' in update task
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- Searching for Function module :
- table TFDIR consist of all function modules
- most of the ALV related function modules begins with REUSE_ALV
- all BAPI function module names begins with BAPI_
- Application hierarchy : is used application wise function modules
- Repository Info sys : provides search based on
- function module name
- short description
- function group
- package
- application component
- Repository ->Application Component ->Package ->Function Group ->Function Module
*************************************************************************************
***********
*- BAPI : Business Application Programming Interface
is a standard interface , which is used for SAP to NON-SAP communication
are implemented as remote enabled function modules
BAPIs are widely used in SAP
BAPIs are implemented using ABAP Objects
BFA : Business Framework Architecture
- is a collection of business components
- business components are implemented as application component
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- business component is a collection of business objects
- business object is a collection of bapi methods
- each bapi method uses bapi function module
- bapi function module uses bapi struture
BOR : business object repository
all business objects are stored in BOR
BOR is a collection of business objects
BAPIs are widely used in SAP
- mass data migration ( Non-sap to sap data migration )
- data distribution using ALE( SAP to SAP )
- BAPIs are used in LSMW
- BAPIs are used in Workflow ( user to user communication )
- are used to display output in WebDynpro
- are used in Reporting
BAPI tcode provides list of Business Objects
BAPI tcode displays Business Object Repository
BAPI explorer provides list of Business objects in Hierarchical view and Alphabetical
view
Hierarchical view displays all business objects and Application component wise
Alphabetical view displays all business objects as A....Z order
application component - sd-sls
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
mm-pur
in hierarchical tab : ->expand sales and distribution -> expand sales
->sales order ( business object ) BUS2032(business object type)
-> business object is a collection of
->interfaces
-> key fields
-> attributes
-> methods(describes functionality of business object)
-> events
BAPI methods : are two types
-> instance dependent and instance independent
-> bapi method can be defined with signature(importing, exporting
parameters)
->get_list : provides list of object
->get_status : provides status of object
-> each BAPI method behind BAPI function module is available
BAPI function module :
-> All SAP defined BAPI function module names begins with BAPI_
-> User defined BAPI function module names should begins with Ybapi (or) zbapi
-> processing type : remote-enabled, can be called from any server
-> import and export parameters are created by making use of bapi structures
-> all import , export parameters must be pass by value
-> do not have exceptions
-> special export structure are BAPIRETURN (or) BAPIRET2
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
-> BAPI function group doesn't have dialog screens
Path from Easy Access : SAP menu -> Tools -> Business Framework -> BAPI Explorer
to develop business object ,we use business object builder (tcode : swo1)
Path for Business object builder : SAP menu -> Tools -> ABAP Workbench -> Development ->
Business object builder
********************************
RFC : Remote Function Call
is a protocol used by SAP System
is a mechanism, which is used to establish connection between two external servers
is configured by BASIS consultants
tcode to configure RFC : SM59
RFC is a interface , which provides communication between SAP systems (or) non-sap
systems
We have to provide RFC Destination name, connection type
hostname/IP address, System number
Gateway host / Gateway server details
finally save, test connection
if RFC connection is established successfully, then system provides time in
microseconds , otherwise it leads system failure (or) communication failure
RFC can classified as
tRFC - transactional RFC
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
aRFC - asynchronous RFC
sRFC - synchronous RFC
qRFC - queued RFC
webRFC
ALE : Application Link Enabling :
- SAP can be implemented as central server (or) distributed server
- in case of distributed environment , data is not stored centrally
- country specific servers are maintained
- ALE is a SAP proprietary technology used to distribute master data (or) transaction data
in distributed system
- operations happens in 2 systems
first system ,which sends data is called outbound system (outbound process)
second system, which receives data is called inbound system ( inbound process)
- ALE is used mainly to exchange data between SAP systems
- it provides asynchronous communication
- ALE uses RFC configuration, while establish connection between external servers
- ALE uses IDoc , to exchange data between external servers
- IDoc is intermediate document, is carrier which carries data from one system to another system
*************************************************************************************
**************
Messages : are used to know the operation result
are created in message class
tcode for message class : SE91
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
message class is also repository object
custom message class begins with Y or Z
6 types of message :
Type I - Information message
Type S - Status (or) Success message
Type E - Error message
Type W - Warning message
Type A - Abort (or) Abend message
Type X - Termination (or) Exit message
message class consist of message no and corresponding message text
message no represented by 3 digit number
valid message number range 000 to 999
maximum 1000 messages are possible for each message class
message text can be up to 72 characters , it may have alphanumeric values
message class concern messages are valid to use in entire SAP system
In order to use global message class in ABAP program, we have to specify message class name along
with report statement.
REPORT <program> MESSAGE-ID <msgcls>.
*- Syntax to display message text
MESSAGE <msgtyp><msgno>.
Ex :
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
MESSAGE I000.
Dialog behavior of messages :
Information message : displayed in special screen in model dialog box
it appears with some text and informs to user and allow the user to
proceed to next screen
Status (or) Success message : appears in status bar of same screen (or) next screen
it display text with green color tick mark
Error message : appears in special screen status bar
it display text with red color icon
user can't proceed further, he must go back rectify the issue
Warning message : appears in special screen status bar
it display text in yellow color
user can proceed to next screen, while pressing enter button
Abort (or) Abend message : appears in special screen with model dialog box
it displays with text , red color stop icon
continue with exit button
control transfer to SAP Easy Access
it restart the whole process
Short dump (or) termination message : leads to runtime error
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
it abnormally stops the process, and displays special
screen as short dump
short dump screen displays all runtime errors in SAP
runtime errors can be resolved using debugger
ST22 tcode is used to analyze all runtime errors
*- syntax to use any message class message
MESSAGE <msgtyp><msgno>(messageclass).
Ex :
message i000(zmsg_cls).
*- Syntax to display message of any message class :
MESSAGE ID '<msgcls>' TYPE '<msgtyp>' NUMBER '<msgnumber>'.
Ex :
message id zmsg_cls type 'I' number '000'.
*- syntax to display without specifying message class
MESSAGE '------<msg text>------' TYPE '<msgtyp>'.
*- syntax of message statement which raises exception
MESSAGE <msgtyp><msgno>(message class) RAISING <exception>.
Note : message class messages can be created by forward navigation also
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
*- System fields related to message class
sy-msgid : displays message class name
sy-msgno : displays message number
sy-msgtyp : displays message type
sy-msgv1 : display message variable
*- Messages can be created as static and dynamic
Static messages : are hard coded
always displays fixed message statement
are not reusable
Dynamic messages : are not hard coded
dynamically it display the corresponding text
are reusable
While program execution, program concern message statement sends values to message class
message statement
to hold the values message statement consist of place holders
Syntax of Dynamic Message :
MESSAGE <msgtyp><msgno>(msgclass) WITH <v1> <v2> <v3> <v4>.
Note : All messages are stored in T100 table
*************************************************************************
Write Formats :
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- Write statement displays program output
- NEW-LINE to display output in new line
- NEW-PAGE to display output in new page
- LEFT-JUSTIFIED is used to display output in left side
- CENTERED is used to display output in center
- RIGHT-JUSTIFIED is used to display in right side
- UNDER is used to display one value under another value
- NO-GAP removes explicit gap between two values
- NO-SIGN displays output with out sign
- NO-ZERO displays output with out zero
- NO-DECIMALS displays output with out decimals
************************************************************************************
*- Screens : while working with SAP, we come across 3 types of screens
- Dialog Screens
- Selection Screens
- List Screen
- Dialog screens are special screens , which are used to perform business transactions
- are used to accept input from user / display output to user
- are designed using screen painter
- Selection screens and List screens are used in Reporting (type 1 programs)
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- List screen is used to display program output
write statements and write formats are used to display output as per client requirement
main functionality of list screen is display program output
- in SAP every screen is identified by unique screen number
screen number is represented as 4 digit number
valid screen number range 0001 to 9999
1000 to 1010 are reserved SAP selection screens
Customer screen number range is : 1 to 999 and 1011 to 9999
- Selection Screen :
- are intermediate screen between program screen and output screen
- are interface between user and program
- main functionality of selection screen is to accept input from user
- it is used to filter the data while reading from database table
- standard selection screen number is 1000
- 3 keywords generates selection screen
- PARAMETERS keyword generates selection screen with single input field
- SELECT-OPTIONS keyword generates selection screen to accept range of values from
user
- SELECTION-SCREEN keyword is used to format selection screen and to create custom
selection screen
- PARAMETERS :
syntax :
PARAMETERS <p_field> TYPE <data type>.
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
Parameters field name should begins with P_ (or) PA_,
it can be up to 8 character long
selection text is used to provide alternative long text for parameter field
goto menu -> text elements -> selection text
- Parameters with DEFAULT addition is used to provide default values to selection screen field,
default values can be editable at runtime by the user
- Parameters with OBLIGATORY addition is used to make selection screen field as required entry
(mandatory field). User must supply the value, otherwise system doesn't allow to proceed to
next screen
- By default input field property is converting lower case value into upper case
this feature can be suppressed by adding LOWER CASE addition
As a result, lower case values retains in lower case only
- NO-DISPLAY addition is used to suppress the visibility of field in selection screen
- VISIBLE LENGTH addition is used to display input field with specified length, but it accept
value as defined length
- VALUE CHECK addition is used to perform validation of user input
it is only allowed if parameter field declared with dictionary type
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- syntax to create Check box :
PARAMETERS : <cb_field> AS CHECKBOX
- Predefined data objects in ABAP :
- System fields(SYST structure components)
- SPACE
- ME (Self reference method)
- SCREEN internal table
- syntax to generate radio buttons :
PARAMETERS : <rb_field1> RADIOBUTTON GROUP <rgrp>,
<rb_field2> RADIOBUTTON GROUP <rgrp>.
Radio buttons also called as option buttons
at least two radio buttons required under one radio button group
radio button group name can be alphanumeric, but can be up to 4 characters length
- Variant : provides pre configured values to selection screen
one selection screen can have many variants
each variant provides different set of values
step1 : execute program
provide values to selection screen
click on save
- specify variant name
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- short description
- save
notice that system generated get variant option, which is useful to choose any
variant from the available variants list
variants are program dependent
variant is important for background job
*- Syntax of parameters :
PARAMETERS <p_field> TYPE <DB Table>-<field>.
PARAMETERS <p_field> LIKE <DB Table>-<field>.
this syntax is used to create parameter field, by making use of database table field
As a result, parameter field get the technical properties(datatype, length)
and F1 help ,F4 help from the table field
Selection text can also created with dictionary reference
*- Syntax of Selection-Screen :
*- Syntax to design block with frame and title
SELECTION-SCREEN BEGIN OF BLOCK <blk> WITH FRAME TITLE <text-nnn>.
------------parameters
------------select-options
SELECTION-SCREEN END OF BLOCK <blk>.
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
title for block can be provided by using text symbols
or using initialization event
*- Syntax to provide blank line with in the frame
SELECTION-SCREEN skip.
SELECTION-SCREEN skip <n>.
*- Syntax to provide under line with in the frame
SELECTION-SCREEN uline.
SELECTION-SCREEN uline /2(7).
*- Syntax to display elements in single line with in the frame
SELECTION-SCREEN begin of line.
---parameters
SELECTION-SCREEN end of line.
*- Syntax to display field at specified column position with in the frame
SELECTION-SCREEN POSITION <pos>.
*- Syntax to provide comment for field
SELECTION-SCREEN COMMENT <col_pos>(length) text-nnn FOR FIELD <field>.
Field text can be provided using comment
comment can be provided using text symbol
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
*- Syntax to design custom selection screen
SELECTION-SCREEN begin of screen <scr no>.
---parameters
SELECTION-SCREEN end of screen <scr no>.
*- Syntax to call custom selection screen
CALL SELECTION-SCREEN <scr no>.
CALL SELECTION-SCREEN <scr no> STARTING AT <col> <row>
ENDING AT <col> <row>.
System displays standard 1000 selection screen first ,next system display custom selection screen
100.
*- Syntax to create push button in selection screen
SELECTION-SCREEN pushbutton <col_pos>(length) text-<nnn> USER-COMMAND
<cmd>.
text symbols are used to display text on pushbutton
user actions on selection screen can be handled under AT SELECTION SCREEN event
SSCRFIELDS is a built in structure , which is used to handle user actions on selection
screen
UCOMM component holds the function code value dynamically based on user interaction on
selection screen push button
*- selection screen keyword also used to design tab strip control
***SELECT-OPTIONS : keyword also generates selection screen
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
it is useful to accept range of values (or) interval values from user
it generates two input fields(lower limit -> upper limit)
Syntax :
SELECT-OPTIONS <so_field> FOR <DB Table>-<field>.
select-options field name should begins with so_, it must be up to 8 characters long,
selection text is used to provide alternative long text .
system can't recognize the database field automatically (because of FOR addition)
so TABLES keyword is used to create one work area the name of database table
otherwise we can declare single variable on database table field also.
SELECT-OPTIONS statement creates a special internal table in the memory(RAM)
this special internal table name is <so_field>,
it is also called as selection table
this internal table always created as old syntax (with header line)
header name and body name is <so_field>
this special internal table have 4 fields
- sign : data type c, length 1
value can be 'I' or 'E'
I - include range (inclusive) - default
E - exclude range (exclusive)
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- option : data type c, length 2
is used as comparison operator
BT - between ( default )
NB - not between
EQ - equals to
NE - not equals to
GT - greater than
GE - greater than or equals to
LT - less than
LE - less than or equals to
- low : lower limit value
- high : upper limit value
Select-options generates multiple selections icon in the selection screen,
using this icon user can set / reset include single value or include range of values ,
exclude single value or exclude range of values.
system dynamically generates select statement according user input
- Advantage of this selection table is : user can dynamically specify the values to fetch data
(without changing select statement values can be fetched)
- we can also build this special internal table manually
it can be build by filling header and append statement
it can be build under INITIALIZATION event
so that this values appears as default values
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
*- Additions allowed for select-options :
DEFAULT keyword is used to provide values
NO-DISPLAY is used to suppress the visibility of field in selection screen
NO-EXTENSION is used to suppress the multiple selections icon, ( user can't choose
multiple selections )
NO INTERVALS is used to suppress the upper limit field, ( user can't enter upper limit value )
- Screen fields attributes :
field have some attributes like
- active - visible in the selection screen
- input - ready to accept input
- output - only display output
- invisible - password property( displaying *****)
- intensified - displaying in output in red color
- required - display field with tick mark
- F4 help - display field with F4 key
- we can set attributes for screen fields using programming
- dynamically we can modify screen field attributes
- SCREEN is a built-in internal table which provides several screen field attributes
- SCREEN is a built-in structure which provides several screen field attributes
- syntax to work with screen internal table
LOOP AT SCREEN
if screen-name = '<fieldname>'.
screen-<attribute> = 1 or 0.
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
modify screen.
endif.
ENDLOOP.
- SCREEN internal table is by default created with old syntax
- conditional based we can set (or) reset attributes to screen field
- to apply / set attribute use value 1
- to reset attribute use value 0
- modify screen internal table with changed values
- Event AT SELECTION-SCREEN OUTPUT is used to provide several attributes to selection screen
fields
- MODIF ID addition is used to declare modification group name
modification group name can be up to 3 characters
by referring modification group, we can apply common attribute to all fields at a time
- PARAMETERS ,SELECT-OPTIONS both supports MODIF ID addition
*************************************************************
Open SQL : statements are used on Database Tables
sy-subrc and sy-dbcnt system fields are recommended to use for each open SQL
statement
- Insert : used to create new record in database table
first fill work area , and use below statement to create single record
INSERT <DB Table> FROM <wa>.
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
fill multiple records into internal table, then use below statement to create many
records
INSERT <DB Table> FROM TABLE <itab>.
- UPDATE : used to modify database table records at later stage
Syntax :
UPDATE <DB Table> FROM <wa>.
UPDATE <DB Table> FROM TABLE <itab>.
- DELETE : used to delete database table entries
Syntax :
DELETE <DB Table> FROM <wa>.
DELETE <DB Table> FROM TABLE <itab>.
- SELECT : statement is used to read / fetch / retrieve data from database table
SELECT <required columns>
INTO <target area>
FROM <database table / database view>
WHERE <condition1>
GROUP BY <column>
HAVING <condition2>
ORDER BY <column>.
SELECT...ENDSELECT is a loop, which is used to read database table data directly
each iteration it reads single record
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
this loop repeats for number of times depends on number of database table entries
it is not recommended to hit the database table for number of times, it is having
negative impact
it is recommend to read single record ( alternative for SELECT SINGLE )
Array Fetch operation : is faster and recommended by SAP
it reads all the records of database table and directly appends to
internal table at one step
this operation bypass work area
it uses SELECT ....INTO TABLE <itab> syntax
*- declare variable as target area, populate it using SELECT single <field> statement
*- declare structure as target area, populate it using SELECT single * statement
*- declare internal table as target area, populate it using SELECT * statement
*- UP TO <n> ROWS addition is used to read records from database table based on index
whenever up to <n> rows statement is used, it is recommended to use ORDER BY addition
*- WHERE addition is used to read condition matching records
multiple conditions can be combined using logical operators AND / OR
comparision is case sensitive
*- ORDER BY is used reading in the specified mode order
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
default mode ascending
instead of sorting at itab level, use select with order by addition
*- GROUP BY :
if several records have similar data, then we can apply group by on column .
it reads several records to single record
it is recommend to perform aggregate function on column
HAVING :
followed by condition
it is only recommended to use after Group by
we can apply further condition of group by column
*- DISTINCT :
addition is used to eliminate duplicate records while reading unique records
*- CLIENT SPECIFIED :
addition is used to read data from other clients
by default system reads data from local logon client
*- Aggregate functions : are used to perform Arithmetic operations along with Select Statement
MAX( <f> ) : provides maximum value of field
MIN( <f> ) : provides minimum value of field
AVG( <f> ) : provides average value of field
SUM( <f> ) : provides sum value of field
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
COUNT( <f> ) : provides number of records
*- reading data from 2 database tables
pre-requisite : underlying database tables must have relationship
KNA1 <-> KNB1 <-> KNC1 ( common field is KUNNR - customer no)
LFA1 <-> LFB1 <-> LFC1 ( common field is LIFNR - vendor no )
MARA <-> MARC <-> MARD ( common field is MATNR - material no )
VBAK <-> VBAP ( common field is VBELN - sales doc no )
EKKO <-> EKPO ( common field is EBELN - purchase doc no )
*- Techniques used to read data from multiple tables :
- use Inner join (or) left outer join
- use inner queries or subqueries
- use for all entries
- use parallel cursor
*- Inner Join : reads the data from both tables using join condition
join condition is defined based on common fields in both tables
*- For all entries : is used while populating current internal table, while comparing existing
internal table
is used to read corresponding records from database table
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
pre-requisite : main driving table should not empty
is used alternative for nested select statements
***********************************************
Inter program Communication : this topic deals with program to program communication
- SUBMIT keyword is used to call executable program in another executable program.
(to call report in report)
syntax :
SUBMIT <program>.
- syntax :
SUBMIT<program> AND RETURN.
this syntax calls the another executable program and while returning it display currnt program output
- syntax :
SUBMIT <program> VIA SELECTION-SCREEN.
this syntax calls other program concern selection screen first, then display output
- syntax :
CALL TRANSACTION '<tcode>'.
this syntax calls the specified tcode , and while returning it executes current program remaining
statement
this syntax calls the initial screen of specified tcode
- syntax :
CALL TRANSACTION <tcode> AND SKIP FIRST SCREEN.
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
this syntax skips the initial (or) first screen
- syntax :
LEAVE TO TRANSACTION '<tcode>.
this syntax leaves the current program and calls the specified tcode, while returning control transfer
to SAP Easy Access
- SAP MEMORY : is a common memory which is shared by all external programs
SET / GET parameter statements are used to share SAP memory
SET parameter statement sets the value from program to SAP memory
GET parameter statement reads the value from SAP memory to other program
syntax :
SET PARAMETER ID <pid> FIELD <f>.
GET PARAMETER ID <pid> FIELD <f>.
Parameter id is used to read (or) set values
Parameter id is defined at Data Element level
Fieldname Parameter ID
KUNNR KUN
MATNR MAT
LIFNR LIF
VBELN AUN
BUKRS BUK
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
*- Parameter ID values can be defined permanently at user profile
whenever user logs in, system reads values from user profile and display
system menu -> user profile -> own data -> parameters tab ->
specify parameter ID and parameter value
*- Parameters and SELECT-OPTIONS can also be defined with parameter id, using MEMORY ID addition
PARAMETERS <pa_field> type <DB Table>-<field> MEMORY ID <pid>.
SELECT-OPTIONS <so_field> FOR <DB Table>-<field> MEMORY ID <pid>.
system reads the value from user profile and display as default value
****ABAP Memory : is a common memory between all internal sessions of an external session
can be exchanged using EXPORT and IMPORT statement
Export statement exports the value from internal session to ABAP memory
Import statement imports the value from ABAP memory to other internal
session
*- Substructure can be defined with BOXED addition
advantage of boxed addition is when data object is created, initially it won't allocate memory.
substructure components are created in PXA - with initial values, as non modifiable part
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
when substructure components are assigned with value (used), then it revoke the reference from
PXA to modifiable memory
*************ABAP Reporting :
- Reports are used to display structured and formatted output
- Reports are output of Executable Program (Type 1)
- Reports are used by end users
for - information / analysis / decision making
- All SAP defined built-in reports are available under information system
- Possible types of Reports in ABAP :
- Classical Reports (or) Classical List
- Interactive Reports
- ALV Reports
- LDB Reports : are mostly used in ABAP HR programming
- ABAP Query (or) SAP Query : are generated by Functional consultant, without programming
knowledge
- ABAP is Event driven programming language
- ABAP reporting and screen programming is implemented using Events
- Every event have unique name and purpose
- SAP recommends to write Events explicitly in the program
- after writing events total program is divided as event blocks
- system gives high priority to Events
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- events are not triggered as the sequence it was written in the program
- events have priority of execution
- some events triggers internally by the system ( implicit events )
- some events triggered by user actions ( explicit events )
- Dialog Screen Events :
- PBO : Process Before Output - it provides default values to dialog screen
it triggers while loading the screen
- PAI : Process After Input - it consist of user input validation
- it is triggered by user actions on dialog screen
- POH : Process on Help-Request - it provides F1 help to screen field
it is triggered by F1 function key
- POV : Process on Value-Request - it provides F4 help to screen field
it is triggered by F4 function key
- Selection screen Events :
INITIALIZATION - it triggers while displaying selection screen
it is used to provide default values to selection screen fields
it is used to perform certain calculation before displaying selection screen
it must followed by START-OF-SELECTION event
is only valid for Executable program (type 1)
AT SELECTION-SCREEN OUTPUT - it also triggers before displaying selection screen
it provides different attributes to screen fields
AT SELECTION-SCREEN - it triggers after user action on selection screen
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
is used to perform authorization check
is used to perform user input validation check
AT SELECTION-SCREEN ON <f> - it is useful to validate particular field
AT SELECTION-SCREEN ON RADIOBUTTON GROUP <grp>.
- it is useful to perform operation after user interaction on
radio button group
AT SELECTION-SCREEN ON BLOCK <blok>.
- it is useful to validate all block concern fields
AT SELECTION-SCREEN ON seltab.
- it is useful to validate selection table
AT SELECTION-SCREEN ON VALUE-REQUEST FOR <f>.
- it provides F4 help to screen field
AT SELECTION0-SCREEN ON HELP-REQUEST FOR <f>.
- it provides F1 help to screen field
***********************
List Screen Events :
START-OF-SELECTION.
is implicit event triggered by the system for all executable programs
by default
is used to select the data from database table
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
END-OF-SELECTION.
is triggered at the end of data selection from database
is used to display output to list screen
TOP-OF-PAGE.
provides header information for page
is triggered by First write statement (or) Uline (or) SKIP statement
END-OF-PAGE.
provides footer information for page
is triggered by LINE-COUNT addition , along with Report statement
*************************************************************************************
****************
Report Transaction : is used to assign reports to end user
can be created using SE93 tcode
custom tcode name should begins with Y or Z
combines executable program and its selection screen 1000
Steps :
- execute tcode : se93
- specify tcode begins with Y or Z
- click on create
- specify short description
- choose report transaction
- continue
- specify program name
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- selection screen number 1000
- check GUI capability as SAP GUI support Windows
- save as local object
- check, test
**************************************************************************
Note : Custom List heading and column headings can be provided using text elements
goto menu -> text elements -> list headings
*************************************************************************************
***********************
Performance Tuning (or) Performance Analysis :
- Performance Factors on Database Tables :
- Indexes
- Buffering
- Log data changes
- Performance Factors on Select Statements :
- instead of select * , use select <f1> <f2>
- fetch required data only from database
- do not use select ...endselect loop, use Array Fetch (into table)
- implement many conditions, with WHERE
- instead of sorting at itab level, use Order by addition with select statement
- instead of perform arithmetic operations at itab level, use select aggregate functions
- instead of deleting duplicate records at itab level, use select distinct addition
- use inner join (or) database views
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- do not use nested select statements , use for all entries (or) parallel cursor
- Performance Factors on Internal Tables :
- use explicit syntax (without header line)
- nested loops not recommended
- select statement with in loop...endloop is not recommended
- Performance Tools :
- Extended Program Check - tcode SLIN
- Runtime Analysis - tcode SE30
- SQL Trace - tcode ST05
- Code Inspector - SCI
- ABAP Debugger
- Path for Performance examples :
ABAP Editor -> environment menu -> examples -> performance examples
- SAP Code Inspector :
- is a tool introduces from 4.7 version onwards
- is useful to check performance of any program
- it checks performance checks, security checks, extended program check, user interfaces
- it is also useful to perform check on WebDynpro application
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- path from ABAP Editor : Program menu -> check -> code inspector
- direct tcode : SCI
- path from SAP Easy Access : SAP menu -> tools -> ABAP Workbench -> test -> code
inspector
- Check variant : specifies list of checks to be carried out
- Object set : specifies list of object to be checked
- Inspection : combines check variant and object set
*****************************************************************
Authorization :
- we have to restrict user to access certain business critical data
- it can be implemented using Authorization Check
- in general select statement doesn't perform authorization check by default, we have to explicity
implement authorization check
- Authorization class is a collection of Authorization objects
Each Authorization object consist of fiedls
ACTVT field have 3 values 01 - create,
02 - change,
03 - display
- List of Authorization are defined under profile,
Profile is assigned to Role
Role is assigned to user master record
- Step1 : tcode : SU21 - create authorization class starting with Y or Z(ZACL)
- place the cursor on our authrozation class, then create authorization
object
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
specify fields like BUKRS, ACTVT,
specify permitted values(03 - display)
- BASIS consultant performs - profile creation with authorization
role creation , assign profile
user master record creation , assign role
- Step3 : tcode : SE93 : while creating tcode for executable program, ie.,Report Transaction,
specify authorization object and values
- Step4 : open program implement authorization check
under event AT SELECTION-SCREEN
call pattern, choose authorization radio button, specify authorization object, continue
specify values in the program,
check sy-subrc.
if the user is authorized ,specify select statement to read data
otherwise throw error message
*---------
Debugger : is a tool closely integrated with ABAP Workbench
is used to resolve runtime errors
is useful to analyze the program as line by line
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
Different ways to enter debug mode
- command /h
- break-point statement in program
- system menu -> utilities -> debug ABAP / program / system
- ABAP Editor -> program menu -> execute -> debugging
- In ABAP two types of debugger available :
old debugger - classic debugger , is valid up to 4.7EE version
new debugger introduced from ECC 5.0 onwards
- Classic Debugger :
common options available for all tabs :
F5 - single step - is useful for line by line execution
F6 - execute - is useful to execute set of statements at a time ( subroutines / function
modules / methods )
F7 - return - is useful to return the control back to main program
also useful to move cursor to next break point
F8 - run - it stops debugger and executes rest of the program at a time, procced to next
screen
Fields tab : is used to analyze variables, work areas
Tables tab : is used to analyze internal tables
we can change, delete, insert, append records in debug mode
change internal table content
- double click on field value
- specify new value
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
- then click on pencil icon(change field content)
- execute
Break-points :
- is a signal in the program source code, where system stops processing and starts debugger
- static break point can be created using syntax :
BREAK-POINT.
BREAK-POINT <n>.
BREAK <username>.
static break points : increase program lines
hard coded
- dynamic break points :
can be displayed in break points tab
can be maximum 30 (per program)
can be set / delete in program (or) debug mode
are not hard coded, doesn't increase program lines
can be set / delete using stop icon (application tool bar)
it is allowed on built-in programs also
- Watch Points :
unlike Break points, watch points are used to watch the program changes
one program can have maximum 10 watch points
SAP ABAP Certification Notes - prepared by A.V.Krishna,SAP Certified Consultant & Trainer
can only set in debug mode
once debugger closed watch points are deleted automatically
watch point can be defined by specifying field name, whenever field value changes, system prompt
with message "watch point reached'
watch point can also be created by specifing condition (values), if system meets the condition then
prompts with message "watch point reached'
several watch points can be defined with logical operators AND or OR
- CALLS tab provides list of all active calls in chronological order
- Overview tab displays all list of events, and triggered sequence
- Settings tab displays advanced settings of debugger
- New Debugger : opens the debugger as parallel session
supports to debug webdynpro applications
Desktop1,2,3,standard used to analyze field values
structure tab is used to analyse structure values
tables tab is used to internal tables
objects tab is used to analyse object oriented objects
diff tab is used to compare two variable values
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
ABAP Dictionary :
- is also called as Data Dictionary (or) DDIC
- tcode : SE11
- is a development tool, which is closely integrated with ABAP Workbench
- SE12 used for only display ( used by functional consultants )
- is a central repository, which consist of database tables, views, data types, type groups, domains,
search help , lock objects
- dictionary definitions have global scope, ( valid for all programs / function modules / global
classes )
- is also called as virtual database ( which consist of meta data - definitions of underlying
database objects )
- it is used to create, change, display, copy, delete dictionary objects
- is platform independent , and database independent
- while activation of database tables, and database views are created in the underlying database
- Functionality of ABAP Dictionary :
- it provides data integrity, data security, data consistency
- it avoids data redundancy
*- DATABASE TABLE :
- is a two dimentional matrix, which consist of records as rows and fields as columns
- Database Table is also Repository Object
- Working with Database Tables (priority basis):
- Work with built-in tables (or) predefined tables
- Enhancement of built-in tables
- Modify built-in tables
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- create custom tables
- SD Tables :
KNA1 - Customer master general data
KNB1 - Customer master company code data
KNC1 - Customer master Transaction figures data
KNVV - Customer master Sales Data
VBAK - Sales document header data
VBAP - Sales document item data
- MM Tables :
MARA - material master general data
MARC - material master plant data
MARD - material master storage location data
MAKT - material descriptions
LFA1 - vendor master general data
LFB1 - vendor master company code data
LFC1 - vendor master transaction figures data
EKKO - purchase document header data
EKPO - purchase document item data
- System Tables :
T000 - clients data
T001 - company code data
T001w - plants data
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
T002 - language keys
T005 - country keys
T006 - unit of measurements
T100 - messages
TADIR - Repository objects
TSTC - transaction codes
TCURC - currency codes
- Flight tables :
SCARR - Airlines
SPFLI - Flight schedules
SFLIGHT - Flight details
SBOOK - Booking details
SCUSTOM - Customer details
STRAVELAG - Travel Agency details
SMEAL - meals details
Built-in Table navigation :
- open any table in display mode
- table structure is loaded and displayed
- notice the short description
- notice number of key fields and non key fields
- utilities menu -> table contents -> display(to view the data of table)
- data browser concern selection screen is displayed
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- execute
- data browser concern output screen is displayed
- Data Browser : tcode - SE16
SE16n - new data browser (Enjoy transaction)
is used to display data of any database table (or) database view
- New terminology of database table :
- Package - every table must belongs to one package
- Delivery Class - specifies the data to be transferred between clients while client copy (or)
upgrade
- it specifies the owner of database table
A - Application Table
C - Customizing Table -
- Data Class : specifies the logical storage parameter
specifies the table space occupied by current table in the physical database
table space depends on type of data stored in the table
APPL0 - master data, transparent tables
APPL1 - transaction data, transparent tables
APPL2 - organization data, customization tables
- Size Catagory : specifies number of records expected in the table
0 0-250
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
1 250-2000
- Enhancement Category : specifies the type of possible enhancement to current table
- can be enhanced ( character / numeric / deep )
- can't be enhanced
- Dictionary Data types : also called as Integrated Types (30 data types)
ACCP - posting period
CLNT - client
INT4 - integer
FLTP - floating point
DEC - decimals
CURR - currency
CUKY - currency key
QUAN - quantity
UNIT - measuring unit
LANG - language
CHAR - character
NUMC - numeric character
DATS - date
TIMS - time
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- Classification of Database Tables :
- BASIS Classification :
- Client dependent tables
- also called as client specific tables
- consist of MANDT as first field and key field (CLNT as data type)
- records are stored along with client number
Ex : KNA1, MARA
- data is dependent on client
- Client independent tables
- also called as cross-client tables
- doesn't contain MANDT as key field
- records are not stored with client number
Ex : T002, TADIR
- data is common for all clients
- Functional Classification : based on type of data stored in the table
- in SAP we come across 4 types of data :
Master Data
Transaction Data
System Data (or) Control Data
Configuration data (or) Customization data (or) Organization data
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- Master Tables : stores master data
is the data which is almost constant and rarely changes
Ex :
Customer master data ( KNA1, KNB1,KNC1,KNVV )
Vendor master data ( LFA1, LFB1, LFC1,LFM1)
Material master data ( MARA, MARC, MARD,MAKT )
- Transaction Tables : stores transaction data
is the data which frequently changes and rarely constant
Ex :
Sales Tables(VBAK, VBAP)
Delivery Tables(LIKP,LIPS)
Billing Tables(VBRK,VBRP)
Purchase Tables(EKKO,EKPO)
- System Tables : stores system data
the data which is defined and controlled by SAP
the data which comes along with SAP software
Ex :
T002 - language keys
TCURC - currency codes
T006 - unit of measurement
- Configuration Tables : stores configuration data (or) organization data
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
the data which is entered by consultant , while set up new organization
in SAP
Ex :
TADIR - repository objects
T000 - clients
T001 - company codes
T001w - plants
*- Technical(ABAP) Classification of Database Tables :
Transparent Tables :
- maintains 1 to 1 relationship with underlying database
- are mostly used in SAP
- are used to for application (or) commercial purpose
- Ex : KNA1, MARA
Cluster Tables :
- maintains many to 1 relationship with underlying database
- rarely used tables, Special SAP constructed tables
- are used to store functional dependent data
- Ex : BSEG, BSES
- Cluster tables are large in size
- less number of tables(77)
- consist of common key field as cluster key
- are connected to underlying table as table cluster
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
Pooled Tables :
- maintains many to 1 relationship with underlying database
- rarely used tables, Special SAP constructed tables
- are used to store large amount of system internal data
- Ex : TRMAC, TTDTG
- pooled tables are small in size
- many number of tables(2100)
- doesn't consist of common key field( variable key )
- are connected to underlying table as table pool
Advantage of Cluster & Pooled tables :
- overall less of tables
- data is stored in encrypted(compressed) form
- saves underlying table space
- reduces I/O operations
Limitations of Cluster & Pooled tables :
- Inner join select statement not allowed
- select with group by, order by addition not allowed
- native SQL statements not allowed
- Secondary index can't be created
- Append structure is not possible
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
*- Logging : can be done to check performance of database table
logging checkbox available at technical settings of database table
if logging is activated , system records all the changes done by all users and finally
generates a log file as table history (tcode SCU3)
*- Hint : we always create transparent table,
it can be converted to structure / pooled table / cluster table
*- Custom Table creation Steps :
- Execute tcode : SE11
specify database table name starting with Y or Z
click on create
specify short description
specify delivery class (A)
specify data browser option ( display / maintenance allowed )
save as local object
click on technical settings
specify data class (APPL0)
size category (0)
save, back
click on fields tab
specify field name, activate key field,
specify data type, length, decimal places, using data element / predefined type
in the same manner create other required fields
extras menu -> enhancement category ->set option as can be enhanced
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
finally save, check, activate table
Utilities menu -> table contents -> create entries (to new entry)
Utilities menu -> table contents -> display ( to view existing entries)
Note : When we create new table by copying existing table, source table structure only copied to
target table, content will not be copied
Note : Technical settings of built-in table can be modifiable, without SAP permission and with out
access key
- Table field name must be unique
table field name can be up to 16 characters length
fields are 2 types
- key fields ( primary key fields )
- must be at the first
- must be adjacent
- minimum 1 key field and maximum 16 key fields are allowed
- key check box is activated
- if a table consist of more than 1 key field, it is called as composite primary key
- overall uniqueness is maintained for composite primary key
- unique key accept one record with initial values
- non key fields (non primary key fields)
- must be after key fields
- functional fields
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- may have duplicate values (or) null values
- Activation :
while activation of the database table
- table physical definition created in the database
- table runtime object gets generated
- status turned to Active
- table can be ready to use
- for any changes we have to activate table
- Data Element :
- describes semantic properties like short description, long description(F1 help
documentation), Field label( short, medium, long, heading), F4 help
- is a global data type defined in ABAP Dictionary initial screen
- is a Repository object
- can be created using data type as (predefined type / domain / reference type)
- Parameter ID can be defined at data element level
- once the data element can be created and activated , it can be used while creating table field
(or)structure component
- one data element can be used in multiple table fields ( reusability )
- can also be created thru forward navigation
- is also called as Semantic Domain
Steps to create data element :
- execute tcode : SE11
- select data type radio button
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- specify data element name begins with Y or Z
- click on create
- continue with data element
- specify short description
- specify data type and length ( using predefined type / domain )
- save as local object
- maintain short, medium, long, heading field labels (field label tab)
- maintain documentation using documentation tab
- finally save, check, activate
- Usage of Data Element while crating table field
- specify field name,
- specify corresponding data element name, press enter
- notice the data type, length, short description
- while creating new entry
- notice F1 help documentation
- notice medium field label( utilities menu -> settings -> user parameters -> keyword ->choose
field label)
- Domain :
- is a low level basic component in the hierarchy
- is also repository object
- describes technical properties like data type, length, decimal places,
- it also describes the value ranges like ( single values / intervals / value table )
- conversion routine is attached at domain level
- custom domain can be created from ABAP Dictionary initial screen
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- once domain created and activated, then it can be used while creating data element
- one domain can be used in multiple data elements ( reusability )
- Custom domain creation steps :
- execute tcode : SE11
- choose domain radio button
- specify domain name begins with Y or Z
- click on create
- specify short description
- specify data type, length and value ranges
- save, check, activate
- Usage of domain
- while creating data element , specify domain name under datatype tab
- Database Table can be created in 2 ways :
Top-down Approach : Table Field -> Data Element -> Domain
Bottom-up approach : Domain -> Data Element -> Table Field
- 2 level domain concept :
one domain can be used in multiple data elements
one data element can be used in multiple table fields
- Where-Used List : is a important feature provided by SAP to consultant
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
it provides list of used objects , where ever the current object is used.
output depends on cursor position(object dependent)
kunnr domain -> kunnr data element -> kna1 table
- Domain - Definition tab : consist of Format section - specifies the internal data storage format
(how it stores in the database)
Output characteristics - provides output display properties
Sign option valid for INT4 , Dec, FLTP, CURR,QUAN data types
Lower case option valid for CHAR, NUMC data types
Conversion routine converts user display format to internal format and vice versa
Every conversion routine behind two function modules are available
CONVERSION_EXIT_<xxxxx>_INPUT - this function module converts external format to
internal
CONVERSION_EXIT_<xxxxx>_OUTPUT - this function module converts internal format to external
KUNNR domain consist of ALPHA conversion routine
SPRAS domain consist of ISOLA conversion routine
*- Domain : is set of values
value range tab is used to define either single value (or) interval values (or) value
table
Single values : also called as fixed values
while defining domain, we can also define fixed values
As a result, where ever this domain is used, this fixed values appears in F4 list
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
if user chooses a value from the list, then entry is valid, otherwise system
rejects entry
Intervals(or) ranges : we can also define interval values with lower and upper limit
this values also appears in F4 list
user must specify a value with in the available range.
*************************************************************************************
***********************
Structure : is a collection of components
is a global repository object
is a data type, defined in ABAP Dictionary initial screen
each structure component can be created with data element (or) another structure
(or) another table type
structure doesn't contain data
structure can be included in Database Table
one structure can be included in many tables(reusability)
Ex : EMARA structure included in MARA table
SI_KNA1 structure included in KNA1 table
structure creation steps :
- start tcode SE11
- choose data type radio button
- specify structure name begins with Y or Z
- click on create
- continue with structure
- specify short description
- specify component name
- provide datatype, length using data element (or) predefined type
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- in the same manner create other components
- finally save, check, activate
steps to include structure into table :
- open database table in change mode
- specify .include in fields column
- specify structure name in data element column
- press enter
- notice that structure components are included into table
*- Structure can be classified as 3 types
- Flat structure : each components created with data element (no ref types)
- Nested structure : one of the structure component is ref to another structure
- Deep structure : one of the structure component is ref to another internal table type
Note : RANGES keyword can be used to create internal table with Sign, Option, Low, High
but it doesn't generate selection screen
Table type :
- Create Global table type in ABAP Dictionary, activate
table type can be created using line type ( can be data element / structure )
specify initial value, access type, key components
finally save, check, activate
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
Deep Structure :
- create global structure in ABAP Dictionary initial screen(deep structure)
specify component name
specify its corresponding component type as above created table type
finally activate
Note : Only flat structures can be included in data base table
- Append structure : is used as table enhancement
it is recommended for built-in tables
with out interrupting , existing table structure we can additional fields at
the bottom
one table can have many append structures
append structure must be at the end
append structure is not reusable ( applicable to same table only )
is not possible for cluster and pooled tables
is implemented as special requirement
possible type of enhancement can be described by Enhancement
category
steps : open built-in table in display mode
click on append structure (application tool bar)
click on create button
specify append structure name begins with Y or Z
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
continue
specify short description
specify component name begins with YY or ZZ
specify its corresponding data element
finally save, check, activate, back
*- Difference between .include and .append
.include structure :
- it is used to include fields into table or structure
- can be included at any key (or) non key area of table
- it is not table enhancement
- it is reusable
- fields can have any name
- it is recommended for custom tables
.append structure :
- it is used to add fields to table or structure
- can only added at the bottom
- it is table enhancement
- it is not reusable
- field names should begins with YY or ZZ
- it is recommended for built-in tables
CI_INCLUDES : are customized includes
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
are special includes which are defined by SAP and implemented by customer
at customer site
where ever SAP developer is expecting additional fields from customer, there
they defined the CI_INCLUDE
- are reusable
- most of the HR tables ( Info types ) have CI_INCLUDES at the last
- are empty default, customer can add one or many fields
Type Group : is also called Type pool
is program type 'T' (not self executable)
are defined globally in ABAP Dictionary
is also repository object
custom type group name should begins with Y or Z
type group name can be up to 5 characters
each type group concern type name (or) constant name should begins with type
group_
is a collection of types and constants
are valid for all programs / global classes
In order to use global type group in program, we have to add type pools statement
in the declaration
TYPE-POOLS <typegroup>.
*-----------------------------
Input Check (or) Foreign key :
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
Requirement : If at all we want to read two database tables data, the base tables must have
relationship in the underlying database
Tables can be related (or) integrated by defining foreign key
Definition : Foreign key is a key field of other table
F.key act like interface between 2 tables
F.key may have duplicate values
Advantages : After defining F.key relationship, system automatically generates F4 help
for F.key field
F4 help consist of list of values from check table
F4 help is useful to end user while creating new entry with the help of other table
values
Field validation : if the user choose a value from the F4 list , then only record is
valid, otherwise record is invalid
Check Table : is a parent table for foreign key tables
act like base table (or) reference table for f.key tables
check table key field values automatically appears as F4 help in F.key field
F.key table : is a child table, which consist of F.key
is a dependent table on check table
pre-requisites : at least two tables
two tables status must be active
two tables must have common field
two tables have some data
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
check table key field must be defined with data element
Procedure : open foreign key table in change mode
click on entry help / check tab
place the cursor on foreign key field
click on foreign key icon
specify check table name
click on generate proposal
click on check and copy
notice the status message
notice foreign key checkbox is activated
notice check table name
activate table , notice the origin of input help
Testing : while creating new entry
notice F4 help
check field validation
Additional Theory :
F.key field is also called check field
F.key field can be a key field (or) non key field in F.key table
F.key field with Text Table :
Text table is a foreign key table which is used to maintain text
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
In order to maintain text it contains LANG field as key field
it maintains text in several languages
SMEAL ->SMEALT( text table which maintains meals text)
MARA ->MAKT ( text table which maintains material text)
Cardinality : is also called as Multiplicity
precisely defines the relationship between tables
specifies number of dependent records for each check table record
1:1
1:N
1: C
1:CN
- Finding relationship between tables :
- Where-used list
- database views
- open table and observe check tables list
- search in google pdf "table relationships by Christopher Solomon"
Hint : Check table key field name and Foreign key table f.key field name both can be same (or)
different, but both must have common technical properties
- data element may be different , domain must be same
Value Table : is defined at domain level
domain value range tab consist of value table option
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
one domain contain one value table at a time
after defining value table at domain level, where ever this domain is used system
proposes this value table name as check table
it is mainly useful while defining F.key , for automatic proposal of value table
name as check table
Working with Currency / Quantity values :
- Whenever currency values are entered, it must followed by currency key( data type CURR
must followed by CUKY ).We have to provide ref table and ref field name for CURR
field
- generating F4 help
click on entry help/ check tab
place the cursor on curr key field
click on f.key icon
continue with proposal
(Hint : WAERS data element uses WAERS domain,
this domain consist of value table as TCURC)
- Whenever quantity values are entered, it must followed by unit of measurement( data type
QUAN must followed by UNIT data type)
we have to provide ref table and ref field for QUAN field
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
Note : Fixed values only possible for data types : CHAR, NUMC,DEC,INT1,INT2,INT4.
***********************************
Conversion process :
- after activation of the table at ABAP Dictionary, same table gets created in the physical underlying
database
for few changes system accepts(field length increase) and activate successfully
but for few changes(field length decrease) at later level, system prompts for convert table
Conversion is a special process, carried out with some sequential steps
Conversion only required if alter table is not possible
conversion advantage is by retaining the data , changes can be applied
Database Utility(SE14) provides this conversion option
Activate and adjust database button is used to carry out conversion
As a result all the ABAP Dictionary changes applied to underlying table
***********************************
Indexes :
- are used to speed up search criteria
- whenever table is activated ,system automatically creates primary index on key fields
- primary index name is 0, which is unique index
- path to view indexes : utilities menu -> database object -> database utility -> indexes tab
- system creates physical table and its index in the underlying database while activation
- Index is copy and reduced fields of original table
- Index is created in sorted order
- Index is pointing to original table
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- when select query is executed , database interface uses database optimizer
- database optimizer uses index to search for relevant record
- it uses binary search (because index is arranged in sorted order)
- if the query is on key field comparison , so that result is faster
- but if the query is on non key field comparison, then result is delayed,
because non key field values are duplicate, randomly available
- if we are accessing non key field values very frequently , then we can create secondary index on non
key field
- path : open the table in display mode -> click on indexes tab -> click on create index
- specify short description
- specify field name
- finally activate
******************************************************************************
Buffering :
- buffer is temporary memory area at application layer
- every application server behind local buffers are available
- buffer data is volatile ( not fixed )
- database interface initially looks at buffer , if buffer contain data then reads from buffer
otherwise it reads from underlying database
- most of the tables default setting is buffering not allowed ( by pass buffer )
- technical settings button provides buffer options
- base on requirement we can activate buffers
- Frequently accessed, and rarely updated / written / modified tables are recommended for
buffering
- Buffering types :
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
Fully buffered : if the table is less ( <30kb), then it is recommended for full buffering.
entire table is loaded whenever we access this table
Generic Area buffered : if it is activated only generic key matching records are loaded into
buffer. generic key can be defined by specifying key fields of the table
generic key is combination of left justified key fields
client specific and language specific tables are by default generic buffered
Single Record Buffered : only single record loaded into buffer
select single statement result is single record
it is recommended if we are accessing frequently single record
- Following statements by pass SAP Table buffer :
- select ...bypassing buffer
- select for update
- select with aggregate functions
- select distinct
- select ...where is..null
- order by (except for primary key)
VIEWS : is collection of fields of related database tables
is also called imaginary table (or) temporary table (or) virtual table
basically it doesn't contain data, but it is loaded at runtime
in SAP we come across 4 types :
- Database Views
- Projection Views
- Maintenance View
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- Help View
- Database View : is a collection of data from more than one related tables
implements inner join
it reads the data from both tables based on defined join condition
join condition can be defined based on common field in both tables
selection conditions (condition based data retrieval) also possible
can be buffered like database tables
can be created in underlying database while activation
maintenance status is : Read Only
it is useful to find out relationship between tables
Steps : choose view radio button
specify view name begins with Y or Z
click on create
continue with database view
specify short description
specify table names(kna1,knb1)
select both tables
click on relationship
choose one relationship, continue
click on view fields tab
specify key fields from both tables
specify required non key fields from both tables
finally save, check, activate
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
utilities menu -> contents
Note : if database view is created on single database table ,then maintenance is possible
DB views are used in programs ,(alternative for inner join select statement)
*- difference between view and internal table :
- DB table / DB View :
- is dictionary object
- created thru navigation
- is permanent , repository object
- Internal table :
- program object
- created thru coding - syntax
- is temporary, dynamic data object
Projection View : can be created on single database table
is used to hide some data and in turn display other data
selection conditions not allowed
maintenance status : read only
*******************************************************
Maintenance View : unlike other views, it is used to maintain (read / change / insert / delete)
data on database tables
it is special view, which is used to perform above operations
it implements left outer join
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
selection conditions (condition base data retrieval) is allowed
maintenance status is Read , Change, Insert, Delete
Working with Maintenance view is 2 step procedure :
- step1 : create maintenance view
- specify view name begins with Y or Z
- click on create
- continue with maintenance view
- specify short description
- specify table name(left side table)
- click on relationship
- choose one relationship, continue
- click on view fields tab (notice that left side table fields already loaded)
- select right side table additional key fields
- select non key fields of left and right side tables
- finally save, check, activate
- step2 : table maintenance generator
utilities menu -> table maintenance generator
specify authorization group(&NC&) - it is useful to restrict other user to perform
changes on database tables
specify function group(zmview) - it holds the generated screens, it is responsible to
maintain all the changes done by the users
choose maintenance type
- one step ( system uses only overview for read, change, insert, delete operations)
- two step ( system uses overview screen for read, change, delete operation)
( system uses single screen for insert )
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- click on find screen number -> propose screen numbers
- system generated overview screen(1), single screen(2)
if standard recording routine is selected, then system maintains all the changes under
one transport request number
finally click on create button
system generates function group, includes, dialog screens...etc.,
back
Now Utilities menu -> contents
tcode SE54 - generation of table maintenance dialog
tcode SE55 - Table maintenance generation dialog : generation environment
tcode SM30 - table/view maintenance
Note : whenever custom table is created, immediate perform table maintenance generator
as a result only authorized users can maintain data
View Cluster : combines several maintenance views
tcode : SM34(system menu -> services -> table maintenance -> view cluster
maintenance)
tables involved in the maintenance must have N: M relationship
we have to create independent maintenance views first , then generate dialogs
finally combine under view cluster
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
Help View : is also used to read data from database tables and display
it implements left outer join
it is used as selection method while creating elementary search help
Note : only Database view created in the underlying database as independent object
we can only define buffer settings for DB view
system generates Select statement only for Database Views
*************************************************************************************
*******************
Search Help : is also called as
- Entry help
- F4 help
- Possible Entries list
- Possible Values list
- Hit List
- Input help
- when end user press F4 function key , system display list of values for input field
- this list is a information to end user
- user can choose a value from the list (or) based on the information user can enter
new value also
- SAP provides by default F4 help in several ways :
- DATS data type generates calendar control as F4 help
- TIMS data type generates timer control as F4 help
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- Domain Fixed values / Interval values automatically generates F4 help
- Check table / Input check / Foreign key - generates F4 help
- Explicitly (based on requirement) search help can be defined in ABAP Dictionary initial
screen
- Search help is a repository object
- Search help is replace for match code object( valid for 4.6c version )
- Search help can be classified as 2 types
- elementary search help
- collective search help
- Elementary search help :
- is used to provide F4 help for a field
- search help can be defined ,activated and tested in abap dictionary
- search help can be attached to
- database table field (using entry help / check tab)
- structure component (using entry help / check tab)
- data element ( using further characteristics tab )
- selection screen field ( At selection-screen on value-request event )
- dialog screen field (POV event)
- can be defined using selection method( data collection ) as
- Database Table ( fields from single table )
- Database View (fields from 2 tables with inner join)
- Projection View (restricted fields from single table)
- Help View( fields from 2 table with left outer join)
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
Requirement : providing F4 help to empno field of zempmaster table
Prerequisites : database table status must be active
table contain some data
table field must have data element
Procedure to create elementary search help :
- choose search help radio button
- provide search help name begins with Y or Z
- click on create
- continue with elementary search help
- specify short description
- specify database table name in selection method
- specify search help parameter name
- activate import, export checkboxes
- specify LPos, SPos values
- finally activate, test search help
Procedure to attach search help for table field
- open the database table in change mode
- click on entry help / check tab
- place the cursor on field name
- click on search help button
- specify search help name, continue
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- click on copy
- notice the status message
- notice the origin of entry help
- notice search help name
- activate table
Testing :
- while creating new entry notice the F4 help
Notes :
- search help parameter name and table field name should be same
- import is activated, to read the values based on difference patterns
- export is activated, to export the values from hit list to screen fields
- LPos specifies the current field appearing position in hit list
- SPos specifies the current field search position in the implicit system generated select statement
- Default values can be provided
- using parameter id
- using system fields
- Search help exit is used to change F4 help behavior( it is implemented by function module)
- Hot key is represented by single character, it is useful to select current elementary search help in
collective search help
- dialog box with value restriction : system first displays restricted dialog box , so that user can
implement further condition
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
*************************************************************************************
***********
Collective Search Help : is a combination of more than 1 elementary search helps
it provides extended search help
it is used to provide alternative search path to user
prerequisite : at least two elementary search helps
- each elementary search help created using help view
steps : specify collective search help name begins with Y or Z
click on create
continue with collective search help
specify short description
specify search help parameter list from both elementary search helps
specify both elementary search helps in included search help tab
select each one click on parameter assignment
finally activate, test
*************************************************************************************
****************
Dialog Programming = Screen Programming = Dynpro Programming
- Dialog screens are special screens , which are used to perform business transaction
- Dialog screens are designed in Screen Painter
- are used to accept input from user / to display output to user
- Screen Painter transaction code : SE51
- Screen painter is a development tool , which is used to design dialog screens
- Dialog screen is a collection of GUI Elements like
- text box (for label purpose)
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- input filed
- check box
- radio button
- push button
- group box(is a collection of fields)
- table control
- tabstrip control
- Advantages of working with screens :
- Easy navigation
- user friendly
- input check / validating user input
- Every dialog screen behind a special Editor , Flow Logic Editor is available
Flow logic Editor differs from ABAP Editor
Flow logic Editor code is executed by Screen Process (or) Screen Interpreter
- Module Pool Programming :
- program type 'M'
- is not self executable
- custom tcode(dialog transaction) is required to call dialog screens
- is a collection of modules
- modules are created under events
- Events used for Dialog Screens
- PBO
- PAI
- POV
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- POH
- Transaction Programming : business transaction can be performed by calling sequential screens.
Transaction have 2 phases : dialog phase and update phase
- in dialog phase : user interact with screens ( handled by dialog work process )
- in update phase : updating screens info to database table ( handled by update work
process)
Transaction is ended by Commit (or) Rollback
- Synchronous update : if user creates new record, then system updates all screens
information to database tables finally after explicit save on final screen.
after updating to database , then system prompts with success
message
- Asynchronous update : if user opened existing record for changing , then enqueue WP
performs lock first, all the changes done by the user updates immediately
into temporary tables (vb*)
finally when user ends the transaction with explicit save(commit
work) , the update work process reads information from vb* tables and
updates to original tables permanently
- Working with screen programming is 4 step procedure :
step1 : tcode - SE38 : create program with type 'M'
declare required data objects
step2 : tcode - SE51 : create screen for program
- set attributes of screen
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- design layout as per requirement, set attributes for screen fields
- maintain code in flow logic editor
step3 : tcode - SE93 : custom tcode creation
step4 : test transaction code
- Demo1 : Arithmetic operations
- tcode - se38 - create program with type M
declare n1 n2 res variables with integer data type
activate program
- tcode - se51 - specify program name and screen number , click on create
specify short description
click on layout button
- drag and design 4 text fields
- maintain name and text for each text field
- drag and design 4 push buttons
- maintain name, text, function code for each pushbutton
- click on dict/program fields icon (F6)
- specify fieldname(n1) , click get from program ,continue
- repeat for other fields also
- click on flow logic button
- uncomment module under PAI event
- create module using forward navigation
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- continue with main program
- specify the logic between module...endmodule
- save, check, activate, back
- activate flow logic editor
- tcode - SE93 - specify tcode name begins with Y or Z
click on create
specify short description
continue with dialog transaction
specify dialog program name, and screen number
finally save, check
- test dialog transaction code
Notes : when user enters tcode in command field, system checks that exist or not
if tcode exist, it calls the dialog program concern dialog screen and display
when user enter values and click on pushbutton-> it triggers PAI event->
module call happens -> values are passed from screen to program ->
at program level operation happens -> operation result passed back to screen
Values are passed from screen to program (or) program to screen if their names are
same.
SY-UCOMM is a system field which holds function code value after user interaction on
push button
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
Demo2 : DML operations
- SE38 - create program type M - declare TABLES KNA1.
- SE51 - create screen , design screen using layout
click on Dict /Program fields window
specify table name as KNA1, click on Get from Dictionary
choose required fields, continue
- SE93 - create tcode
- test tcode
Theory related to screen painter :
TABLES keyword creates work area with database name
this work area act as target area
Dialog screens can be created for
- program type 1 - executable program
- program type M - module pool program
- program type F - function group
- each program can have 9999 screens
- global declarations of program is valid for all screens
- Screen have attributes tab :
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
this attributes are applicable to entire screen
Dialog screen type :
- Normal dialog screens can be called using syntax
call screen <scrno>.
- Subscreen : are special screens used in tabstrip control
syntax to call subscreen
call subscreen <subscrarea> including <prog name> <dynpro>.
- Model dialog box : are small dialog screens which are displayed at specified co-ordinates
syntax
call screen <scrno> starting at <col> <row>
ending at <col> <row>.
- Next Screen : number specifies the next immediate screen to be called
by default next screen number is current screen number( recursive call )
PAI of current screen triggers same screen PBO
In order to navigation we have to specify the next screen number as other than
current screen number
- Cursor position : specifies default cursor position, while loading the screen
- sy-dynnr system field display current screen number
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- sy-dyngr system field display current screen group
- screen group is a collection of screens belongs to same program
- context menu : right click short cut menu
**** Layout tab :
Text Field : is used to display fixed static text
in general it is used as Field Label
it support multi lingual
we have to set name( element unique name)
text(display text)
Input field : is used to accept input from user
it act like output field also
input field name and variable name should be same
input field can be made as drop down list and drop down list with key also
Checkbox : can be created by drag and drop
provide text
it support function code
Radio button : must be created under group
at least 2 radio buttons required under one group
drag and drop 2 radio buttons, select both -> right click -> define group
function code is available to perform operation
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
Pushbutton : is used to perform operation based on user action
have name, text, fct code
Tab strip control : is a complex GUI element, which displays tab wise different information
contains only general attributes( doesn't have dictionary / program / display
attributes )
it can't be converted to other element
Group box : is used to group several elements
have name, text
Sub screen Area : is a special GUI element , which is used to call sub screens
contain only general attributes
it can't be converted to other elements
Table control : is a complex tool, which is used to display output in tabular format
Custom Control : is used in OOALV Reporting
it act like base for many container controls
Status Icon : displays icon with text
*****Elements List tab :
- consist of list of GUI elements available in Layout
- it provides elements and their attributes
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- one default GUI element exist at the last of elements list for every dialog screen
- it is named as OK
- OK field belongs to data type c, length 20
- OK field is responsible to handle user actions
- working with OK field is 3 step procedure :
- step1 : declare OK field in top include
data OK_CODE type SY-UCOMM.
- step2 : assign OK_code in element list
- step3 : use OK_code while implementing PAI event module logic
*****Flow Logic tab :
- it is flow logic editor
- it support only below keywords
- process
- module
- field
- on
- chain
- endchain
- loop
- endloop
- call
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
*- calling screen sequence :
by default screens are called as per static screen sequence defined using next screen option
static attribute can be overwritten with statement in the program
code overwrites the static attribute
- call screen <scrno>.
this syntax is used to call normal dialog screen immediately
this syntax is used to freely navigate between all normal dialog screens
all screens must belongs to same program
- set screen <scrno>.
this syntax sets control to specified screen
after processing current screen, then control transfer to specified screen
- set screen <scrno>.
leave screen.
this statements collectively transfer the control to specified screen
- instead of using above 2 statements, alternatively we can use below syntax
leave to screen <scrno>.
- Modification of screen attributes dynamically
SCREEN internal table provides different attributes to screen fields
using LOOP statement , conditionally we can set attributes dynamically
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
design time(static) attributes can be overwritten dynamically using SCREEN internal table
it can be implemented in PBO event module
- Module pool program - demonstration thru SE80
user defined module pool program name may begins with Y (or) Z
SAPMY (or) SAPMZ
to organize program source code it generates 4 includes
top include is used for global data declarations
o01 include is used to provide PBO modules code
i01 include is used to provide PAI modules code
f01 include is used to maintain all subroutines
steps : place the cursor on package
right click -> create program -> specify program name(SAPMZSCR_PROG)
activate top include checkbox, continue
system creates top include
- declare global data in top include(tables mara)
- activate
double click on program -> switch to change mode
- uncomment and create other modules(i01, o01,f01), using forward navigation
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
place the cursor on program -> right click -> create screen
-> design screen, maintain flow logic
create tcode and test
*- working with status icon
- show icon program displays all icons list
- icons is a built-in structure available in data dictionary
- step1 : declare field in top include as below (SE38)
DATA <iconfield1> TYPE ICONS-TEXT.
- step2 : design screen - drag and drop status icon
specify icon name as per top include
flow logic tab
create PBO event module
-between module ..endmodule
- call function module 'ICON_CREATE'
- pass icon name( icon_print )
- specify text
- specify icon field as importing result parameter
- save, check, activate, test
*************************************************************************************
*******
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
Menu Painter : is a development tool, which is closely integrated with ABAP Workbench
tcode : SE41
is used to design Status (or) GUI status for dialog screens
- We can design status for
- selection screen
- list screen
- dialog screen
- Status can be defined for
- program type 1
- program type M
- program type F
GUI status consist of
- pf-status and title bar
- Set pf-status is a collection of menu bar, standard tool bar, application tool bar
- Set title bar is used to create title
- Menu bar : consist of maximum 8 main menus ( 2 default system and help menus )
main menu may have 3 cascade levels
separator lines possible to separate set of activity menus
under line letter ( hot key ) possible
shortcut with Ctrl , Shift combinations possible
- Standard tool bar : also called as function keys
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
is having fixed icons
- Title bar : to identify current screen title
- Application tool bar : consist of list of icons - maximum 35 icons possible
*- Working with menu painter is 5 step procedure
-step1 : create program
-step2 : design screen using screen painter
-step3 : design menus using menu painter
-step4 : create transaction code
-step5 : test tcode
*- Status is designed under PBO event
module status_<scrno> is used to call output module
set pf status 'xxxxx' statement , is used to design status
set title bar 'xxx' statement , is used to set title
*- demo :
design status for DML operation screen
- execute tcode : SE51
- open screen in change mode
- uncomment module under PBO event
- create it using forward navigation
- uncomment set pf status and title bar
- replace xxx by meaningful names
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- double click on MYTITLE
- specify title (this screen designed by &1)
- click on all title -> activate, back
- double click on MYSTATUS
- provide short description
- continue
- expand menu bar
- specify menu as operations -> double click on it -> specify function code and its corresponding
display text
- expand function keys
- enable BACK, EXIT , CANC buttons
- expand application tool bar
- specify function code as SCR2223
- double click on it
- continue with function text
- specify function text
- icon, icon text, info text
- activate status , back
- maintain relevant logic in PAI module
- Reserved function keys :
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
F1 - system help
F3 - back
F4 - search help
F10 - select first menu item
F11 - save
F12 - cancel
- For application tool bar item (each item act as pushbutton)
- we can set static text (or) dynamic text
- function code, function text is mandatory
- icon name display icon symbol
- icon text display icon with text
- info text appears as tool tip
- Function Type :
space Normal Application function
P local GUI function (used in Tab strip Control)
S system function
T call a function
E Exit command
H internal use
- Set title bar may contain maximum 9 place holders
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
************************************************************
Field Validation (or) Input Check:
- Advantage of Dialog screen is automatic field validation
- it validates user input , if entire record is correct it accept otherwise reject it
- Automatic Input Checks can be done by SAP in several ways
- by default SAP performs field validation in different ways
- proper date format
- proper time format
- proper data type format
- required entry
- domain - fixed values / intervals
- check table (or) foreign key check
- In addition to that , we can also implement extra field validation using Field (or) Module statement
- syntax :
FIELD <f> VALUES ('val1', 'val2').
ex :
FIELD wa-carrid values('AA', 'LH).
- this syntax validates user input from single values
- syntax :
FIELD <f> BETWEEN 'val1' AND 'val2'.
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
ex :
Field wa-bukrs between 1000 and 2000.
- this syntax validates range of values
- syntax :
FIELD <f> MODULE <mod>.
- create module <mod> with forward navigation , implement validation logic
ex :
FIELD wa-werks MODULE validate_werks.
- conditional module call implemented using ON INPUT, ON-REQUEST , and unconditional module call
implemented using AT EXIT-COMMAND.
- syntax :
FIELD <f> MODULE <mod> ON INPUT
this module is called only when user enters a value other than initial value
- syntax :
FIELD <f> MODULE <mod> ON REQUEST.
this module is called only if field have some value
- CHAIN...ENDCHAIN is used to validate multiple fields as a group
- At Exit command : is used to bypass mandatory checks
it is typically associated with BACK,EXIT ,CANC buttons
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
step1 : design status , enable back, exit, cancel buttons
specify function type as E
step2 : create module under PAI event
MODULE <mod> AT EXIT-COMMAND.
create <mod> and implement code for back, exit, cancel buttons
back
activate flow logic editor
test
****************Tab strip Control :
- it is complex GUI element, which is used to display different information in different tabs
- by default tab strip contain 2 tabs , it can be extended to many tabs
- among available tabs only one tab is ever active
- in PBO while loading the screen we have to keep one tab to be open by default
upon user interaction user can switch between other tabs
- tab strip control is a collection of tab title + tab page( sub screen area) + sub screen
- Tab title is nothing but push button, we have to provide name, text, function code
- Tab page consist of empty sub screen area
- Sub screen area is another GUI element, it calls the sub screen and displays
- It calls dynamically many sub screens (reusability)
- it calls sub screens belongs to same program or other program
- Sub screen is called into sub screen area
- One sub screen can be called by many sub screen arears (reusability)
- Tab strip control can be designed as manually (or) wizard
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
in case of manual approach, we have to design and maintain code
in case of wizard, system generates screen layout and generates code
- Steps :
step1- tcode : SE38 - create program type M
- declare tab strip control using below syntax
CONTROLS <tabstrp> TYPE TABSTRIP.
- declare variable to call sub screen
CXTAB is a built-in type group
SCXTAB_TABSTRIP is a built in structure
it consist of component as Active tab , which specifies the current active tab
step2 - tcode : SE51 - create screen for program
- design layout
- drag and drop tab strip control
- name tab strip control ( as per declaration )
- for each tab title provide name, text, function code
- drag and drop one sub screen area into tab strip control
- provide name for sub screen area
- provide the same sub screen area name as reference to other tabs
- switch to flow logic tab
- uncomment and create PBO event module
- specify which tab to be displayed by default while loading the screen
- activate , back
- specify call statement with below syntax :
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
CALL SUBSCREEN <sub screen area> INCLUDING <program> <screen no>.
- uncomment and create PAI event module
- specify the logic to call respective sub screen based on user selection
- activate, back
- specify call statement again :
CALL SUBSCREEN <sub screen area>.
activate flow logic editor
- create 200, 300 sub screens, activate it
- step3 - tcode : SE93 - create dialog transaction
- step4 - test transaction
Based on Scrolling tab strip can be designed in 2 ways :
- Local GUI scrolling :
- memory allocated to tab strip from presentation server
- each tab is defined with independent sub screen area
- independent call sub screen statements required to call individual sub screen
- each tab of tab strip must be assigned with function type as P
- Application Scrolling :
- memory allocated to tab strip from application server
TAW10_2 Certification Notes Prepared by A.V.Krishna , SAP Certified Consultant & Trainer
- all tabs are using common sub screen area
- one call sub screen statement is enough to call sub screens
- tab title concern function type should be space
TAW11_Notes prepared by AV.Krishna , SAP Certified Consultant & Trainer
- ABAP mainly used for Reporting purpose
- in ABAP reporting is possible
Classical List -> Interactive List -> Procedural ALV -> OOALV
- Limitations of Classical reporting is overcome by ALV reporting
- ALV : ABAP List Viewer (SAP LIST VIEWER)
- it is new reporting technique used by companies recently
- Procedural ALV : can be generated using Type group(SLIS) and function modules(
Reuse_alv)
- OOALV : can be generated using Global Classes and Methods
- Advantages of ALV :
- it save lot of time of ABAP consultant , in order to format output screen
- it provides lot of features to end users, without changing program code and without
having programming knowledge , user can carry out several operations
- ALV output displays special generic functions tool bar, which consist of options like
- sorting (ascending / descending)
- filter ( display required range of values )
- sum ( grand total/sub total )
- change layout (hide / display columns)
- export output to several formats like
- notepad
- word
- excel
- HTML
TAW11_Notes prepared by AV.Krishna , SAP Certified Consultant & Trainer
- ALV output displays : automatic column headings(top-of-page event not
required)
key fields background color differs
all columns output display possible at a time
automatic column width
- Possible types of procedural ALV reports
- Simple ALV list (display all columns output)
- Simple ALV grid
- Fieldcat ALV list(display particular columns output)
- Fieldcat ALV grid
- Fieldcatalog merge ALV list(display two table columns output)
- Fieldcatalog merge ALV grid
- ALV event list(providing heading thru event)
- ALV event grid
- ALV block list(display output in vertical blocks)
- ALV hierarchical list(display hierarchical output)
- ALV interactive list(display basic list -> generate secondary list)
- ALV interactive grid
- Possible types of OOALV reports :
- Simple ALV grid (display all columns output)
- Fieldcat ALV grid(display particular columns output)
- Fieldcatalog merge ALV grid(display two table columns output)
- ALV event grid(providing heading thru event)
TAW11_Notes prepared by AV.Krishna , SAP Certified Consultant & Trainer
- ALV interactive grid(display basic list -> generate secondary list)
Theory : OOALV report final output will be displayed using dialog screen
Screen painter have one GUI element as custom control is used to display
output
custom control act as container control
ALV grid output dislayed using container control
CFW - Control Framework is a collection of many Enjoy controls
OOALV reports are displayed by using control framework control
For each control , SAP developed one global wrapper class
- some containers list
- custom container
- docking container
- split container
- easy splitter container
- dialog box container
CL_GUI_CUSTOM_CONTAINER is a built-in global class, which consist of
attributes, methods, events related to custom container.
In order to work with this class, we have to supply container name ( as per
constructor signature )
CL_GUI_ALV_GRID is a another built-in global class, which consist of attributes,
methods ,events realted to grid output
TAW11_Notes prepared by AV.Krishna , SAP Certified Consultant & Trainer
In order to work with this class, we have to supply parent container instance(as
per constructor signature)
method set_table_for_first_display is used to send formatted output to control
this method is used to display final output
*- Demo 1 : Simple ALV Grid Report : it displays all columns output
step1 : tcode - SE38 -
specify program name begins with Y or Z
click on create - type 1 - save as local object
- declare one ref variable to container class
- declare one ref variable to grid class
- declare internal table and work area
- populate internal table using select statement
- specify call screen statement, create 100 dialog screen with forward
navigation
step2 : tcode - SE51
- specify short description
- click on layout button
- drag and design custom control icon
- name custom control as CCONTAINER
- click on flow logic tab
- uncomment module under PBO event, create it thru forward navigation
- check if container object status , if it is initial, then create container instance,
pass our container name CCONTAINER
- create instance for grid class, pass above created container instance as
parent
- finally call method set_table_for_first_display thru grid instance
TAW11_Notes prepared by AV.Krishna , SAP Certified Consultant & Trainer
pass structure name , internal table name
(structure specifies how to display
internal table specifies what to display)
- uncomment pf-status , create status , enable back, exit, canc buttons
- uncomment PAI event module, create it thru forward navigation,
specify code for back, exit, canc buttons
- finally activate flow logic editor
- back
Step3 : test program
*****************************************
Demo2 : ALV Fieldcat grid report : this report displays only particular required columns
output in final output
Fieldcat internal table is useful
- to display required fields in the output
- to format output as per customer requirement
- must be declared with LVC_T_FCAT table type
- its corresponding work area must be declared with LVC_S_FCAT line
type
- fieldcat can be build in several ways :
- manually
- calling function module (automatically)
- in case of manually , we have to fill work area first , then append work
area to internal table next
steps : - tcode- SE38 - create executable program,
TAW11_Notes prepared by AV.Krishna , SAP Certified Consultant & Trainer
declare internal table line type
declare internal table and work area using above line type
declare field cat internal table and work area
declare ref variables to container and grid class
populate internal table thru select statement
create 100 dialog screen by call screen statement
- tcode - SE51 - create screen and layout
- PBO event module
- create instance for container class
- create instance for grid class
- build fieldcat internal table manually
- call method to display output
- activate , back
- activate flow logic editor
- test program
Demo3 : ALV Fieldcatalog merge report
this report is used to display two database tables columns output
database tables must have relationship in the database
SAP provided built-in function module LVC_FIELDCATALOG_MERGE, is used to
prepare fieldcatog for 2 table fields
this function module imports global structure defined in ABAP Dictionary with 2
table fields and merges (prepare) returns the changed field catalog
TAW11_Notes prepared by AV.Krishna , SAP Certified Consultant & Trainer
Demo4 : ALV event grid report :
- print_top_of_list event provides list header information
- in program declare local class as handler class
- declare handler method and implement it
- declare one ref variable to global trigger class
- declare another ref variable to local handler class
- create screen and design
- in flow logic tab , create instances, call method to display output
- create instance for local trigger class
- specify set handler statement (registry)
Demo5 : ALV interactive grid report :
this report displays basic required information on basic list, after user
interaction(double click) it displays its corresponding details in secondary list.
CL_GUI_ALV_GRID class having DOUBLE_CLICK event, when this event triggers it
exports
row no, column name, numeric row id
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
OOABAP :
- is also called as ABAP Objects / ABAPOO
- implementing C++ and Java features in ABAP is called as
ABAP objects
- is extension to classic ABAP
- it supports both syntaxes
- object based programming languages : vb script & java script (
doesn't support inheritance,
polymorphism)
- object oriented programming languages : C++, Java, .NET,
ABAP
- release 4.0 onwards object orientation is introduces in ABAP
- It is a programming technique , implemented using classes,
methods, objects...etc.,
- Advantages :
- Abstraction (protecting data)
- Encapsulation (hiding data)
- Inheritance ( reusability )
- Polymorphism (common behavior in all classes)
- Exact way of implementing Real world scenarios
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Easy way of implementing complex business process
- it redefines the modularity
- it extends the reusability
- it reduces the maintenance effort
- it improves program structure
- Classic ABAP
- declarations using TYPE (or) LIKE additions
- supports internal table old & new syntaxes
- procedures : subroutine, function module
- classic exception handling using sy-subrc
- Reports : procedural ALV report
- procedural enhancement technique : Customer exit and User
exit
- data flow diagrams (SAD)
- ABAP objects
- declarations using TYPE REF TO addition
- supports internal table new syntax only
- procedure : method
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- object oriented exception handing using try....endtry block
- Reports : OOALV report
- oo enhancement technique : BAdIs
- UML diagrams(OOAD)
- BAPI
- Workflow
- BSP
- WebDynpro
- CRM Technical
- SRM Technical
*- New Terminology used in ABAP Objects :
- CLASS : is a definition (or) blueprint (or) template for objects
is a collection members like
- attributes
- methods
- events
every class must have visibility scope
visibility scope represented using visibility sections
visibility scope controls the scope of accessing class
components
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
visibility scope can be
- public section : components visible to all, any class
object can access it
- protected section : components can only accessed
by same class and its sub
class
- private section : components can only accessed
same class
- no default visibility section in abap
class can be created as 2 ways
Local Class : is defined and implemented with in ABAP
executable program
scope is local
Global Class : is defined and implemented in class
builder
scope is global
Syntax to declare local class
CLASS <cls> DEFINITION.
----<visibility section>----
----<declare attributes>----.
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
----<declare methods>----
----<declare events>----
ENDCLASS.
Syntax to implement local class
CLASS <cls> IMPLEMENTATION.
---<methods implementation>----.
ENDCLASS.
OBJECT : is a part of program source code
technically object is instance of class
creating object to class is called as Instantiation
creating multiple objects to class is called as Multiple
Instantiation
reference variable is required to create instance
syntax to declare reference variable
DATA <rvar> TYPE REF TO <class>.
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
ref variable is null pointer, which is not pointing to
anything initially
it is declared with ref to existing local (or) global class
syntax to create object .
CREATE OBJECT <rvar>.
this syntax creates object in memory.
memory is allocated to ref variable
ref variable name , object name should be same
object is used to access class components
dynamically
At runtime object
- state is described by Attributes of class
- behavior (or) functionality is described by
Methods of class
- identity described by Events of class
- Method : is a object oriented procedure
have unique name and unique functionality
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- 5 Steps to work with Local Class
- step1 : declare class
- step2 : implement class
- step3 : declare ref variable
START-OF-SELECTION.
- step4 : instance creation
- step5 : calling method thru instance
Notes : local class name should begins with lcl_
user defined global class name should begins with zcl_
every class must have visibility sections
every class must have definition part then followed by
implementation part
class implementation consist of only methods
implementation
all declared methods must be implemented in class
implementation
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
if the class have only attributes , then implementation is
optional
objects must be created , to work with class components
ref variable must be declared before object creation
START-OF-SELECTION is a default event for classical
abap program
but in ABAP objects , we have to specify START-OF-
SELECTION explicitly.
actual program execution starts after event.
- after class implementation generation statements are
not executed
- if we keep class implementation at the bottom of the
program, then START-OF-SELECTION is optional
- Working with Global class is 5 step procedure :
step1 : declare class in class builder(SE24)
step2 : implement class in class builder(SE24)
step3 : declare ref variable in program(SE38)
START-OF-SELECTION.
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
step4 : instance creation(SE38) using pattern
step5 : calling methods thru instance(SE38) using pattern
Demo2 : Working with Internal Tables using local class program
Working with internal tables with global class :
- tcode - SE24
- specify class name starting with zcl_itab
- click on create, provide short description
- save as local object
- click on local definitions button -> click on private section
declare line type and declare table type as below
TYPES : begin of ty_kna1,
kunnr type kna1-kunnr,
land1 type kna1-land1,
name1 type kna1-name1,
end of ty_kna1,
t_kna1 type table of ty_kna1.
- click on attributes tab:
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
ITAB instance attribute private t_kna1
WA instance attribute private ty_kna1
- click on methods tab :
get_data instance method public
disp_data instance method public
- implement both methods, specify select statement in get_data
method
specify loop statement in disp_data
method
- finallay activate class and test class
- tcode : SE38
- create executable program
- declare ref variable with ref to global class
- create instance
- call methods
******************************************************
Working with methods :
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- methods are declared while class declaration
METHODS : <meth1> , <meth2>.
- methods are implemented while class implementation
method <meth1>.
----<statements>---.
endmethod
- Every method have unique name
- All the declared methods must have implementation
- methods describes object behavior (or) functionality at runtime
- methods are used to perform operations also
- in order to perform operation, method must be declared with
signature
- signature is method dependent
- signature is optional
- signature may consist of importing, exporting, changing,
returning as formal parameters
may consist of exceptions also
- syntax to declare method along with signature :
methods: <meth> importing <iv> type <data type>
exporting <ev> type <data type>
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
changing <cv> type <data type>
returning value(rv) type <data type>
exceptions <exp1>. "classic exception
raising <exception class>. "class based exception
- the parameters defined along with method is called as formal
parameters
- the parameters which are passed with call method statement
are called as actual parameters
- formal and actual parameters concern data type and number
should be same
- when exporting and changing are used, we should not use
returning
- returning parameter must be declared with value addition
- syntax of call statement :
CALL METHOD <instance>-><method>
exporting
<fp> = <ap>
importing
<fp> = <ap>
changing
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
<fp> = <ap>
receiving
<fp> = <ap>.
- Possible type of operations :
- Pass by ref
- Pass by value
- Pass by value and result
- in case of pass by ref formal parameters are declared with out
VALUE keyword
methods : <method> importing n1.
- in case of pass by value formal parameters are declared with
VALUE keyword with default value
methods : <method> importing value(n1) default 10.
- in case of pass by value and result formal parameters are
declared with CHANGING with VALUE keyword
methods : <method> changing value(n1) default 20.
********************CLASS Components
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Attributes : describes the data (state) of object at runtime
can be classified as 2 types
Instance Attributes : are declared by DATA keyword
can be accessed by using
instance only
describes the instance specific
state
exist (available) per each instance
Static Attributes : also called as class attributes
can be declared by CLASS-DATA
keyword
can be accessed by instance (or)
class
describes the static level state
exist (available) only per class
TYPES declarations, CONSTANTS
declarations also static attributes
if the attribute is declared with READ-ONLY addition,
then it can only read by other class instance, modification is not
allowed at subclass level
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Methods : describes the functionality (or) behavior of instance
(or) class
can be classified as 2 types
Instance method : are declared by METHODS
keyword
describes the behavior of instance
at runtime
can be called by instance only
-can access all attributes of class ,
can call all methods of class, can trigger all
events of class
Static Methods : also called as Class method
are declared by CLASS-METHODS
keyword
describes the behavior of class
can be called by both instance (or)
class
- can access only static attribute,
can call only static method, can only
trigger static event
- Events : describes the status of object (or) class
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- based on response of the object, object can be
identified ,which class it belongs
object response to other object interaction
response happens after triggering event
- can be classified as 2 types
Instance Events : are declared by EVENTS keyword
describes the status of instance at
runtime
can be triggered by instance method
only
Static Events : also called as Class Events
are declared by CLASS-EVENTS
keyword
describes the status of class
can only be triggered by instance
method or static method
*- Accessing Attributes of Class :
syntax to access instance attribute :
<instance>-><instance attribute>.
Ex :
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
obj->n1.
syntax to access static attribute :
Ex :
c1=>num1.
obj->num1. "accessing static attribute thru instance also
possible
*- Calling methods of Class :
syntax to call instance method :
call method <instance>-><instance method>.
ex :
call method obj->m1.
syntax to call static method :
call method <class>=><static method>.
ex :
call method c1=>method1.
call method obj->method1. "calling static attribute thru
instance also possible
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
Exploring Attributes :
- Attributes can be declared with predefined type (or) local types
(or) global types
- Attributes can be declared as - Instance attribute / Static
Attribute / Constants
- Attributes can be made as Read only also
- Read-only addition only allowed for public attributes only
- Attributes can be defined under public, protected, private
sections
- Attributes can be declared with TYPE addition
with LIKE addition (ref to existing
attribute)
with TYPE REF TO addition (ref to
other class / interface)
- Attributes can be printed thru write statement
- Attributes can be printed thru any one of the method also
- Attributes can be assigned to method signatures
************
Exploring Methods :
- Instance method
- Static method
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Functional Method
- Instance constructor
- Static constructor
- self defined method (ME)
- event handler method
- Factory method
*- difference between instance components and static
components
Instance components :
- exist per instance (every instance level)
- can be accessed by only instance
- accessed using single arrow ->
Static components :
- exist per class (only at class level)
- can be accessed by both instance and class
- accessed using double arrow =>
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
*---Constructor : is a special method, which is automatic called as
soon as object is created
can't be called explicitly using call method (
implicit call )
can be classified as Instance and Static Constructor
Instance Constructor :
- always named as CONSTRUCTOR
- must be placed in public area
- only one instance constructor allowed per
class
- have signature with import parameters and
exceptions
- the first method called among methods
- declared by METHODS keyword
Static Constructor :
- always named as CLASS_CONSTRUCTOR
- must be placed in public area
- only one static constructor allowed per
class
- doesn't have signature
- is called before instance constructor
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- declared by CLASS-METHODS keywords
Advantage of constructor :
- allocating initial resources to class
- changing static attributes values
- initialize attributes that are not assigned by value addition
- can inform other objects about the object creation
ME :
- is a predefined self reference method
- is always named as ME only
- with out declaring this method, we can use it for accessing
attributes and calling methods
- but it can only used with in the method implementation,
- it can't be called outside directly
**************
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
UML : Unified Modelling Language
is used to graphical representation of object oriented
programming process
was developed by Object Management Group
- Class Diagram : specifies the relationship between
classes
- Association : specifying relationship with
dependent cardinality , relationship symbol, association
class
- can be 2 types
- multiple association (1->n)
- recursive association(1->1)
- can be 2 types based on dependency
- Aggregation : is special association, whole
part dependency, empty rhombus
- Composition : is special aggration, whole
part existing dependency, filled
rhombus
- can be 2 types based on inheritance
relationship
- Generalization : up arrow, generic access
- specialization : down arrow , spcific access
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Behavior diagrams : are related to object behavior
- sequence diagram
- delegation with sequence diagram
- Component diagrams : shows the organization and
dependencies
- UML diagram represents
+ symbol for public components
- symbol for private components
_ symbol for static components
# symbol for protected components
- ref variables of class can be declared with type ref to addition
(or) like addition
initially all ref variables are null reference
when object is assigned to ref variable , then ref variable
becomes object for same class
existing object reference address is assigned to new ref variable
<ref var> = <object>.
- multiple ref variables can be declared for one class
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- after instance creation each object have its unique memory
address
- pointer internal table is a special internal table , which is used to
maintain reference address of several instance of one class
it maintains all objects references as line by line
it is useful to simplify administration of several instances
- this special internal table declared with special syntax :
DATA <itab> TYPE TABLE OF REF TO <class>.
- this internal table only supports
- append statement
- loop statement
- read statement
- this internal table only contain one built-in psudo column as
TABLE_LINE
- Functional Methods : are special methods which consist of one
returning parameter
it may have importing and exceptions
it may have many exporting and changing
parameters
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
call statement must have receiving parameter (explicit call)
it is called implicitly to perform operations like
- to specify logical expressions
- to perform arithametic operations
- case conditions
**********************************************************
Working with Events :
Events : describes the status of object at runtime
describes unique identification of object
triggered when object status change (or) when object
reached to complete status
Working with Events is 4 step procedure :
- step1 : declare events while trigger class declaration
syntax :
EVENTS : <evnt1>.
- step2 : trigger events while trigger class implementation
syntax :
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
RAISE EVENT <evnt1>.
- step3 : declare event handler method in handler class :
syntax :
METHODS : <on_event1> FOR EVENT <evnt1> OF
<trigger class>.
- step4 : registering event hander method
SET HANDLER <handle cls_obj>-><handler method>
FOR <trigger class obj>.
Theory :
- trigger class concern any one of the method is responsible to
trigger event of same class
- when trigger class instance thru event is triggered , based on
registry control transfer to handle class / handler
classes
- trigger class can be one and handler class can be one or many
- registry is must to transfer the control to handler classes
- both trigger class instance and handler class instance both are
connected at runtime
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- SET handler statement act like connecting between both
classes instances
- to register instance event , SET handler statement consist of
FOR ALL INSTANCES addition
- to register static event, SET handler statement doesn't contain
FOR addition ( because static event can be triggered
class using static method also )
- handler class consist of event handler method declaration
- event handler methods are special methods, which are declared
to handle other class events
- event handler methods are declared with special syntax
- event handler methods generally not called by call method
statement
- Events can also be declared with exporting addition
- when event triggered it exports declared parameter value
- exporting parameters must be declared with VALUE addition (
pass by value )
- syntax :
EVENTS : <evnt> EXPORTING value(ev) type <data type>.
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Accordingly RAISE event have exporting addition
RAISE EVENT <event> EXPORTING <ev> = <var>.
- Accordingly event handle method declaration have IMPORTING
addition
METHODS : <on_event> FOR EVENT <event> OF <class>
IMPORTING <var>.
*- Working with global class events :
SE24 - define global class
- declare methods in methods tab
- declare events in events tab
- implement methods
- activate class
SE38 - create program
- declare handler local class , declare handler method
- implement handler method
- declare one ref to global trigger class
- declare another ref to local handler class
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- create instances
- specify set handler statement ( registry )
- call trigger class method
*- working with 2 global class - event
- first global class act like trigger class
- second global class act like handler class
- program thru calling
***************************************************************************
Object Oriented Features :
- Encapsulation : classic abap supports encapsulation concept
thru function group
function group global data is protected, it can
only be accessed by any one of the function module.
Multiple instantiation is not possible thru function
group
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
In object orientation we can create several
objects for one class(multiple instantiation is possible)
object unites data and function(method)
class components are protected by defining
visibility sections
class components can't be accessed with out
creating instance
- Inheritance : is important feature of object orientation
defines the relationship between classes
advantage : is avoiding redundant declarations
reusability of super class components
when two classes involved in inheritance , one
class act like parent class, other one is child class
super class public and protected components are
by default inherited to subclass , except private
class components
super class is a parent class , its components are
inherited to subclass
sub class is a child class, which inherits
components from super class
ABAP Objects - class concept support Single and
Multilevel inheritance
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Interface concept support Multiple inheritance
subclass can be defined with syntax :
class <cls> definition inheriting from <super class>.
subclass can have components like
- inherited from super class components
- inherited and redefined components
- new declarations
subclass can redefine the super class method
redefine is a concept, where re implementing super
class method in sub class
super class doesn't have final addition, then only it can be
inherited to subclass
always sub class is final class.
inheritance is not possible from final class
*- Polymorphism : it is implemented as a special feature of
inheritance
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
it is recommended to implement most generic
functionality
identical named method behave differently in
different classes
same method response differs from class to
class
Notes : Inheritance is one side relationship
changes of super class can have immediate on sub class
super class is not aware of sub classes
sub class is dependent on super class (white box reuse)
if the super class method is inherited into subclass, it can
re implemented in subclass with out changing signature(
with the super class method signature is used to re implement
)
it differs in case of constructor
every class can have its own independent constructor ,
regardless of super class
if object is created for sub class , system immediately looks
for super class constructor, sub class object creation
statement supplying values to super class constructor
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
Static methods can't be redefined in sub class
priority of calling methods : super class static constructor ->
super class instance constructor -> sub class static
constructor -> sub class instance constructor -
(whenever sub class is accessed first time - as soon as
object created for sub class)
*- In order to increase the scope of ref variables, then casting
between ref variables is required
Up-cast : is also called as Widening cast
up-cast operator is =
in case of up-cast the sub class instances are created
first, then all sub class instances are assigned to super
class instance
it is mainly useful for generic access (generalization)
the client (or) customer wants all sub classes
information then he uses super class only (super class
contains references of sub classes)
After up-cast super class instance can access inherited
components + inherited and redefined components of sub
class
Down-cast : is also called as Narrowing cast
down-cast operator is move ..to (or) ?=
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
always down-cast happens after up-cast
in case of down cast we are reassigning super
class instance back to sub class again
it is mainly useful to specific access(specialization)
the customer who are interested specific features
of sub class, then they approach sub class only
some times downcast operation may leads to
runtime error
to avoid runtime error, we have to implement
downcast with in try...endtry block
if assignment fails, then system raises
CX_SY_MOVE_CAST_ERROR exception
***************************************************************
Interface : interface extends the scope of class
interface consist of only definition part, no
implementation
interface doesn't have visibility sections, by default all
components act as public only
common services required for more than one class can
be kept at interface level
user uses interface services regardless of their
implementation ( uniform access )
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
Interface consist of another interfaces, attributes,
methods, events..etc.,
Interface methods are implemented in class
one interface methods can be implemented in several
classes ( reusability )
implementation differs from class to class
in order to implement interface components, first
interface must be introduced in the public section. INTERFACES
keyword is used to declare interface with in the class
while implementing class, interface method can be
implemented
syntax :
method <interface>~<method>.
------<statements>-----.
endmethod.
Interface supports multiple inheritance, a class can
inherit components from more than one interface
Interface can be created as 2 ways :
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- local interface : is defined and implemented with in the
abap program
scope is local
begins with lif_
- global interface : is defined and implemented in class
builder
scope is global
begins with zif_
- syntax to declare local interface :
INTERFACE <intf>.
------<attribute declarations>----.
------<methods declarations>----.
------<events declarations>----.
ENDINTERFACE.
*- working with local interface is 6 step procedure :
- declare interface
- declare class
- implement class
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- declare ref variable for class
start-of-selection.
- create instance for class
- call interface method thru class instance
*- working with global interface is 6 step procedure :
- tcode - SE24 - create global interface - declare method
specify interface name begins with zif_demo
click on create, short description
declare method in methods tab
activate interface, back
- tcode : SE24 - create global class - implement interface
method
specify class name begins with zcl_demo
click on create, short description,
click on interfaces tab, specify global interface name,
click on methods tab, implement interface method,
activate class, back
- tcode : SE38 - create executable program
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
declare ref variable for global class
create object thru pattern
call interface method thru class instance
Note : Up-cast using interface :
- create instance for class
- assign class instance to interface ref variable (up-cast)
- call interface method thru interface instance
Hint : direct instantiation to interface is not allowed
~ is interface resolution operator
to differentiate methods from different interface, we can use
aliases also
******************************************
Class builder :
- tcode : SE24
- is development tool , which is integrated with ABAP workbench
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- it is used to develop object types as - global class and global
interfaces
- SAP defined global class begins CL_
- User defined global class begins with Ycl_ (or) Zcl_
- SAP defined global interfaces begins with IF_
- User defined global interfaces begins with Yif_ (or) Zif_
- the class which is defined in class builder belongs to program
type 'K'
- the interface which is defined in class builder belongs to
program type 'J'
- Global interface :
- doesn't have visibility sections
- can have another global interfaces also
- but it can't use super class
- it can't have friends
- it doesn't have final checkbox
- it act like abstract class (direct instantiation is not possible)
- methods can't be implemented
- events can't be triggered
- doesn't test environment
- doesn't have constructor and static constructor
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Global Class :
- class can have immediate one super class, but it may have
many interfaces
- it can grant friendship to other class / interface
- it can be final (or) not final
- it can implement super class methods (or) interface methods
- it can trigger class events (or) interface events
- it have test environment
- it contain visibility sections
- it have constructor and static constructor
- class can be created as
- usual class
- exception class
- persistent class
- test class
Procedure to import local class to global class :
- tcode : SE24
- object type menu ->import -> local class in program
- specify program name
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- activate includes, overwrite existing classes
- press enter
- specify class name begins with Y or Z
- select class
- click on import icon
- save as local object
*********************************************
Object oriented design patterns :
- Abstract class :
while defining local class we can ABSTRACT addition, then it is
abstract class
- it can't be instantiated (while inheriting into subclass, we can
redefine and work with abstract class
components)
- we can make method also as ABSTRACT
- while inheriting into sub class abstract method can be
redefined
- Final class :
- if a class have FINAL keyword addition, it can't be inherited to
sub classes
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- if a method have FINAL addition, it can't be redefined in sub
classes
- in general constructor can be placed under public section
as per NetWeaver 7.0 release onwards, constructor can also be
placed in protected and private sections
- while defining class add
CREATE PUBLIC addition to declare constructor in public
section
CREATE PROTECTED addition to declare constructor in
protected section
CREAE PRIVATE addition to declare constructor in private
section
- in case of global class, properties tab , consist of Instantiation
option
- Factory Method :
- are special static methods declared under public section
- are useful to create instance in enhancement exit technique,
it creates instance for badi interface.
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
Ex : CL_EXITHANDLER class consist of GET_INSTANCE as
factory method
- one class can have many factory methods
- each factory method can have different signature and different
functionality
- are useful to simplify administration of several objects created
for same class (using private section internal table )
- certain checks can be carried out before creating instance
- using factory methods we can implement condition based
instance creation
it is useful to avoid creating multiple instances for same class
Singleton Concept : is used to avoid creating multiple instances
is useful to create single instance
Factory method also used to create single
instance
- when class is loaded system executes static constructor -> then
checks factory method ->instance creation -> instance constructor
-> calling other methods thru instance
Friends Concept :
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- in general private section components are not accessible
outside
- exception to that is friends concept
- A class can grant friendship to another class
- other class can access private section components of granting
class
- friendship is one side relationship
- A class can grant friendship for another class (or) interface
- to grant frienship a class must be defined with CREATE
PRIVATE FRIENDS <class>.
- in case of global class Friends tab is used
*- Shared Objects :
- are useful to share common information available in shared
objects memory
- shared memory is a common memory , used by all work
process at application server
- shared memory consist of shared objects memory
- shared objects memory is a collection of shared areas
- shared area consist of area instances
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Area instances can have versions
- shared objects is useful to run e-commerce applications by
SAP users
- shared objects provides concurrency access by providing lock
mechanism
- publisher can write information to shared objects, then it is
available to other users
- other users can read it and order it
- SHMA : tcode to create Shared objects memory area
- is used to create shared memory area
- with the same class name system creates root class
- area is a global class , which is having static methods like
attach_for_write, attach_for_read.
another instance method as set_root exports root object , it is
useful to set root object
public instance attribute root is already declared for root class
- in order to work with shared memory area , we have to create
area instance first
- another global class cl_shm_root class , which is shared
memory enabled
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
it consist of one attribute to declared as ref variable to catalog
class(go_catalog)
this class can be accessed by creating object as go_root
go_catalog is used to read or write to catalog class
- another global class cl_shm_catalog class, which consist of
internal table to hold catalog information two methods are
used to write and read
fill_catalog is used to write catalog information to internal table
get_connections is used to
read catalog information from internal
table
***************************************************************************
***************
Exception Handling :
- if system executes program (or) function module (or) method
successfully meaning there is no static error (or) no dynamic
error
- some times while executing certain statements system can't
proceed further, it that case system leads to runtime error ,
runtime error result is displayed in short dump screen
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
runtime errors are handled by exceptions
exceptions are handled by messages
- procedural exception handling happens thru sy-subrc system
field
if system raises exception it fills the sy-subrc value as non-zero
- object oriented exceptions are handled by global exception
classes
SAP already planned and developed built-in exception classes
SAP defined exception classes begins with CX_SY
User defined global exception class should begins with Ycx_sy
(or) Zcx_sy
local exception class can also created and implemented in abap
program
local exception class name should begins lcx_
- Working with Exception handling is 4 step procedure :
- create global exception class
- create object for exception class by raising exception
- raise and catch and handle exception
- propagate exception
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- All exception class are inherited from root class CX_ROOT
- CX_ROOT uses global interface as IF_MESSAGE
- IF_MESSAGE is a built-in global interface which consist of
get_text method
- CX_ROOT class having attributes like text id, kernel_errid,
previous
having method as get_source_position( ) -
provides error trigger location
- some global classes inherited from
- CX_NO_CHECK
- CX_STATIC_CHECK
- CX_DYNAMIC_CHECK
- when user defined global exception class is created , it is
automatically created under subclass of
CX_STATIC_CHECK
- TRY...ENDTRY : is structure (or) block is used raise and handle
exception
in general TRY statement followed by some statements to be
checked
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
if system raises raise exception, then it looks for immediate
catch statement
CATCH statement followed by global exceptions can be
specified
CATCH statement creates object for exception class
many exception classes can be specified as hierarchy
if no CATCH statement executed finally system uses clean
up block
- Steps to create custom global exception class
- execute tcode : SE24
- specify exception class name begins with zcx_sy
- click on create ( automatically inherits from
cx_sy_static_check)
- notice that message class is activated
- notice the text tab ( only available for global exception classes )
- text tab is used to define exception id
- exception id can be defined with short text (or) long text
- while defining text we can make use message class message
numbers
- we can keep place holders also - which is filled later
- this exception id can be set as default import parameter of
constructor
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- creating object for exception class
- declare ref variable to exception class
create object statement creates instance for exception
class
(or)
Catch statement creates object
CATCH <global exception class> INTO <ref_var>.
(or)
RAISE EXCEPTION <ref_var>.
- declare and raise exception with one statement
RASIE EXCEPTION TYPE <exception_class>
exporting
textid =.
- Propagation : it deals after raising exception and how to handle
exception
propagation1 : when object is created , system calls constructor,
constructor raise exception
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
constructor signature must have raising
<exception>.
control transfer to CATCH statement ( main
program )
propagation2 : after constructor call , it calls another method
another method is raising exception
control transfer CATCH statement ( main
program )
RETRY statement : is used to execute exception once again
after CATCH statement remove the cause of
exception
specify RETRY statement, then control
transfer to TRY block again
and executes once again
RESUME statement : constructor is calling another method
another method raise exception
control transfer main program CATCH
statement
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
CATCH statement is mentioned BEFORE
UNWIND
-immediately check is_resumable value is
'X'
-then specify RESUME statement
-control transfer another method , the
statements after raise statement gets executed
pre-requisite : both constructor and other
method signature must be declared
as resumable exception
Previous : attribute is used to map between two exception objects
************Dynamic Programming :
- Field Symbols :
- is a place holder for data objects
- basically it doesn't occupy memory, but based on assignment ,
it points value of data object
- implements de reference pointer concept of C language
- are mainly used in dynamic programming
- syntax to declare field symbol :
FIELD-SYMBOLS : <FS>.
- FS is name of field symbols
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- angle brackets are part of syntax
- syntax to assign variable to field symbol :
ASSIGN <data object> TO <FS>.
- now <FS> points to the value of data object at runtime
- it automatically adopts the data type, and length of the
assigned data objects
- we can assign variable, structure, internal table to field symbol
- we can assign work area (or) internal table to field symbol
- loop at itab into wa.
loop at itab assigning <FS>.
- <FS> must be declared with structure ( to avoid data type
conflict )
- Field symbols can be declared with TYPE addition also
FIELD-SYMBOLS : <FS> type <global structure>.
- generic data types in ABAP : ANY, DATA ,OBJECT
- field symbols can be declared with generic data type also
- it dynamically adopt the data type, it is useful for flexible
programming
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- FIELD-SYMBOLS : <fs> TYPE any.
- ASSIGN statement can have CASTING addition
- we can assign one field symbol to another field symbol
- second field symbol adopts the technical properties of first field
symbol
- if both have different data types, CASTING addition is required
- CLEAR statement initializes field symbol value
- CLEAR <fs>.
- IS ASSIGNED is used as a logical query to check field symbol
status
- UNASSIGN statement to revoke the assignment
- field symbol can be declared with structure addition
field-symbols <FS> structure kna1 default wa.
<FS> is pointing to wa content
<FS> gets structure from kna1
- Assign structure component to field symbol also possible
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
assign component wa-land1 of structure wa to <FS>.
- Field symbols can be used in date calculations
- Field symbols can be used in dynamic select statements
- ANY is used to adopt any data type (or) data object
- DATA is used to adopt any data type
- OBJECT is used to adopt any class (or) interface object
- GET REFERRENCES OF statement is used to adopt the
technical properties from source variable to target variable
GET REFERRENCES OF <var1> TO <var2>.
- Data references :
declarations with ref to DATA
ex :
DATA <gr_gen> TYPE REF TO DATA.
- using ->* data references can be assigned to field symbol
ASSIGN <gr_gen>->* to <FS>.
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
now field symbol is pointing to the value of data object
- RTTI : Run Time Type Identification
RTTS : Run Time Type Services
RTTC : Run Time Type Creation
- In classical ABAP
to describe field properties , we use DESCRIBE FIELD
statement
to describe itab properties, we use DESCRIBE TABLE
statement
to describe list properties, we use DESCRBE LIST
statement
- in ABAP objects , SAP defined global built-in classes provides
these services
by instantiation to these classes, we can
describe data type, data object properties
TAW12_1 Certification Notes Prepared by AV.Krishna, SAP Certified Consultant & Trainer
- if the data objects are declared by DATA keyword , automatically
objects are created while execution of the program
- if the data objects are declared by CREATE DATA keyword,
objects are not created by default.
when system reads create data statement then objects are
created in the memory.
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
Enhancements :
- Changes to standard SAP :
- Customization
- Personalization
- Enhancement
- Modification
- Custom Development
- Customization : is mandatory in implementation project
as part of customization - BASIS consultants
perform administration concern configuration and Functional
consultants perform respective SD,MM, FI, configuration
- Functional configuration done using IMG tool ( tcode : SPRO )
- other change levels are optional
other change levels are done by ABAP consultant, using ABAP
workbench
- Personalization :
- perform changes to SAP screens :
- creating favorites
- creating desktop shortcuts
- creating role based menus
- performing changes to screen fields :
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- changing table control settings
- providing default values using SET / GET parameters
- transaction variant : to customize standard SAP transaction
are used to hide screen fields
- to make a field as required entry
- to provide default value to screen field with editable mode
- to provide default value to screen field with
non editable mode
- to deactivate not required menu items also
- requirement : perform below changes to mm01 tcode initial screen
- make material field as required entry (mandatory field)
- provide default value as Food industry (non editable mode)
- provide default value as Finished Product (can be editable)
- hide change material field, copy from material field
- deactivate material menu -> change -> immediately
step1 : tcode : SHD0 - transaction variant
is a collection of screen variants
screen variant is a collection of changes on particular
screen
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
step2 : tcode : SE93 - create variant transaction
specify tcode name as zmm01
click on create
choose variant transaction
specify transaction code + transaction variant
save , check
step3 : test zmm01
- Enhancement : without changing standard SAP , we can add
additional functionality to SAP
- Modification : modifying SAP object at customer site, with the help of
Access Key
- Custom Development : developing new object at customer site, with
customer name space
- Enhancement :
- without changing standard SAP , customer can add additional
functionality
- Enhancements are upward compatible
- Enhancements are special provisions provided by SAP and
implemented by customer
- Enhancements hang like hook to standard SAP
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Enhancements also called as exit
- Architecture View : Presentation layer <- menu / screen /
text enhancements
Application layer <- program enhancement
Data base layer <- table enhancement
- Types of Enhancements :
- Customer Exit (implemented thru function modules)
- User Exit ( implemented thru subroutines)
- BTEs ( implemented thru function modules)
- BAdI (implemented thru methods)
- Customer Exit : supports program , menu, screen, text
enhancements
Text Enhancement : is also called as Data Element enhancement
- changing field label :
- place the cursor screen field
- press F1 , click on technical information
- notice data element
- execute tcode : CMOD
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- goto menu -> text enhancements -> keywords -> change
- specify our data element , continue
- change field label
- save, continue with request
- changing field documentation
- identify data element for screen field
- execute tcode : CMOD
- goto menu -> text enhancements -> data elements -> new DE
customer documentation
- specify modification name begins with Y or Z
- continue , change documentation, save, continue with request
- Working with Enhancement is 4 step procedure :
step1 : understand specific unique requirement of customer
step2 : search for relevant enhancement in SAP
step3 : read documentation and implement enhancement
step4 : test enhancement
- step1,2 done by functional consultants
- step3,4 done by ABAP consultants
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- transaction codes related to customer exit :
- SMOD - SAP enhancements list
- CMOD - implementing enhancements
- Search criteria of Enhancements :
- search in SMOD list
- tcode : SE81 - application hierarchy
- tcode : SE84 - repository information system
- tcode : SPRO - search with keyword 'Exit'
- Search based on any tcode :
execute tcode -> system menu ->status -> double click on
program -> goto menu -> attributes -> notice the package
search in SE84 using package
- program based search : open the program in display mode , search
with string
"call customer-function"
- Exploring enhancement in SMOD tcode :
- Enhancement
- attributes tab : consist of description, package, and language
- components tab : consist of function module exits(program exit)
function codes(menu exit)
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
screen areas(screen exit)
includes
- documentation tab : - consist of documentation provided by
SAP developer
- functionality of enhancement and
implementation steps
- Exploring enhancement list :
- program exit -> process -> exit_program_<nnn> -> zinclude
- menu exit -> process -> exit_program_<nnn> -> zinclude
-> function codes
- screen exit -> process -> exit_program_<nnn> -> zinclude
-> screen area
- Program Exit :
- is also called as Program Enhancement (or) Function exit (or)
Function module exit
- without changing built-in program, customer can add their code is
called as program exit
- it is implemented by includes and function module
- every program exit behind one function module is available
- all exit function modules are part of exit function group
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- they begins with EXIT_<program>_<nnn>.
prefix infix suffix
- every function module behind one empty zinclude is available
- SAP developer where ever they wish to give permission, they
defined CALL CUSTOMER-FUNCTION statement internally
- As a part of implementation (CMOD)
we have to create project,
assign enhancement to project,
create zinclude thru forward navigation
specify your code in include
activate include, back
activate project
- SMOD : Enhancement ->Exit_program_001 -> include zinclude
- CMOD : create project - zproject <- Assign Enhancement <-
Exit_program_001 <- create zinclude - write logic
activate project
- Demo : providing information message on successful creation of
vendor using xk01 tcode
- vendor creation using xk01
- execute tcode XK01
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- specify vendor name(MRF1)
- specify account group(0002)
- enter
- specify title(company)
- specify name(MRF Tyres Pvt Ltd)
- specify search term(MRF)
- specify country(IN)
- save
- Searching for enhancement :
- tcode behind program - SAPMF02K, package - FBK ,
enhancement : SAPMF02K
- Implementing enhancement :
- execute tcode : CMOD
- specify project name begins with Y or Z
- click on create
- provide short description
- save as local object
- click on enhancement assignments
- specify enhancement, save
- click on components
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- double click on function module
- double click on zinclude
- press enter to ignore warning message
- save include under local object
- specify logic in include
- activate include, back
- back
- back
- activate project
- test enhancement
Note : Enhancements are not reusable
one Enhancement belongs to one project at a time
In order to re implement same enhancement in another project,
we have to deactivate and delete previous enhancement.
Note : SAP defined function group name begins with SAPL<fgroup>.
SAP defined function module names begins with L<fgroup>top
L<fgroup>U01
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
function group is a collection of function modules, screen, status,
includes, modules,subroutines,..etc,
****************
Menu Exit : is also called menu enhancement
adding custom menu item to SAP permission provided
Status
where ever SAP developer wish to provide permission,
they defined menu with function code + symbol
working with menu exit is 2 step procedure :
step1 - specify function text for function code
step2 - maintain the logic in relevant exit function module
Demo :
Business Requirement : adding custom menu item to ABAP editor
program screen concern environment menu
Searching for enhancement : program : SAPLS38E
package : SEDI
enhancement : SEUED001
Implementation : tcode - cmod
specify project name begins with Y or Z
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
click on create
specify short description
click on enhancement assignment
specify enhancement as SEUED001
save
click on components
switch to change mode
double click on function code +PGE
specify corresponding text as ABAP Dictionary
click on copy, continue with request
double click on EXIT_SAPLLOCAL_EDT1_002
create include, specify logic, activate, back
activate project
- test enhancement
******************************************************************
Screen Exit : is also called screen enhancement
with out changing standard SAP screen, customer can
add additional fields to SAP screen
Where ever SAP developer wish to give the permission ,
they defined empty sub screen area, they maintained call sub screen
statements both in PBO and PAI
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
they specified sub screen number also
- demo : adding custom fields to production order header data (co01
tcode)
observation : execute tcode co01
enter material(100-100)
enter production plant(1000)
enter planning plant(1000)
enter planning type (pp01)
press enter
enter total quantity(100) - pc
specify end date, start date and type as current date
save, continue with production version
click on no
finally system generates one production order number
Searching for Enhancement : package : co
enhancement : PPCO0012
Implementation steps based on documentation :
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- tcode : SE11 - open AUFK table and add 2 custom fields thru
append structure
- tcode : CMOD - create project, assign enhancement, click on
components
double click on 100 screen
specify screen type as sub screen and short
description
click on layout
click on dict/program fields button, add fields from
AUFK table
click on flow logic
save, continue with request
activate, back
double click on +COI , specify text(customer screen
tab)
click on copy
continue with request
double click exit_001 function module (PBO logic)
double click and create zinclude
specify below statement
move-corresponding i_caufvd to aufk.
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
while checking system saying aufk is unknown for
exit function group.
we have to create aufk as tables
double click on aufk, choose tables statement
(create it in ztop include)
activate, back
double click on exit_002 function module ( PAI logic)
double click and create zinclude
specify below statement
move-corresponding aufk to e_coci_aufk.
activate ,back
finally activate project
- test enhancement
********************************************************************************
******************************
BAdI : Business Add-Ins
- is a object oriented enhancement technique
- implemented by global classes and methods
- BAdIs are widely used in SAP
- mainly in Enhancement
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- reporting
- forms
- Difference between Customer Exit and BAdI
Customer Exit
- supports program, menu, screen, text enhancements
- are not reusable
- related transaction codes : SMOD & CMOD
- two layer architecture(SAP <- Customer)
- are not part of enhancement framework and switch frame work
- user can't create customer exit
BAdI
- supports program, menu, screen enhancements (but text
enhancement not possible)
- are reusable
- related transaction codes : SE18 & SE19
- multi layer architecture(SAP <- customer / industry solutions /
business partner )
- are part of enhancement framework and switch frame work
- user can create customer badi
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- BAdIs are used without changing standard SAP , customer can add
additional business functionality to SAP
- BAdIs can be classified as
- Classic BAdI
- is old BAdI, valid till 4.7 version
- can be searched using string "cl_exithandler=>get_instance"
- is not a part of Enhancement framework
- system generates adopter class
- Kernel-based BAdI
- is new BAdI, valid from ECC 5.0 onwards
- can be searched using string "call badi"
- is a part of Enhancement framework
- system doesn't generates adopter class
- Working with BAdI is 4 step procedure
step1 : understand unique specific requirement of customer
step2 : search / locate / find for relevant BAdI
step3 : read documentation and implement BAdI
step4 : test BAdI implementation
- Searching for BAdI :
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- tcode - SE18 : list of classic and new BAdIs
- tcode - SE81 : Application Hierarchy
- tcode - SE84 : Repository Information System
- tcode - SPRO : IMG tool
- execute any tcode , find out package, search based on package in
SE18
- open any program in display mode search with string
"cl_exithandler=>get_instance"
- BAdI Builder :
is used to define and implement BAdI
is a utility tool which is integrated with ABAP Workbench
BAdIs are developed based on object oriented approach
BAdIs are defined as global Interface
Every BAdI behind one global Interface is available
SAP developer defined interface behind possible methods also
this methods are used to provide additional business functionality
BAdI interface implemented by customer
One BAdI interface can have multiple implementations
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Program Enhancement using Classic BAdI :
- Business Requirement : providing information message on
successful creation of customer using XD01 tcode,
providing default Reconciliation account (AKONT) as 140000,
and Payment terms(ZTERM) as 0001
- searching for badi : program : SAPMF02D
package : VS
BAdI : customer_add_data
Method : check_all_data (for final check)
PRESET_VALUES_CCODE (to provide default
values)
- implementing badi : tcode - SE19
choose classic badi create implementation
specify badi name
click on create implementation
specify implementation name begins with Y or Z
continue
specify short description
save implementation
click on interface tab
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
double click on implementation class (zcl_im....)
continue with migration message
click on create enhancement implementation
specify name begins with Y or Z, and short
description, continue
now select our implementation and continue
now control transfer to global class ( class builder )
implement methods and activate, back,
activate badi implementation
- test enhancement
Exploring Classic BAdI :
- have unique name and short description
- Properties tab :
- package, language, user name, date , time (general data)
- name of generated badi class
- is also called as adopter class (or) add-in class (or)
generated class
- it is always starts with cl_ex_<badi name>.
- it is automatically generated by BAdI environment
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- it performs 2 operations
- it calls and controls all active implementations
- it perform filter
- all classic badis are now migrated to enhancement spot
- Type :
if with in SAP checkbox is activated, then this badi is used for
internal use
if multiple use checkbox is activated, then this badi can have
multiple implementations
otherwise single implementation is possible
menu enhancement related badis are not reusable
if filter-dependent check box is activated, then it is called as
filter dependent badi
SAP developer provides filter type
filter type can be global structure (or) data element
filter badi is useful for condition based implementation
while customer implementation, customer must
supply value to filter type
this filter type must belongs to data type character and
can be length up to 30
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
this filter type is defined as mandatory import parameter
for all badi interface methods, customer must supply FLT_VAL , while
implementation
if enhanceable checkbox is activated, then it is enhancable
fiter type
this data element must contain a domain with value table
this value table must be connected with text table
both tables must be cross-client
and their delivery class must be E or S
if interface tab is available - program enhancement is possible
if fcodes tab is available - menu enhancement is possible
if subscreens tab is available - screen enhancement is possible
interface tab : having global interface name and possible methods
interface name begins with IF_EX_<badi name>.
documentation button : provides functionality of badi and
implementation procedure
sample code (goto menu) : is provided by SAP developer for
ABAPer , it is useful for reference purpose
default code (goto menu) : is provided by SAP developer for
ABAPer, if no active implementation is available , then default code
gets displayed
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
SE18 - Initial screen - Utilities menu -> provides create classic
badi / regeneration / migrate classic badi / advancements active
implementations
SE19 - having create classic badi as below option
/ change , display class as above option
- while creating we have to specify badi implementation name
begins with Y or Z
- finally activate badi implementation (deactivate badi
implementation)
- since all classic badis are migrated , so enhancement
implementation is required to implement badi
- Interface tab consist system proposed global class
(zcl_im_<badi_implementation)
- Steps to create custom classic badi
step1 : tcode - SE18
utilities menu -> create classic badi
specify badi name begins with Y or Z
continue
specify short description
save as local object
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
notice the system generated add-in class
double click on interface , create required methods, activate
back
step2 : tcode - SE19
specify classic badi name
click on create implementation
specify badi implementation name begins with Y or Z
continue
specify short description
double click implementation class
implement methods
activate , back
step3 : tcode - SE38
BAdI Application program
- declare ref variable to badi interface
start-of-selection.
- create instance for adopter class , by calling cl_exithandler
class, and its public static method get_instance (factory method)
cl_exithandler is a service class used in service exit
technique
- call interface method thru adopter class instance
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
*--------------------------------------------------------------------------*
- Demo :
Menu Enhancement thru Classic BAdI :
- Business requirement :
adding custom menu items to FBL3N tcode
FBL3N - G/L line item display
- tcode concern ALV output screen concern Extras menu
have some menu exit
- search criteria :
tcode behind program : RFITEMGL
package : FREP
BAdI name : FI_ITEMS_MENUE01
Method name : List_item01 to 04
- Implementation :
execute tcode : SE19
specify classic BAdI name
click on create implementation
specify badi implementation name begins with Y or Z
continue
specify short description
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
save as local object
click on Fcodes tab, specify function text for each function code
click on Interface tab, double click on implementation class
implement methods , activate methods, back
activate implementation
- Test implementation
*- Screen enhancement thru Classic BAdI :
Business requirement : adding custom fields to customer creation
XD01 tcode screen
Search for Enhancement :
program name : SAPMF02D
package : VS
BAdI : customer_add_data_cs(Subscreen Container
4000)
Methods : set_data : is used to provide default values to
screen field
get_data : is used to get the user entered data
from screen
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
observation from documentation :
step1 : add additional fields to KNA1 table
step2 : In Customizing for the customer master,
under Transfer Customer Master Data Fields,
prepare the modification-free enhancement of the customer
record
define a screen group with name and have labeled the tab
pages
step3 : Activate the processing of your own data with the method
CHECK_ADD_ON_ACTIVE of the Business Add-In
CUSTOMER_ADD_DATA.
step4 : implement BAdI - Customer_add_data_cs
- specify filter value
- implement method : get_taxi_screen
- finally activate
step5 : create module pool program
create dialog screen 4000 as sub screen
add our custom fields
activate
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
************************************************
Exploring New BAdI :
New BAdIs are defined for Enhancement Spot
Enhancement Spot name and BAdI name may be same (or) different
doesn't generate Adopter class
this is badi is generated in Kernel ( application layer )
fall back class : is nothing but default implementation
New BAdIs are implemented thru Enhancement Implementation
- Custom New BAdI creation :
step 1 : tcode - SE18
specify enhancement spot name begins with Y or Z
click on create
specify short description
continue
save as local object
en.spot element definitions tab
click on create badi
continue
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
expand new badi
double click on interface
specify interface name zif_ex_badiname, press enter
system prompts to create global interface, continue with yes
save enhancement spot
define required methods in global interface, activate, back
(SE18 : zen_spot ->znewbadi ->zif_ex_newbadi ->m1)
step2 : tcode - SE19
provide enhancement spot
click on create implementation
specify implementation name, short description, continue
save as local object
specify badi implementation name(znewbadi_impl)
specify implementation class name(zcl_im_newbadi_impl)
choose badi name from badi definition drop down(znewbadi)
continue
save as local object
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
expland badi implementation
double click on implementation class
double click on zcl_im_newbadi_impl
implement methods
step3 : tcode - SE38 - newbadi application program
declare ref variable with ref to badi directly
specify get badi statement , to acquire generated badi handle
specify call badi statement, to call badi interface methods
*- Enhancement Framework :
- introduced from ECC 5.0 onwards
- it comes along with built-in enhancement spot , enhancement
points, enhancement options,new badis
- Enhancement Spot :
- is used to define explicit enhancement points
- is used to define explicit enhancement sections
- is used to define new badis
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- one enhancement spot have one badi (or) multiple badis
- Composite enhancement spot is a collection of more than 1
enhancement spots
- Enhancement spot can be search from SE84 - Repository
Information System
- it can be searched based on name, short description,
technology(badi_def),
package, application component
- Explicit Enhancement Point :
- are planned by SAP developer, they defined explicit enhancement
points, where ever they are expecting additional code by the
customer
- are defined for Enhancement spot
- one spot can have multiple enhancement points
- enhancement point can be static (or) dynamic
- static enhancement points allow the user to add declarations
- dynamic enhancement points allow the user to add code
- steps :
- tcode : SE38
- open the built-in program in display mode
- click on program menu -> enhance (or) click on enhance spiral
icon
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- search for enhancement point
- edit menu ->enhancement operations -> create enhancement
implementation
- specify enhancement implementation starting with Y or Z, short
description
- save as local object
- system generates
Enhancement.
End-enhancement.
- between add your code
- finally activate enhancements
- Steps to define custom enhancement option
between enhancement...endenhancement, specify include
statement.
include zinclude10.
place the cursor zinclude10 -> right click -> create enhancement
operations -> enhancement options
- specify enhancement point, specify enhancement spot
- select enhancement spot and continue
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- if multiple enhancement implementations for one spot (or) one
enhancement section leads to conflict.
to avoid that we can implement switch
if switch is activated only one implementation can be called
*- Explicit Enhancement Section : this is prepared by SAP developer
explicitly
the code with in enhancement section ....end-enhancement
section , can be replaced by customer
*- Implicit Enhancement point / option :
- implicit enhancement sections are not avialable & not possible
- SAP developer not planned ( they do not visible in the program
directly )
- are part of enhancement frame work
- are not defined for enhancement spot
- are enabled first , implemented next
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- are useful to enhance
- any built-in program(SE38)
- any built-in global function module(SE37)
- any built-in global class method(SE24)
- any built-in program structure(SE38)
- any built-in program subroutine(SE38)
Hint :
- possible :
explicit enhancement spot
explicit enhancement point
explicit enhancement section
explicit enhancement option
implicit enhancement point
implicit enhancement option
- not possible
implicit enhancement spot
implicit enhancement sections
- Working with implicit enhancement point :
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
steps :
- open built-in program in display mode
- click on spiral button
- edit menu -> enhancement operations -> show implicit
enhancement points
- as a result , system enables special double quoted line
- place the cursor on double quoted line -> right click -> create
enhancement implement
- create new implementation, save as local object
- specify your code between enhancement....endenhancement
- finally activate
- in case of function module source code enhancement,
when we try to create enhancement implementation, system prompts
for code and declaration.
- declaration is used to declare additional declarations at the top
begging of function module( after function statement)
- code is used to add logic with our declarations at the end of
function module (before endfunction statement)
- Ex : date_to_day
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Implicit Enhancement Options for function module :
- we can enhance any built-in function module concern interface , it
is called as implicit enhancement option
- we can add additional and optional import, export, changing, tables
formal parameters
- steps :
- open any function module in display mode
- click on import
- click on spiral button
- create new enhancement implementation, save as local object
- now enhance import tab, export tab, changing tab, tables tab
- finally activate
- Implicit Enhancement option for Global Class :
- we can enhance any built-in global class using implicit
enhancement option
- we can add additional interface, additional attributes, additional
methods, events, types
- we can enhance signature of built-in class method
we can additional importing, exporting, changing parameters
returning parameters, exceptions not possible
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Implicit Enhancement points :
- also possible for local class
- we can enhance local class with additional attributes, methods,
events.
- we can enhance built-in method implementation
- we can enhance subroutines( by adding code after form
statement , before end form statement)
- we can enhance local program structure ( by adding code after
begin of statement, and before end of statement )
- User Exit :
- are part of modification, because it is implemented with the help of
Access Key
- are special provisions provided by SAP and implemented by user
(Enhancement)
- are implemented thru subroutines (procedural enhancement)
- are under special includes FZZ
- mainly used in SAP SD module
- user exit consist of empty subroutine
- perform statement written by SAP developer only
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Modifications after Upgrade :
- after upgrading SAP software to new release, we have to adjust the
repository objects in new version
- SPDD transaction code is used to adjust dictionary objects like data
elements, domains, data base tables
- SPAU transaction code is used to adjust ABAP programs, user
interface,screens, views, search help,
lock objects
-----------------------------------------------------
WebDynpro : web based screen programming
dynpro : screen
R/3 : Windows based screens
we need SAP GUI as Front End
- web SAP HTML as Front End
- SAP started with windows based (GUI based screens)
which can be accessed using Presentation Server ( GUI
support with Windows )
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- SAP started Windows based Screens by Web based screens
- initially they started SAP ITS -> BSP -> WebDynpro
Multi tier Architecture :
- WebClient ( Browser ) : End user access URL
- Web Server : (SAP ITS) - ICM
- Application Server ( ABAP Engine and J2EE Engine )
- Database Server
pre-requisite knowledge :
- Classic ABAP
- Module pool program
- OOABAP
- CRM & SRM & HCM ( ESS and MSS )
(3.0 to -> 4.7EE -> ECC5.0/ 6.0
46c)
BSP WebDynpro
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- BASIS -> SAP WebAS -> SAP NWAS
6.10 6.40
6.20 7.00
6.30 7.01
- WebDynpro : as two types
ABAP Stack - programs can be designed and run using SE80 (
object navigator )
- Step1 : Component creation ( declaration + design + coding )
Application creation
- Step2 : Test Application - output will come in browser
- Introduction
- Controllers
- UI Elements
- data binding
- Context Mapping
- OTR & Messages
- Context Programming
- F4 help
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- ALV Report
- Portal Integration
- Adobe Forms integration
- WebDynpro using Java
- additional software (NWDS- NetWeaver Developer
Studio)
- iviews
- visual composer
- portal integration
- BSP : more coding ,
less user friendly
- MVC paradigm
View - user interaction area
Controller - accepts user input / accepts result database
Model - business logic ( in turn connected with underlying
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
database)
view1 -> outboundplug navigation link
inbound plug->view2
- screen rendering ( round trip )
- data binding : binding data with UI element
view1 -> view2
inputfield -> table
variable itab data
- context mapping : mapping context between controllers
*---------------------------------------------------------*
What is Web Dynpro?
- Web Dynpro is a programming model provided by SAP.
- Web Dynpro is implemented in Java and ABAP.
- It is suited to generate standardized user interfaces (UIs)
using a declarative approach, resulting in a minimum time
effort to realize Web applications.
- Web Dynpro is the technology SAP uses for developing all
future applications
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
Existing Dynpro-based transactions will be converted.
- Web Dynpro does allow to develop of standardized UI very
quick, Web Dynpro has to be embedded in the portal
environment to be able to change the application design.
- Web Dynpro is a programming model, which allows to
design standard UIs very quick.
Everything can be designed without coding .
On the other side, the freedom in designing the UI is
restricted. E.g. it is not possible to include client side
JavaScript in the generated pages. The generated code is not
restricted to HTML.
- ABAP Web Dynpro high speed, low cost, and standardized
UIs.
- Web Dynpro applications are built using declarative
programming techniques based
on the Model View Controller (MVC) paradigm.
- Web Dynpro is SAP's state-of-the-art technology for
creating application user interfaces (UIs).
ABAP Web Dynpro : ( comparison with Java Web Dynpro )
- ABAP Web Dynpro does not know model objects, which
encapsulate the business logic.
- The ABAP Dictionary content can be reused (value help,
data elements, ...).
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Instead of View Sets, ABAP WD uses Container Views to
combine different views on one page.
- Since Container Views are Views - thus having Plugs - the
navigation in WD
ABAP is realized differently from the Java approach (View
Sets do not offer Plugs).
- The ABAP List Viewer can be used with ABAP WD.
- We have to specify the interface elements at client , they
will get the data from
- Define possible navigation paths declaratively in application
- All the code to create the user interface is then generated
automatically
within a standard runtime framework. This relieves us from the
repetitive coding tasks involved in writing HTML and making it
interactive with JavaScript.
- ABAP Web Dynpro has been available since SAP
NetWeaver 2004s (SAP NetWeaver Application Server 7.0).
For developing the entities of a Web Dynpro application, the
Object Navigator (transaction code SE80) has been
enhanced.
- Web Dynpro is designed to support structured development.
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
The software modularization units are Web Dynpro
components, which can be combined to build up complex
applications.
********************************************************************
Context stores the data at runtime.
Context life time is , as long as component is running - context
holds the data.
Conext is used to share information between controllers
- global context is defined in Component Controller, which are shared
by all view controller context
- Component controller context can be mapped to view controller
context
Context consist of Root Node (must)
Root node is a collection of Sub Nodes (or) Elements
Sub Node is a collection of Nodes (or) Elements
Node is used to hold internal table
Element is used to hold Attribute
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
Node represented as circle, Attribute represented as Triangle
Node collection is collection of elements
Cardinality property specifies number of possible elements for node.
0..1: Zero or one element permitted
0..n: Zero or more elements permitted
1..1: Exactly one element permitted
1..n: One or more elements permitted
Internal Context mapping : mapping context of two controllers with in
the component
External Context mapping : mapping context of two controllers of
external WD component
Context root node : is a parent node of context,
it can't be deleted (or) modified any way
Name of context node must be unique
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
Context Attribute doesn't have child attributes
Cardinality specifies maximum and minimum number of elements the
node collection may hold at runtime.
Lead Selection : Exactly one element of the node collection can be
marked as the element at lead selection.
Elements are 3 types :
1.created by WD Framework at context initialization time
2.created using source code in container method at runtime
3.lead selection element
Singleton : if the property is set as true , only one child instance can
be generated at runtime
it is Boolean property effects the relationship between a
dependent and its parent node
singleton = false ( non singleton )
singleton = true ( singleton )
Supply Function :
- it is a mechanism for repopulating child nodes.
- it is useful particularly when using singleton nodes
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- it is called at runtime automatically when the data of an invalid
context node is accessed.
- it is a method ,assigned to node
******************************
View controller consist of Layout tab
using Layout tab we can design layout as per requirement
All the possible UI elements are listed in the Layout
using drag and drop we can design layout
- elements can be inserted using ROOTUIELEMENTCONTAINER (
right click -> insert element -> name element -> specify type of
element )
- Every UI element name must be unique
UI element properties can be set
- Elements are classified as 4 types :
Standard Simple : button, label, input field
Standard Complex : need to have child element
ex : table -> child ( table column )
Standard Container : may have child elements
ex : group (visibility)
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
transparent container ( non visibility )
other element category :
Active Component : used for Active-X based diagrams
ex : Adobe (or) IGS (or) MS-office
integration (or) trees (or) Gantt Charts or network charts.
Layout : All container elements and its children are arranged in layout
in different ways
1.Flow Layout : elements are displayed in a row( wide enough)
2.Row Layout : all children elements are displayed with a new
row (or) same line
3.Matrix Layout : child elements are displayed as columns ( can
occupy multiple cells)
4.Grid Layout : vertical alignment of elements
5.Form Layout : used the container UI element all children
inherit the property layout data
can display multiple cells
Data binding is a two way relationship
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
UI element hard coded values can be changed at runtime using hook
method wddomodify()
Text Views, Labels, captions.... display text from ABAP Dictionary
Composite UI Elements are incapable to display information on thier
own. They must have child UI elements to function correctly
Table : two dimensional display
*****************************************
Each Dynpro Controller is a separate ABAP Class
Apart from standard hook methods developer can create Instance
methods, event handler methods (or) Supply functions
Two hook methods exist for all controller types
wddoinit() -> called after control instantiated
First method processed in controller life time
only called once
initialization code mention here
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
wddoexit() -> last method processed end of controller life cycle
all clean up code should be mention here
Component Controller : Additional standard methods
wddobeforenavigation()
-> called after action method before Framework
process events
-> when client event raised, corresponding action
method in the view controller processed
wddopostprocessing()
-> validates cross components
-> last controller method processed before the UI is
sent to the client
View Controller : Additional hook methods
wddobeforeaction()
-> after WD Application has been started and the
user has client event the first method to be processed
wddomodifyview()
-> only method used to manipulate the UI element
hierarchy dynamically
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
User defined all methods are public and used by other controller of the
same component
Each controller is a separate ABAP Program
Standard Attributes :
wd_this : self reference to controller interface ( like ME )
used to access standard WD functions like validation
wd_context : ref to controller context root node
wd_comp_controller : additional system generated attribute as
used controller
-> ref to component controller from any
controller
User defined Attributes are public (or) private
-> visible to all
Accessing context node : using get_child_node()
Accessing node elements : using get_element()
Reading value of attribute : using get_attribute()
Reading value of multiple static attribute : using
get_static_attributes()
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
Reading Static Attribute values for all node elements :
using get_static_attribute_table()
Changing value of Attribute : using set_attribute( )
Changing multiple Attributes of a Node element : using
set_static_attributes()
Add elements to context node : using bind_element()
Binding structure to context node : bind_structure ( )
Binding internal table to context node : bind_table( )
Demo1 : Display Welcome message in the output (using caption)
- execute tcode : SE80
- place the cursor on package
- right click
- create webdynpro component interface
- specify webdynpro component ( as zwdc_component1 )
- specify window name ( as window1 )
- continue
- expand webdynpro component
- place the cursor on our webdynpro component
- right click
- activate
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- place the cursor on webdynpro component -> right click -> create
view
- specify view name (as view1)
- continue
- click on layout tab of view1
- drag and drop caption ( specify name and element as caption )
- continue
- speicfy text as ( welcome to webdynpro ) in the attributes window
- activate view1
- embed view1 into window1
- finally activate webdynpro component
- place the cursor on webdynpro component
- right click
- create webdynpro application ( as zwda_component1 )
- save application
- place the cursor on webdynpro application ->right click
- test
- view the result in browser
*------------------------------------------------------------------------------*
Demo2 : Navigating between Views
- Create web dynpro component ( window name : main ), Activate
Web Dynpro component
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- Create view1 : layout tab : place UI element caption ( text : This
is First view )
- Specify outbound plug ( to_view2)
- Specify inbound plug(from_view2)
- Place UI element button (text : button_go, action
: outbound plug to_view2)
- Save and activate view1
- Create view2 : layout tab : place caption(text : This is Second
view)
- Specify outbound plug(to_view1)
- Specify inbound plug(from_view1)
- Place UI element button(text : button_back,
action: outbound plug to_view1)
- Save and activate view2
- Embed view1 & view2 to window main
- Create navigation link for view1 (Outbound plug : to_view2)
- Create navigation link for view2(Outbound plug : to_view1)
- Finally activate web dynpro component
- Create webdynpro application
- Place the cursor on Webdynpro application -> right click -> test
*------------------------------------------------------*
Demo 2 : Navigation link Demonstration :
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- create web dynpro component
- create start_view :
specify inbound plug as : in_default
outbound plug as : out_next
go to layout tab
insert text_view ( specify text - First View )
insert button ( specify name and onaction event ,
choose outbound plug as out_next)
- create result_view :
specify inbound plug as : in_default
outbound plug as : out_back
go to layout tab
insert text_view( specify text- Second View)
insert button (specify name and onaction event,
choose outbound plug as out_back)
- activate & embed both views in window main
- expand start_view, select out_next plug, right click define navigation
link, specify dest view as Result_view , inbound plug as in_default
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- expland result_view, select out_back plug, right click define
navigation link, specify dest view as Start_view, inbound plug as
in_default.
- finally activate component
- create application and test
*_____________________________________*
Demo3 : Passing data between views - manul binding
(one view user enters name , second view displays user entered
name)
- create Webdynpro component
- create view1
- component controller -> context
- create node(node name : node)
- create attribute(attribute name : name
type : user01-bname)
- activate component controller
- dbl click on view1-> layout -> design label(text username)
button(text submit, action : action
obpulg action)
input field(label for:input_field)
- context tab : drag and drop from right side to left side
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
dbl click on input field (binding value property : name)
- create view2
create label ( Entered name was)
context tab : drag and drop context from component controller
layout tab : bind name to input field
- finally activate view1 & view2
- embed view1 & view2 to window main
- create navigation link
- create WD Application & test
*-----------------------------------------------------------------------*
Demo4 : using Context Mapping & data binding:
( one view user enters values, second view displays user entered
values )
- create wd component and activate
- create view and activate
- go to component controller - context tab
right click ->create node :(name : Flight_info
Dict Structure : sflight
click on add attributes from structure
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
select carrid and connid and continue
for carrid and connid activae inputhelp mode as automatic
go to view1 controller -> context tab
drag and drop attributes from component controller context to
view controller context
go to inbound plug - specify in_default
go to outbound plug - specify out_next
Go to Layout
create element group , specify caption
right click on group -> create container form -> click on context ->
select fields to display -> continue
insert button ( specify name Button_next,
text Next
action - onAction
outbound plug - out_next )
Activate View1
in the same manner create View2
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
activate view2
Embed both views in Window Main
- define link for both views
- activate component , create application and test
*-------------------------------------------------------------------*
Demo4 : Accept name from one view and display in other view
create WD component
for component controller - create node : main
create attribute for main node : name
type string
create startview -> layout tab
insert label :text (Enter your name)
insert input field
insert button ( name, onaction event )
go to context tab - map controller context to view context
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
for input field value property bind as attribute
name
create result view ->layout tab
insert label : text (User Enter name is)
insert text_view
insert button ( name, onaction event )
go to context tab - map controller context to result view context
for text_view bind attribute as name go to
methods tab - double click on onactionback event
click on code wizard
select read context -> specify node and
attribute (name)
add additional code before fire plug
* code added by user *
elem_main->set_attribute(
exporting
name = 'NAME'
value = item_name ).
- embed both views in Window Main
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
- create application and test
*---------------------------------------------------------------------*
Demo5 : Displaying database table data on final output
using internal table
- create WD component & Activate it
- click on Component Controller Context -> right click -> create
node(node_sflight) -> add attributes
specify cardinality as 0..n
activate component controller
- create view1 context -> drag and drop context
- switch to layout tab : drag and drop table
bind table to node (data binding)
- under wddoinit()method specify below logic .
* data declaration *
data : node_sflight type ref to if_wd_context_node,
itab type table of sflight.
TAW12_2 Certification Notes prepared by AV.Krishna, SAP Certified Consultant & Trainer
* data fetching logic *
select * from sflight into table itab.
* navigate from <CONTEXT> to <SFLIGHT> via lead selection *
node_sflight = wd_context->get_child_node( name =
`SFLIGHT_NODE` ).
* bind internal table to context node *
node_sflight->bind_table( ITAB ).
- finally create application & test