Professional Documents
Culture Documents
Day2 - Pre-requisites, SAP Project, SAP Architecture, Logon procedure, Logoff procedure,
of testing activities
*******************************************************************************
- it fulfills company specific , country specific, regional specific legal and statutory requirements
- SAP All-in-one :
- powered by NetWeaver
- Powered by NetWeaver
- consist of Core Applications , Industry specific applications, Enhancement Packages , and Support
Packages
*************************************************************************************
- Presentation Server :
- is also called as SAP GUI.exe (or) SAP Front End (or) SAP Logon
View
Program
Function Module
Screen
Menus
Global Classes
Forms
- Classification
- status : Active
- Runtime Environment :
Application Server :
- Dispatcher accepts request from presentation servers and maintain all request under
dispatcher queue
All work processes are using common memory area called Shared
memory
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
- Task handler : accepts the request from dispatcher and assigns task to respective areas
Open SQL :
Native SQL :
EXEC <SQL>.
------------------.
------------------.
ENDEXEC.
it is closely integrated with many development tools like ABAP Dictionary, ABAP Editor, Screen
Painter, Menu Painter, Class Builder, Function Builder...etc.,
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 :
- Stop Server
Ex :
DEV
QAS
PRD
ZME
Client :
100, 200, 300 - Non-IDES clients - used for real time development purpose
menu bar
title bar
status bar
System menu and Help menu are default menus for every screen
F1 - System help
F2 - detail display
F4 - search help
F5 - create mode
F6 - change mode
F7 - display mode
F9 - technical information
F12 - cancel
Ctrl + F3 : activate
Ctrl + F8 : execute
is a combo box(user choose a tcode from list, and enter new tcode)
can be alphanumeric
ABAP Tcodes :
BASIS Tcodes :
Functional Tcodes :
SD tcodes :
MM tcodes :
*******************************************************************************
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
(EhP1.........7)
6.20 7.00
6.30 7.01......7.40
*************************************************************************************
*****
Lock Management :
- Lock object is required to restrict simultaneous access of table record by several users at a time.
pass values
test program
pass values
test program
lock server (or) Enqueue sever holds all logical lock entries
the user who sets the lock, he can perform all operations
***********************************************************************
- Application data and Customizing data is client specific (or) client dependent
- SAP -> Repository -> Applications -> Components -> Package -> Repository Object
Ex :
- search for custom tables : z* press F4 - system displays all the table names begins with z
it provides search criteria based on object name (or) short description (or)
package (or) application component
tcode : SE81
Tag Browser,
MIME Repository,
Transport Organizer
***************************************************************
- Package can be created directly using SE21 tcode (or) SE80 tcode also
- click on create
- package type(development)
- continue
- save
- continue
it consist of object name, short description, owner, source client, target client, project, date,
status.
<INSTANCE>k<9xxxxx>.
EX :
ZMEK900021
ZME - instance
k - is constant
TR : transport request
*************************************************************************************
*****************
ABAP Programming :
ABAP Features :
- using 40% of Assembly language and 60% C,C++ initially ABAP was developed
WRITE
write
Write
- is typed language
- ABAP Editor is a development tool , which is closely integrated with ABAP Workbench
- click on create
- test / F8
every program must belongs to any one of the below program type
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
- 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.
- Single line comment : place * symbol at first column position, then entire line treated as
comment line
- Operators List :
+ addition operator
- subtraction operator
* multiplication operator
= EQ
<> >< NE
> GT
>= GE
< LT
<= LE
LIKE
IS INITIAL
*- Separators : are used to separate two things, do not require space before and after
- hyphen
~ tilde
/ slash
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 )
Declarations
Operations
Output
- can be classified as
are valid for all programs, all function modules, all global
classes ..and so on.
Char <- c
Numc <- n
Dats <- d
Tims <- t
Int4 <- i
Fltp <- f
Dec <- p
- fixed length
c character
n numeric character
d date
t time
i integer
f float
p packed decimal
- variable length
- structure types
- table types
- data references
- object reference
- classes
- interfaces
can be classified as
- Character Literals :
- Ex : 'Ravi'
'WB24 1234'
'SAP R/3'
- Numeric Literals :
- sequence of numbers
- Ex : 123
-456
'789'
Ex :
DATA n1 TYPE i.
Ex :
: is chain operator
it concatenates many statements with comma and finally ends with period
- using = operator
<field> = '<value>'.
n1 = n2 = n3 = 10.
- Parameters statement generates selection screen, to accept single value from user,
syntax :
IS NOT INITIAL
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
syntax
Ex :
Ex :
- 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
Note :
Unicode point of view, one character occupies either 2 bytes (or) 4 bytes
it occupies 8 bytes
Numeric Character : is special data type, which is used to display zip code (or) postal codes
X - Hexadecimal : (0123456789abcdef)
String Operations :
CO - contains only
CA - contains any
CS - contain string
CP - contain pattern
syntax : IF <condition>.
---<st block>---.
ELSE.
---<st block>---.
ENDIF.
syntax : IF <condition1>.
---<st block1>--.
ELSEIF <condition2>.
---<st block2>--.
ELSEIF <condition3>.
---<st block3>--.
ELSE.
---<statement>--.
ENDIF.
syntax :
CASE <field>.
WHEN 'val1'.
----<statment1>---.
WHEN 'val2'.
----<statement2>---.
WHEN 'val3'.
----<statement3>---.
---------------------------.
---------------------------.
WHEN others.
---<statement>---.
ENDCASE.
- Do Loop :
syntax :
DO <n> TIMES.
-----<statement block>---.
ENDDO.
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 :
- 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 :
- Version Management :
while activation of the object , system generates one active version at development database
we can generate several versions for each modification and keep it into native version database
- Attributes screen -> Fixed point Arithmetic : is activated by system default for all programs.
*************************************************************************************
- variables can be declared using predefined type (or) local type
structure component
table field)
- syntax :
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
- after execution of ABAP statement , system automatically fills the sy-subrc value
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
*************************************************************************************
************
Syntax :
----------------------------------,
----------------------------------,
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 )
<structure>-<field>.
- using = operator
MOVE keyword is used to move source structure field value to target structure
IS NOT INITIAL
- clear statement is used to reset structure field values back to initial values
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)
---------------------------------------------,
end of <structure>.
- structure type is used while creation complex data objects ( structure and internal tables )
scope is local
- global structure type : is defined in ABAP Dictionary, valid for all programs
scope is global
-------------------------------------------,
END OF <st_type>.
*- Internal Tables :
- 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
-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
-4 read
-5 loop...endloop
- other operations
-6 sort
-7 modify
-8 collect
-9 delete
- deleting data
-10 clear
-11 refersh
-12 free
- are used to perform SQL operations(SELECT / INSERT / UPDATE / DELETE) on database tables
- internal table data can be downloaded into files / uploaded from files
- by default it is created with 8kb memory, if 8kb is filled then system allocates 12kb
memory, and so on... up to 2GB
- is old syntax
- it consist of 2 components
- header line : is implicit work area, which holds only one record at a time
can hold many records at a time as line by line (or) row by row
- Limitations :
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
- is new syntax
- it consist of 2 components
- explicit work area : is created explicitly, which holds only one record at a time
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 )
internal table and work area can be addressed directly by its name
- work area and internal table structure is same and memory is different
- Index
- Standard Index
- Sorted Index
- Hashed
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
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
- no limitations
- are rarely used and recommended If the internal table to be created in a sorted order by
default
- 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
end of ty_kna1.
- components of structure type, becomes columns of internal table and work area
- 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 ,
*- SELECT statement is used to fetch (or) retrieve (or) read data from database table and populate
into internal table
loop statement always start reading from internal table first record to till
last record
-----<display wa content>----.
finally it terminates
this syntax only reads index matching records from internal table
this syntax only reads condition matching records from internal table
Whenever WITH key is used , it is recommended to use Binary Search addition for quick search.
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
first new entry must be filled in work area, then perform append operation
syntax :
*- Insert : statement is used to insert new record at specified index position of internal table
new entry must be filled into work area first, later use insert statement
syntax :
syntax :
SORT <itab>.
this statement modifies all condition matching records with new values
Syntax :
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
syntax :
syntax :
CLEAR <wa>.
CLEAR <itab>.
syntax :
REFRESH <itab>.
*- FREE : statement is used to remove internal table entries and allocated memory also
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 )
syntax :
OCCURS <memory>
KIND <type>.
*- appending many records from source internal table to target internal table
*- inserting several records from source internal table into target internal table
INSERT LINES OF <itab1> FROM <indx > TO <indx INTO <itab2> INDEX <indx>.
*- sy-dbcnt is a system field, which provides number of records effected after open SQL
operation(INSERT / UPDATE / DELETE / SELECT)
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
internal tables types are used while creating complex data object internal
table in the program
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.
END OF itab.
0 allocates memory
*************************************************************************************
*************************
Modularization Techniques :
- Modularity is a programming technique, where large size program is divided into small modules (or)
blocks and dealing with individual modules
- Advantages :
- macros
- includes
- subroutines
- function modules
- Includes :
Parameter passing between include program and executable program is not possible
it is mainly useful for program type 'M' and program type 'F'.
- Include classification
Procedures :
is a set of statements which begins with FORM keyword and ends with
ENDFORM keyword
FORM <subroutine>.
----<statements>---.
ENDFORM.
PERFORM <subroutine>.
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
#include <stdio.h>
main()
int a, b, c;
a=10;
b=20;
c=add(a,b);
printf("%d",c);
add(x,y)
int z;
z=x+y;
return(z);
- Pass by reference
- Pass by value
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
*- Pass by Reference : while subroutine call perform statement sends (export) address of
actual parameters to subroutine.
formal parameter doesn't have separate memory, but in turn they point
to the address of actual parameters
*- Pass by Value : while subroutine call perform statement sends(export) value of actual
parameters to subroutine.
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
*- 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.
- External Subroutines : are created under program type 'S' - subroutine pool
PERFORM <ex_sub>(program).
*************************************************************************************
***
Function Modules :
is a Repository Object
continue
In order to perform operations function module must be declared with formal parameters
As a Rule, Formal and Actual parameters number and datatype should be same.
scenario1 :
- pass by ref :
- 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
Import tab :
import formal parameters import (accept) the values send by calling programs
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
Export Tab : is used to declare formal export parameters with in the function module
Note : SAP recommends that use Import and Export tabs as Pass by value
Scenairo3 :
- declare import parameters with default values, check pass by value check box
changing tab is used to return the changed value back to calling program
Scenario4 :
begins with t_
- activate , test
- while processing function module, if system come across typical statements, it triggers runtime
error
- we can plan in advance and implement exceptions ,in order to avoid runtime error
RAISE <exception>.
- while calling function module in executable program, system automatically fills and assigns sy-
subrc value to exceptions
Notes :
- Attributes tab :
calling syntax :
calling syntax :
- calling syntax :
- short description
- function group
- package
- application component
*************************************************************************************
***********
BAPI explorer provides list of Business objects in Hierarchical view and Alphabetical
view
Hierarchical view displays all business objects and Application component wise
mm-pur
->interfaces
-> attributes
-> events
-> All SAP defined BAPI function module names begins with BAPI_
-> User defined BAPI function module names should begins with Ybapi (or) zbapi
-> import and export parameters are created by making use of bapi structures
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 ->
********************************
RFC is a interface , which provides communication between SAP systems (or) non-sap
systems
webRFC
- ALE is a SAP proprietary technology used to distribute master data (or) transaction data
in distributed system
first system ,which sends data is called outbound system (outbound process)
second system, which receives data is called inbound system ( inbound process)
- ALE uses RFC configuration, while establish connection between external servers
- IDoc is intermediate document, is carrier which carries data from one system to another system
*************************************************************************************
**************
6 types of message :
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.
MESSAGE <msgtyp><msgno>.
Ex :
MESSAGE I000.
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
Abort (or) Abend message : appears in special screen with model dialog box
MESSAGE <msgtyp><msgno>(messageclass).
Ex :
message i000(zmsg_cls).
Ex :
are reusable
While program execution, program concern message statement sends values to message class
message statement
*************************************************************************
Write Formats :
************************************************************************************
- Dialog Screens
- Selection Screens
- List Screen
- Dialog screens are special screens , which are used to perform business transactions
- Selection screens and List screens are used in Reporting (type 1 programs)
write statements and write formats are used to display output as per client requirement
- Selection Screen :
- PARAMETERS :
syntax :
selection text is used to provide alternative long text for parameter field
- Parameters with DEFAULT addition is used to provide default values to selection screen field,
- 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
- VISIBLE LENGTH addition is used to display input field with specified length, but it accept
value as defined length
- SPACE
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
click on save
- short description
- save
notice that system generated get variant option, which is useful to choose any
variant from the available variants list
*- Syntax of parameters :
this syntax is used to create parameter field, by making use of database table field
*- Syntax of Selection-Screen :
------------parameters
------------select-options
SELECTION-SCREEN skip.
SELECTION-SCREEN uline.
---parameters
---parameters
System displays standard 1000 selection screen first ,next system display custom selection screen
100.
user actions on selection screen can be handled under AT SELECTION SCREEN event
UCOMM component holds the function code value dynamically based on user interaction on
selection screen push button
Syntax :
select-options field name should begins with so_, it must be up to 8 characters long,
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
this internal table always created as old syntax (with header line)
BT - between ( default )
NB - not between
EQ - equals to
NE - not equals to
GT - greater than
LT - less than
using this icon user can set / reset include single value or include range of values ,
- Advantage of this selection table is : user can dynamically specify the values to fetch data
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 is a built-in internal table which provides several screen field attributes
LOOP AT SCREEN
if screen-name = '<fieldname>'.
screen-<attribute> = 1 or 0.
modify screen.
endif.
ENDLOOP.
by referring modification group, we can apply common attribute to all fields at a time
*************************************************************
sy-subrc and sy-dbcnt system fields are recommended to use for each open SQL
statement
first fill work area , and use below statement to create single record
fill multiple records into internal table, then use below statement to create many
records
Syntax :
Syntax :
- SELECT : statement is used to read / fetch / retrieve data from database table
WHERE <condition1>
GROUP BY <column>
HAVING <condition2>
ORDER BY <column>.
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
*- declare variable as target area, populate it using SELECT single <field> statement
*- UP TO <n> ROWS addition is used to read records from database table based on index
*- GROUP BY :
if several records have similar data, then we can apply group by on column .
HAVING :
followed by condition
*- DISTINCT :
*- CLIENT SPECIFIED :
*- Aggregate functions : are used to perform Arithmetic operations along with Select Statement
KNA1 <-> KNB1 <-> KNC1 ( common field is KUNNR - customer no)
*- Inner Join : reads the data from both tables using join condition
*- For all entries : is used while populating current internal table, while comparing existing
internal table
***********************************************
Inter program Communication : this topic deals with program to program communication
syntax :
SUBMIT <program>.
- syntax :
this syntax calls the another executable program and while returning it display currnt program output
- syntax :
this syntax calls other program concern selection screen first, then display output
- syntax :
this syntax calls the specified tcode , and while returning it executes current program remaining
statement
- syntax :
- syntax :
this syntax leaves the current program and calls the specified tcode, while returning control transfer
to SAP Easy Access
SET parameter statement sets the value from program to SAP memory
GET parameter statement reads the value from SAP memory to other program
syntax :
Fieldname Parameter ID
KUNNR KUN
MATNR MAT
LIFNR LIF
VBELN AUN
BUKRS BUK
whenever user logs in, system reads values from user profile and display
system menu -> user profile -> own data -> parameters tab ->
*- Parameters and SELECT-OPTIONS can also be defined with parameter id, using MEMORY ID addition
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
Export statement exports the value from internal session to ABAP memory
Import statement imports the value from ABAP memory to other internal
session
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
when substructure components are assigned with value (used), then it revoke the reference from
PXA to modifiable memory
*************ABAP Reporting :
- All SAP defined built-in reports are available under information system
- Interactive Reports
- ALV Reports
- ABAP Query (or) SAP Query : are generated by Functional consultant, without programming
knowledge
- events are not triggered as the sequence it was written in the program
AT SELECTION-SCREEN ON seltab.
***********************
START-OF-SELECTION.
END-OF-SELECTION.
TOP-OF-PAGE.
END-OF-PAGE.
*************************************************************************************
****************
Steps :
- click on create
- continue
- check, test
**************************************************************************
Note : Custom List heading and column headings can be provided using text elements
*************************************************************************************
***********************
- Indexes
- Buffering
- do not use select ...endselect loop, use Array Fetch (into table)
- 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
- do not use nested select statements , use for all entries (or) parallel cursor
- Performance Tools :
- ABAP Debugger
ABAP Editor -> environment menu -> examples -> performance examples
- it checks performance checks, security checks, extended program check, user interfaces
- path from ABAP Editor : Program menu -> check -> code inspector
- path from SAP Easy Access : SAP menu -> tools -> ABAP Workbench -> test -> code
inspector
*****************************************************************
Authorization :
- in general select statement doesn't perform authorization check by default, we have to explicity
implement authorization check
02 - change,
03 - display
- Step3 : tcode : SE93 : while creating tcode for executable program, ie.,Report Transaction,
call pattern, choose authorization radio button, specify authorization object, continue
check sy-subrc.
*---------
- command /h
- Classic Debugger :
F8 - run - it stops debugger and executes rest of the program at a time, procced to next
screen
- execute
Break-points :
- is a signal in the program source code, where system stops processing and starts debugger
BREAK-POINT.
BREAK-POINT <n>.
BREAK <username>.
hard coded
- Watch Points :
unlike Break points, watch points are used to watch the program changes
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'