Core Abap Notes
Transcript of Core Abap Notes
-
7/30/2019 Core Abap Notes
1/38
1 | P a g e S a n t o s h P
VINAYAKA
SAP: - (System Applications and Products in data Processing).
ABAP: - (Advance Business Application Programming)
Programming Languages: - C, C++, Java, .Net.
Packages: - Word, Excel, Tally, Focus, Wings
Operating System: - Dos, Windows, Unix, Linux..
Database: - Oracle, Sql Server, Mysql.
ERP Products: - SAP, Oracle Applications, Siebel, CRM..
Package: - Package is a set of rebuild instructions. Readymade built in functions.
Database: - Database is stored the data permanently.
Enterprise: - Organization or Company.
Resource: - Money Finance,
Man power HR,
Material Material Management,
Machinery Production,
Marketing Sales.
Planning: - How to utilizing the resources in a efficient way.
To integrate the department
Every Company to prepare the department
SS
1) Front end department2) Back end department1) Front end department: - Market, Sales.Customer directly interacting.
2) Back end department: - Hr, Finance, Production, Purchase, Inventory.
-
7/30/2019 Core Abap Notes
2/38
2 | P a g e S a n t o s h P
YES
ENQUIRER
NOPLACE ORDER ROW
METERIAL
SALES ORDER
FRONT END DEPARTMENT RAW MATERIAL
NOT AVLIABLE
VENDOR 1CHECK FOR STOCK VENDOR 2 FUNDS
VENDOR 3
BACK END DEPARTMENT
Types of consultant in sap project: -
1) Function consultant2) Technical consultant3) Techno functional consultant4) Basis consultant
FUNCTION TECHNICAL
1)
SAP FICO 1) ABAP2) SAP HR 2) HR ABAP3) SAP MM 3) WEB DYNPRO4) SAP SD 4) CRM TECHNICAL5) SAP CRM 5) WORK FLOW6) SAP PM 6) BI/BW
....N 7) TF
: 8) EP (Enterprise portal)
:
:
Modules
CUSTOMER
QUOTATION
PURCHASE
ORDER
MARKETING
SALES
WAREHOUSE
DEPARTMENTBLILLING
DELIVERY
PRODUCTION
MATERIAL
MANAGEMENT
PURCHASE
FINANCE
-
7/30/2019 Core Abap Notes
3/38
3 | P a g e S a n t o s h P
Role of ABAP Consultant in SAP Project.
1) Analysis understanding of functional specs.2) Preparing technical specs.3) Preparing UTP (Unit Test Plan).4) Build (Development).5) Code review, unit testing, and integration testing.6) Transport management.7) Supporting production issue.DATA: - Data is a keyword used for declaring a variable in an ABAP.
Syntax: - data [:] [value ].
PARAMETERS: -parameter is a keyword it generates a selection screen for reading the
user input.
By default the parameter variables are displayed as labels on selection screen To provide Meaningful description we need to generate text element.
Syntax: - parameters [:] [default ][Lower case] [Obligatory] .
OBLIGATORY: - Obligatory is the keyword used as part of parameters statement to
make a selection screen field as mandatory.
WRITE: - Write statement is a keyword used for display the Output LPS
(List Processing Screen) .
VALUE: - Value is a keyword used as part of data statement to initialize the variables.
CONSTANTS: - Constants is a keyword used for declaring constant variables.
Constant variable must be initializing at the time of declaration. The value for constant variable its fixed throughout the program.
RADIO BUTTONS: - Radio buttons is keyword.
A group of radio buttons only one radio button can be selected.
Radio button can have either of the following values.
X Selected.
Not Selected.
Syntax: -parameters radio button group [default X].
CHECKBOX: - Checkbox is a keyword to select the checkboxs.
Syntax: -parameters as checkbox [default X].
-
7/30/2019 Core Abap Notes
4/38
4 | P a g e S a n t o s h P
DEFAULT: - Default is a keyword to provide the default values.
CONTINUE: - Whenever a continue statement is executed inside a loop. It skips theremaining statements of the loop and the control jumps to iteration.
Before execute the continue statement we need to increment or decrement theiteration variable accordingly. Otherwise the program will be execute indefinite.EXIT: - Whenever exit statement will executed inside a loop. The control comes out of the
looping statement.
If it is executed outside the loop the control comes out of the program.FIELD-SYMBOLS: - A field-symbol is a data structure which can store any kind of data
type.
Field-symbols are declared by using the keyword field-symbols. Field-symbols variable is always enclosed in angular brackets.
Syntax: - field-symbols .
ASSIGN: - It is keyword used for assigning a value to the field symbols.
The variables stored in the field-symbols is called referenced variable. Field-symbols will acts like a pointer i.e. the changes made to the field-symbols
will automatically reflect the reference variable and vice versa.
EDITMASK: - Edit mask is used as part of write statement to convert the data and time
format to the user defined format.
CHECK STATEMENT: - Check is similar to IF. When the check statement condition is
failed the remaining statements of the program will not be executed where as incase of IF
statement. The if statement condition is failed only the if block is ignored i.e. remaining
statements of the program will be executed.
SUBMIT: - Submit keyword is used for calling a report from another report.
If a non existing program is called by using submit keyword its result is runtimeerror. Load the program not found.
NOTE: - By default whenever a program is called using submit keyword the control jump
to called program and control will not returned to calling program.
EXPORT & IMPORT: -
Export statement is used for exporting a variable value to the ABAP memory within a memory id.
Import statement is used for importing a variable value from ABAP memorywhich is stored in a memory id.
-
7/30/2019 Core Abap Notes
5/38
5 | P a g e S a n t o s h P
STRING FUNCTIONS: -
1) STRLEN: - It returns the length of the string.2) CONCATENATE: - It combines multiple strings into single string based on a
d-limiter/separator.
3) SPLIT: - It splits a given string into a multiple substrings based on a d-limiter.4) TRANSLATE: - It converts a given string into a lower case or upper case translate
string to lower case.
5) CLEAR: - Clear is used for clearing the contents of a variable.6) OVERLAY: - It fills the blank spaces of a given string with the appropriate positioned
character of the source string.
7) REPLACE: - By default replace function replaces first occurrence of a pattern with thetarget pattern. By default replace function is case sensitive.
8) TRANSFER: - It is used for writing the content of the variable to the application serverpath.
9) CONDENSE: - Condense statement suppress the blank space in a given string.10)OFFSET LOGIC: - It is used for extracting a position of a string.STRUCTURES: - It is a user defined data type which is a collection of different types of
fields.
Structure is used for storing record kind of information. At any point of time thestructure can store only single record.
Syntax1: -
Data: begin of ,Field 1,
Field 2,
Field 3, parameters statement is
Field 4, not allowed inside statement.
Field n,
End of .
Syntax2: -
Data: like .
NOTE: - Existing structure can be a local structure or it can be a dictionary structure
created in the database.
The above syntax only copies the fields from one structure to another structure.
MOVE: - Statement is used for copying the data between two similar structures. Only
checks for the corresponding fields for data types between two structures. It does not check
for no of fields and fields name.
-
7/30/2019 Core Abap Notes
6/38
6 | P a g e S a n t o s h P
MOVE-CORRESPONDING: - Move-corresponding is used between two dissimilar
structures to copy the values from one structure to another structure. It is recommended not
to use corresponding because of the following reasons.
It decreases the performance of the application. Because each field of the sourcestructure is compared with all the fields of the target structure which is a time
consuming process.
It may lead to runtime error because while copying it only checks for fields name butnot for data type. When the data type mismatches it leads to runtime error.
NESTED STRUCTURE: - Declaring a structure inside another structure.
Syntax: - begin of ,
field 1,
field 2,
begin of ,
field 1,
field 2,
..
end of ,
..
end of .
INCLUDING STRUCTURE: -
Including all the fields of an existing structure into another structure by using
include keyword.
The included structure can be local or dictionary structure.Syntax: - include structure .
TRANSPORT ORGANIZER: - Transport organizer is a tool used for managing the
transports in the development environment.
VERSION MANAGEMENT: - It is the process of comparing two versions in the same
system are across a system and identifying the differences and retrieving the appropriate
version.
-
7/30/2019 Core Abap Notes
7/38
7 | P a g e S a n t o s h P
DICTIONARY OBJECTS: -
1) Database Tables2) Views3)
Data Type4) Type Group
5) Domain6) Search Help7) Lock Object1) Database Tables: - Database tables are three types.
i. Transparentii. Pooled
iii. ClusterTransparent: -
It is used to store application data such as master data transactional data. Wealways create transparent table only.
There is one-to-one relationship i.e. for the table DDIC another table with thesame structure and the same name and the same fields will be created in the
original data base.
Pooled: - It is used for exclusively for storing internal control information. The data from several different pooled tables can be stored together in a table
pool.
This is many-to-one relationship.Cluster: -
Cluster tables are logical tables that must be assigned to a table cluster when theyare defined.
Cluster tables can be used to store control data. They can also be used to storetemporary data or texts, such as documentation.
2) Views: -It is a data dictionary object. It is considered as a pseudo table, A view never occupy any
physical space in the database server.
i. Database Viewii. Projection View
iii. Maintenance Viewiv. Help View
-
7/30/2019 Core Abap Notes
8/38
8 | P a g e S a n t o s h P
Database View: -
Database views are implemented with an equivalent view on the database. Database views are defined in the ABAP dictionary. A database view is
automatically created in the underlying database when it is activated.
Projection View: -
Projection views are used to hide fields of a table. This can minimize interface. A projection view contains exactly one table. You cannot define selection
conditions for projection views.
Maintenance View: -
Permit you to maintain the data distributed on several tables for one applicationobject at one time.
Help View: - Help views can be used as selection method in search helps.
3) Data Type: -i. Data Element
ii. Structureiii. Table Type
Data Element: -
A data element is a reusable dictionary object. Which provides the shortdescription for the field? This description appears automatically on the
transaction.
A data element created at once can be used across many places. Data element can be created either by referring a direct data type or by referring to
a domain.
Structure: - It is a user defined data type which is a collection of different types of fields.
Structure is used for storing record kind of information. At any point of time thestructure can store only single record.
Table Type: -
Table type is an internal table create at a data base level it can be associated with aline type. A line type can be a data element or a structure.
A table type is a global internal existing at the database level. The table type determines how ABAP will access individual table entries. Internal
tables can be divided into three types.
i. Standard Tableii. Sorted Table
iii. Hashed Table
-
7/30/2019 Core Abap Notes
9/38
9 | P a g e S a n t o s h P
Standard Table: - Standard tables have an internal linear index. From a particular size
upwards, the indexes of internal tables are administered as trees. In this case, the index
administration overhead increases in logarithmic and not linear relation to the number of
lines. The system can access records either by using the table index or the key. The response
time for key access is proportional to the number of entries in the table. The key of astandard table is always non-unique. You cannot specify a unique key. This means that
standard tables can always be filled very quickly, since the system does not have to check
whether there are already existing entries.
Sorted Table: - Sorted tables are always saved sorted by the key. They also have an
internal index. The system can access records either by using the table index or the key. The
response time for key access is logarithmically proportional to the number of table entries,
since the system uses a binary search. The key of a sorted table can be either unique or non-
unique. When you define the table, you must specify whether the key is to be unique or not.
Standard tables and sorted tables are known generically as index tables.
Hashed Table: - Hashed tables have no linear index. You can only access a hashed table
using its key. The response time is independent of the number of table entries, and is
constant, since the system accesses the table entries using a hash algorithm. The key of a
hashed table must be unique. When you define the table, you must specify the key as
UNIQUE.
4) Type Group: -They define data types in a type group in the ABAP/4 Dictionary insteadof defining them within an ABAP/4 program. The type group name in the ABAP/4 Dictionary has a maximum of 5 characters.
Type names within type group must begin with followed
by an underscore.
The types in a type group must be declared in ABAP/4 programs with the TYPE-POOLS command.
Syntax: - types-pools /.
5) Domain: - A domain is a reusable dictionary object which stores technical properties of the
field. The technical properties include data type, size, value range, value table.
6) Search Help: - Search help are two Types.i. Elementary Search Help
ii. Collective Search HelpElementary Search Help: - describe a search path. The elementary search help must define
where the data of the hit list should be read from (selection method), how the exchange of
values between the screen template and selection method is implemented (interface of the
search help) and how the online input help should be defined (online behavior of the search
help).
-
7/30/2019 Core Abap Notes
10/38
10 | P a g e S a n t o s h P
Collective Search Help: - combine several elementary search helps. A collective search
help thus can offer several alternative search paths.
7) Lock Object: -
The R/3 system synchronizes access of several users to the same data records witha lock mechanism. When interactive transaction is programmed, locks are set and
released by calling modules. These function modules are automatically generated
from the definition of lock object in the ABAP dictionary.
.Include: -
.Include is a keyword used at the field level to include a dictionary structure in
another dictionary structure.
Corresponding Fields: -
As part of select query when the no of fields or sequence of fields retrieved from
database table is not matching with the target internal table or structure then we need to use
corresponding fields statements in the select query.
Describe: - Describe table statement counts the no of records in the internal table and stores
the count value in the system field SY-TFILL.
Select-Options: - It is the internal table provided by sap which is associated with 4 fiedls.
1)LOW2)HIGH3)OPTION4)SIGN
LOW: - It will stores lower limit.
HIGH: - It stores upper limit.
OPTION: - Possible values are , =, bt (between, default)
SIGN: - I (inclusive, default) or E (exclusive).
Selection-options are used for reading the range of values.INITIALIZATION: - It is the event triggered by sap before displaying the selection
screen. It is used for initializing the selection screen fields. It is triggered only once in the
life time of a selection screen.
-
7/30/2019 Core Abap Notes
11/38
11 | P a g e S a n t o s h P
Insert: - Insert statement always inserts a new record and ignores records if it already
exists. It only checks for primary key field values.
While inserting the data into database table from an internal table it is alwaysrecommended to use modify statement instead of insert statement. Because incaseof insert if the duplicate record is found it results in runtime error.
To avoid the runtime errors use accepting duplicate keys. Without acceptingduplicate key we have a runtime error. But this is not recommended.
Modify: - modify statement it insets a new record or update the existing records.
Clear: - Each & every time we will write clear statement. It clears the local structure
clearing from work area.
Syntax for inserting data into database table from an structure: -
Insert/modify from table .
Syntax for inserting data into database table from an internal table: -
Inset/modify from table
Read Statement: - It is used for reading a specific record from the internal table. Read
always reads the single record even if there are multiple records satisfying the conditions. Read statement can be used either based on an index or based on a condition. By default read follows linear search first to last. The index of the internal table starts form 1. It is always recommended to use the read statement to sort the internal table
before using binary search.
Transporting: - By default read statement transports all the fields between body to work
area.
To transport only specific fields use transporting keyword as part of readstatement. This improves the performance.
SELECT ENDSELECT: - Select end select is considered as database loop and it retrieves
single record per request.
Select-endselect it always retrieves single record per request. The no of select queries depends upon the no of records satisfying the criteria. It there are more no of select queries it increases the network traffic there by
decreases the performance. This is the reason it is recommended not to use select-
endselect.
-
7/30/2019 Core Abap Notes
12/38
12 | P a g e S a n t o s h P
Standard SQL: - It is a set of SQL statement to interact with database systems from the
front end applications like Java, .net etc..
From ABAP we can use two type of SQL statement.1. Open SQL2.
Native SQL
Open SQL: -
Native SQL: - Every database vendor provides a set of SQL statements to interact with
their own database systems. This statements are specific to database.
Note: -
For native SQL the variables are preferred (:) bind variables. It should not end the statement with (.) period & separate the variable by comma
(,) to select query.
Note: -
Native SQL statements always embedded between execute SQL and end execute.Cursors in open SQL: - A cursor is a special data structure it can be use for storing
multiple records by using cursors we can avoid the usage of internal tables.
Step1: - Declare the cursor.
Syntax: - data : type cursor.
Step2: - Open the cursor.Syntax: - Open cursor for .
Note: -
Only select statement can be associated with cursors. Whenever a cursor is opened a select statement associated with the cursor will be
processed and the output of the select query is called as active set.
Step3: - Read the cursor contents.
Syntax: - Fetch next cursor into .
Step4: - Close cursor .
Cursors in native SQL: -
Step1: - Open the cursor.
Syntax: - Open for .
Step2: - Read the cursor contents.
Syntax: - Fetch next into .
-
7/30/2019 Core Abap Notes
13/38
13 | P a g e S a n t o s h P
Step3: - Close the cursor.
Syntax: - close .
Message classes: - A message class is a collection of messages. In a single message class
we can store up to 1000 messages. The message internal value ranges from 000 to 999. Se91 is a T-CODE used for creating and managing message classes.
Types of message: -
I (information)
W (warning)
S (status)
E (error)
A (abort)
Once we create message class we will use it anywhere of those classes.Note: - Depending upon the sicbret of the message we can use the appropriate message
type.
Syntax: - message .
MESSAGE MESSAGE SHORT TEXT
000 RECORD INSERTED001 RECORD NOT INSERTED
002 RECORD MODIFIED
003 RECORD NOT MODIFIED
004 RECORD DELETED
005 RECORD NOT DELETED
006 RECORD FOUND
007 RECORD NOT FOUND
Joins: - Joins is used to extract the data from several tables by joining them together witha common field. If the field is replaced in several tables we need to identify that field along
with table name, hence ~ (tilt symbol) is used along with the table allies name in order to
uniquely identify a field from specified table. Joins are two types.
1)Inner join2)Outer join
1) Inner join: - This type of join will retrieve the data from multiple tables if the data isfound commonly in all the tables, if any one of the table doesnt contain for the given
condition no data is extracted from any of a table, only transparent tables can be used
within the joins.
-
7/30/2019 Core Abap Notes
14/38
14 | P a g e S a n t o s h P
TABLE A TABLE B
A B C D D E F G Ha1 b1 c1 d1 d1 e1 f1 g1 h1
a2 b2 c2 d2 d2 e2 f2 g2 h2
a3 b3 c3 d1 d3 e3 f3 g3 h3
a4 b4 c4 d4 d2 e4 f4 g4 h4
a5 b5 c5 d5 d5 e5 f5 g5 h5
Table A Inner join Table B
A B C D D E F G H
a1 b1 c1 d1 d1 e1 f1 g1 h1
a2 b2 c2 d2 d2 e2 f2 g2 h2
a2 b2 c2 d2 d2 e4 f4 g4 h4
a3 b3 c3 d1 d1 e1 f1 g1 h1
a5 b5 c5 d5 d5 e5 f5 g5 h5
2) Outer join: - Whenever you used the right side table record with left side table, if thecommon record found in both table then the system will extract the data from both
tables. It for the specified field, the record does not exist in right side table, then systemwill extract left side record into consideration.
TABLE A TABLE B
A B C D D E F G H
a1 b1 c1 d1 d1 e1 f1 g1 h1
a2 b2 c2 d2 d2 e2 f2 g2 h2a3 b3 c3 d1 d3 e3 f3 g3 h3
a4 b4 c4 d4 d2 e4 f4 g4 h4
a5 b5 c5 d5 d5 e5 f5 g5 h5
-
7/30/2019 Core Abap Notes
15/38
15 | P a g e S a n t o s h P
Table A Left Outer Join Table B
A B C D D E F G H
a1 b1 c1 d1 d1 e1 f1 g1 h1
a2 b2 c2 d2 d2 e2 f2 g2 h2a2 b2 c2 d2 d2 e4 f4 g4 h4
a3 b3 c3 d1 d1 e1 f1 g1 h1
a4 b4 c4 d4 0 0 null 0 null
a5 b5 c5 d5 d5 e5 f5 g5 h5
Modularization Techniques: - Modularization is a process of breaking the program into
individual modules. By modularizing the following are the advantages.
1) Increases reusability2) Better maintenance3) Performance improvement4) Readability5) Controlling the flow of the programInternal Subroutines: -
Syntax: - Syntax for calling internal subroutine performs.
[parameter list].
Syntax: - Syntax for defining internal subroutine form.
[parameter list].
Navigations in break points: -
1) F5 (SINGLE STEP): - It executes single step at a time.2) F6 (EXECUTE): - It is similar to F5 but when F6 is pressed at the time of calling a
block. (Subroutine, method, function module). The time of calling the entire statements
of the block will be executed as a single step.
3) F7 (RETURN): - When F7 is pressed inside a block the entire remaining statements ofthe block will be executed as a single step and the control comes out of the block and
cursor is placed in the next statement after the block called.
4) F8 (RUN): - When F8 is pressed the control jumps to next available break point if notavailable the entire program will be executed as a single step.
Pass by reference: - In pass by reference the address of actual parameters are passed as
parameters to formal parameters, so any changes made to formal parameters will
automatically reflect the actual parameters.
-
7/30/2019 Core Abap Notes
16/38
16 | P a g e S a n t o s h P
Pass by value: - In pass by value the values of actual parameters are copied to formal
parameters. Any changes made to formal parameters will not reflect actual parameters value
is a keyword used to pass the parameters by value.
Function Module: - Function module is a set of statements it is defined only once and itcan be called any no of times. It is developed by using function builder tool. Function
module is stored inside function group.
Function group: - A function group is a repository object with can contain different type of
repository object like function modules, Classes, subroutines, etc.
Function group can be created by using SE80/SE37. Whenever a function group iscreated two include programs will be created.
1) Include ending with TOP: - It is called as top include file and it can contain globaldeclarations, subroutine definitions and module definitions.
2) Include ending with UXX: - It is include generated for sap purpose. In this sub include will be generated. Whenever a new function module is created. Each sub include is reference to a function.
Sections in function builder tool: -
1) Importing: - these are the parameters received by function module.2) Exporting: - these are the parameters returned by function modules.3) Changing: - This will act as both importing & exporting. 4) Tables: - These are used for interacting with internal table as parameters. This can be
use both as import & export.
5) Exception: - These are used for interaction with user defined exceptions.6) Source code: - In this the function module is implemented.Note: - By default the function module type is normal & it is client independent object i.e. a
function module created at one type can be accessed from other client for the same server.
Syntax for calling normal function: -
Call function [parameter list] .
Syntax for defining normal function: -
Function < function name > .
Statements.
End function.
-
7/30/2019 Core Abap Notes
17/38
17 | P a g e S a n t o s h P
Exceptions in function modules: -
An exception is a runtime error which is raised during the execution of a program. Exception handling is a process of handling the runtime errors and continues the
program execution without termination. In function modules we can handle the standard exception by using try & catch.
Example: - O/P: - 66/0 It is runtime error exception occurs.
We can handle the standard exceptions by using try & catch blocks. Inside the try block we need to keep these statements where the possible error
might occur.
Inside the catch block we need to handle the exception. The catch block is placedimmediately after the try block.
Whenever an exception is raised in the try block SAP creates the appropriateexception class objects and the control is transferred to catch block.
Catch CX_ROOT is parent class of catch we cant sure able to the choose classwe can use CX_ROOT.
User defined exception in function modules: -
In case of system defied exceptions the standard exception is declared & raised bySap itself & it is handled by the developer.
In case of user defined exceptions it is declared raised and handled by thedevelopers.
Step 1: - Declare the user defined exceptions in the exception tab of the function module.
Step2: - Raise the exception in the source code at the appropriate place by using raise
statement.
Step3: - Handle the exception I the calling program by checking the SY-SUBRC status.
Note: - If no exception is raised SY_SUBRC set to ZERO.
Macro: - If you want to reuse the same set of statements more than once in a program, you
can include them in a macro.
It is used in HR-ABAP
Macro is a predefined constant which can hold 9 different placeholders. (parameters).
Syntax for defining macro: -
Define .
Statements with place holders.
End-of-definition.
-
7/30/2019 Core Abap Notes
18/38
18 | P a g e S a n t o s h P
Syntax for calling macro: -
value1 value2value9.
Note: - All the standard macros which are part of HR functional modules Its stored in the
table TRMAC.
Selection screen programming: - It is used for generating a selection screen which can
contain different types of component.
A selection screen can contain following component.
1) I/O FIELDS.2) CHECK BOXES.3) RADIO BUTTONS.4) PUSH BUTTONS.5) BLOCKS.6) TABBED BLOCKS.7) TAB BUTTONS.8) LABELS.
Syntax for designing labels: -
Selection-screen comment () .
Event handling: -
Events only write at the last. As part of ABAP they are many events provided bySAP, which are triggered at different places.
As part of selection-screen they are different events triggered.1) Initialization: - This event is triggered before displaying the selection-screen. It is
triggered only one time of life time in the selection screen. It is used for initializing the
selection screen.
Syntax for designing blocks: -
Selection-screen begin of block with frame [title ].
Selection-screen begin of block b2 with frame title pqr.
Syntax for designing push buttons: -
Selection-screen push button () user-command
.
2) At selection-screen output: - This event is used for controlling the screen display in htruntime. I.e. it is used for refreshing the elements of the screen in the runtime.
This event is triggered after initialization event as well as after at selection screenevent, i.e. it is triggered at least once before displaying the selection screen.
-
7/30/2019 Core Abap Notes
19/38
19 | P a g e S a n t o s h P
Note: - Screen is a structure provided by SAP this structure will act as internal table in the
run time. This structure holds the information of the screen-elements.
3) At selection-screen: - This event is triggered in the following cases.
When the user presses enter key in the I/O field. When the user clicks on selection-screen push buttons. In this case the function code of the push button is captured in the system field SY-UCOMM.
Note: - If a data element is associated with a search help then by default f4 help available
provided for the field whenever it is used on selection screen or dialogue screen.
It the search help is not attached with the data element level then manually weneed to attach f4 help. For a selection screen field or a dialogue screen field.
4) At selection-screen on value-request: -This event is triggered when the user presses f4 key on a selection-screen I/O field.
F.M:- F4IF_INT_TABLE_VALUE_REQUEST
Is a function module used for displaying the internal table contents as a list of values.
Whenever k4 key is pressed on a field.
Selection-screen tabbed blocks: -
A tabbed block is a collection of tabbed button. Each tab button is associated with a sub screen a sub screen is a part of a screen.
Syntax: -
slection-screen begin of tabbed block for lines.
Declaration of tab buttons.
Selection-screen end of block .
Note: - If the tabbed block does not have any tab buttons then it results to runtime error.
Dynpro does not exist.
Syntax for declaring tab buttons: -
Selection-screen tab () user-command .
Selection-screen begin of screen 100 as subscreen.
Selection-screen begin of lines.
Selection-screen end of line.
-
7/30/2019 Core Abap Notes
20/38
20 | P a g e S a n t o s h P
Syntax for sub screens: -
Selection-screen begin of screen as subscreen.
Properties of tabbed block: -1) Active tab: - It holds the function code of the tab button which needs to be activated.2) Program: - It holds the name of the program where the sub screen is existing.3) Dynnr: - It holds the sub screen no, which needs to be associated with the active tab.Adding push buttons on selection-screen application toolbar: -
Syntax: -
Selection-screen function key .
Where can be 1,2,3,4,5..
Menu painter (se41): -
It is used for defining the custom GUI status for a dialogue screen (Or) for a LPS
(list processing screen) as part of this new GUI status we can add additional menus. Enable
or disable the standard tool bar push buttons and we can add 35 push buttons on the LPS
application tool bar.
We can enable the menu painter by using the statement set pf-status
Syntax: - The GUI status must always be in upper case.
Set pf-status .
When for the custom GUI status SAP loses the standard GUI status.
As part of the custom GUI status on LPS if we associate the standard function code for the
standard tool bar buttons. Then standard function code for the standard tool bar buttons.
Then both the buttons as well as the functionality will be enabled.
It we associate the user defined function codes then only then buttons are enabled without
the functionality in this case we need to enable the functionality. By handling the event at
user command.
Dialog programming (module pool programming): -
It is used for developing user defined transaction. A transaction cannot executed of its
own. It must be associated with a T-code.
As part of this they are 4 events associate.
1) PBO (process before output)2) PAI (process after input)3) POV (process on value-request)4) POH (process on help-request)
-
7/30/2019 Core Abap Notes
21/38
21 | P a g e S a n t o s h P
PBO: - It is similar to at-selection-screen output event. It is executed before the transactions
are displayed as well as after PAI event.
PAI: - This event is similar to at selection-screen event. It is triggered in the following
cases. When the user selects or deselects a check box or a radio button. When the user presses enter key in the I/O field. When the user clicks a push button. When the user selects a value from the dropdown list box.
POV: - This event is similar to at selection-screen on value request. It is triggered when the
user presses f4 key in the I/O field. It is used for associating custom f4 help for a
transaction I/O field.
POH: - It is similar to at selection-screen on help request. It is triggered when the user
presses f1 key on a transaction field. It is used for associating custom f1 help for a
transaction field.
Tab strip control: - It is a component in module pool which is a collection of tab buttons.
A tab button is associated with a sub screen. A sub screen cannot sit directly on normal screen. It must be placed on top of
screen areas.
Sub screen area is a container of sub screens. A single sub screen area can be associated.
With any no of sunscreens If a screen contains tab strip control it must be declared
explicitly. By using the keyword controls.
Syntax for declaring tab strip control: -
Controls type tab strip.
Syntax for calling normal screen: -
Call screen .
Syntax for calling subscreens: -
Call sub screen including .
Note: - As part of module pool program a top include file can be created which can be used
for declaring global variables. These variables can be used across the screens in the
module pool programs.
Sections in screen painter tool: -
-
7/30/2019 Core Abap Notes
22/38
-
7/30/2019 Core Abap Notes
23/38
23 | P a g e S a n t o s h P
Note: - Whenever the validations are failed on a transaction. SAP doesnt allow performing
any action by default. In most of the times the user wants to exit the screen without
submitting the fields values of the transaction. This can be achieved to the cancel button.
But if the transaction fails at least one validation. The user cannot exit the button. So in
these cases explicitly we need to create a button which acts as a cancel button.
2) Flow logic validations: - These validations are designed by developer in the flow logic.On a transaction if any field is failing the flow logic or module pool validation the
other fields on the transaction are disabled not allowing the user to input the values.
This can be avoided by using chain end chain.
Chain-endchain is used for grouping the logically related fields.3) Module pool validations: - In automatic field validation and flow logic validation.
Whenever a field fails a validation. The error messages are provide by SAP.
As part of module pool validations we need to declare the module in flow logicand implement in the module pool program.
As part of this implementation the developer can provide the user defined themessage.
Table control: - Table control is a component in module pool transaction used for
representing a data in table or format. (in the form of rows & columns).
Whenever a functions contains table control component it must be declared explicitly by
using controls keyword.
Syntax for declaring table control: -Controls type table view using screen .
By default table control supports only horizontal scrolling properties. I.e. it doesnot support vertical scrolling.
Vertical scrolling properties should be enabling explicitly by using settings linesproperties of the table control.
File handling on application server: -
Opening the file: -
Syntax: -
Open dataset for in [encoding
default] [message ].
File opening mode: - input for reading.
Output for writing.
Appending for appending contents to end of file.
Update for reading/ writing.
Perform the operation [Read/Write].
-
7/30/2019 Core Abap Notes
24/38
24 | P a g e S a n t o s h P
1) For Reading: -Read dataset into .
Note: - Whenever a file is opened in text mode read data-set statement reads the content
from the file line by line in case of binary mode it reads byte by byre.
If the read is successful sy-subrc is set to 0 otherwise 4.
2) For writing: -Syntax: - transfer to
3) Close the file: -Syntax: - Close dataset .
Note: -
It a non existing file is open in output mode. SAP creates the file and the filepointer will be at the beginning of the file for writing the new contents.
Whenever an existing file is opened in output mode. SAP opens the file, deletesthe existing contents and places the file pointer at the beginning of the file for
writing new contents.
BDC (Batch Data Communication): - BDC techniques are used for transferring the data
from legacy system to sap. The legacy system can be any text file or excel sheet.
BDC Techniques: -
1) Direct input method.2) Call transaction.3) Session.Call transaction & session methods are called as Batch Input Methods.
Data migration using call transaction method: -
Data Transaction: -
Legacy Internal BDC data Transaction R/3
System Table Internal Table (Screen)
Call Transaction Method
-
7/30/2019 Core Abap Notes
25/38
25 | P a g e S a n t o s h P
As part of call transaction and session method we need to map the legacy system data on to
a transaction for this we need to use the structure BDC data provided by SAP. It contains
following fields.
PROGRAM: - It holds the name of the module pool program.
DYNPRO: - It holds the module pool screen no.
DYNBEGIN: - It is a flag indicator for the occurrence of a new record.
FNAM: - It holds the module pool screen field name.
FVAL: - It holds the field value retrieve name from the legacy system and which needs to
mapped to the transaction fields.
For data migration using BDC migration using BDC techniques the ABAP consultants
needs to understand the format of the legacy system. This includes the information like.
1) Type of file (.TXT file or excel sheet)2) The type of data is stored in the file3) The corresponding tables & fields in SAP.4) The sequence and data type of fields.5) Existence of the file i.e. whether the file is available on presentation server or
application server.Syntax for call transaction: -
Call transaction
[using ].
[mode ].
[update ].
[
-
7/30/2019 Core Abap Notes
26/38
26 | P a g e S a n t o s h P
SM35 Is T-code used for processing the session object.
Procedure to interact with session object: -
Step1: - Create the session object by using the function module BDC_OPEN_GROUP.It contains following parameters.
a)Client: - It holds the client no in which the session object has to be created. Sessionobject is client dependent.
b)Group: - It holds the session object name.c)Hold date: - It holds the data in which the session object is blocked.d)Keep: - It is an indicator to keep the session output even data processing the session
object.
e)User: - It holds the user name where is authorized to process the session object.Note: - In call transaction the errors needs to be handler explicitly in case of session the log
is generated automatically by SAP itself which can be analyzed at data later point of time.
Step2: - Map the internal table (type BDC data) data to the session object by calling the
function module BDC_INSERT.
It contains following parameters.
a)T-code: - It holds the T-code of the transaction to which the session object data ismapped.
b)DYNPRO TAB: - It holds the BDC data internal table.Step3: - Close the session object by calling the function module BDC_CLOSE_GROUP.
Note: - SM35 Is the T-code used for processing the session object.
Note: - Call transaction Technique is online. I.e. when enter the call transaction is executed
the records are processed one after the other. I.e. call transaction is immediate processing.
Session technique is offline processing. I.e. once the BDC data internal table is mapped to
the session object the session object can be processed at later point of time. Whenever the
network traffic to the application server is lss.
In general the session object is processing during non business hours.
-
7/30/2019 Core Abap Notes
27/38
27 | P a g e S a n t o s h P
Recording Method: -
In recording technique we need to record a transaction with same input values. Based upon this recording SAP itself generates a source code. This source code needs to be edited manual to map it to the legacy system for data
migration.
Transaction: - Z147/SHDB is the T-code for Recording.
Error Handling in call transaction: -
Note: - BDCMSGCOLL is a structure used for collections the messages which are
captured during data migration using call transaction.
Syntax: -
Call transaction using
Mode
Update
Message into
Types of processing mode: -
1) A (Default): It displays all screen one after the other in this mode the error records isvalidate.
2) E (Error): Display error screens in this mode the error record is validated as an whenit is encountered (as soon as it is displayed on the transaction) (i.e. if does not required
any user interaction).3) N (No display): It indicates background processing.
Types of update modes: -
1) S (Default) (Synchronous): In this for every record sy-subrc status is returned, onlyafter receiving the sy-subrc status the next record is processed.
2) A (Asynchronous): In this no status is returned after processing the record.3) L (Local Update): It uses the memory of the local system to process the record.Direct input method: -
Legacy System Internal Table R/3 Database
-
7/30/2019 Core Abap Notes
28/38
-
7/30/2019 Core Abap Notes
29/38
29 | P a g e S a n t o s h P
Note: - The data in the window can contain different paragraph format. Each paragraph
format is associated with different form and style settings.
SAP script form is client dependent and language dependent.
Types of symbols in SAP scripts: - Symbols are used for representing a value in sap
scripts there are 4 types of symbols.
1) System symbols2) Standard symbols3) Program symbols4) Text symbols1) System Symbols: - These symbols and their values are provided by SAP and the exists
as the part of the TABLE-TTXSY.
2) Standard Symbols: - These symbols and their values are provided by SAP. And thereare stored in the TABLE-TTDTG.
3) Program Symbols: - These symbols and their values are provided by developer. Thesesymbols are declared in form level and the values are supplied from driver program.
4) Text Symbols: - These symbols are exists in the form of control commands.Note: - Whenever a form is displayed by using START_FORM we must end the form by
using END_FORM before opening the next form otherwise it results is ABORT ERROR.
Standard Texts: - It is an object which holds the common information which needs to be
appearing in all the business documents standard text is created on using the T-code (SO10).
We can include the standard text in any no of forms by using the controlcommand includes.
Standard text does not generate any change request it needs to be assign to arequest manually.
Modifying Standard text dynamically: -
Note: - For modifying the standard text dynamically based on a condition we need to read
the existing standard text by using the function module READ_TEXT.
Once the text is read we can modifying the text accordingly and update the changes to
standard text by using the function module SAVE_TEXT.
Transporting standard text: - By default standard text does not generate any change
request. It needs o be attached to a change request manually by executing the programRSTXTRAN.
-
7/30/2019 Core Abap Notes
30/38
30 | P a g e S a n t o s h P
Smart forms: - A smart form is also a word processing tool where the development &
maintenance cost is minimum smart form is client-independent because smart form is a
function module generated dynamically whenever a smart form is activated.
TFDIR is a table which stores the smart forms.
A smart form does not require any driver programs it can be executed directly.
Even though a smart form can be executed directly we need to create a driverprogram for calling the smart form function module because in the production
system the across to smart form T-code may be decide.
As part of the driver program we need to call the smart form related functionmodule. But this procedure is not recommended.
The reasons for this are when the smart form is transported to production client.And when activated it generates a new function module when naming conventions
specific to the production client.
So to avoid this we need to follow the below procedure.As part of the driver program call the function module
SSF_FUNCTION_MODULE_NAME
Function modules take the smart forms name is input and returns the associated function
module name which is received in a appropriate variable type.
Pass data to smart forms: - To pass the data to smart forms from a driver program we
need to use the parameter sections of the smart form function module.
Text Modules: - Text module is a set of statements which is defined once and which can be
included in any no of smart forms.
Smart Styles: - It is used for designing user defined style format which can be included in
any no of smart forms.
-
7/30/2019 Core Abap Notes
31/38
31 | P a g e S a n t o s h P
Control Break Events in Smart forms: - These events must be used only between loop
and endloop.
1) AT FIRST2)
AT NEW3) AT END OF
4) AT LAST1) AT FIRST: - This event is trigger whenever the first record of the internal table is read;
this event is triggered only once.
Syntax: -
AT FIRST.
STATEMENTS.
ENDAT.
2) AT NEW: - At new event is triggered whenever a new value is encountered thespecified field.
Syntax: -
AT NEW
STATEMENTS.
ENDAT.
3) AT END OF: - This event is triggered at end of the last row for specified last field.Syntax: -
AT END OF
STATEMENTS.
ENDAT.
4) AT LAST: - This event is triggered at end of the last row the internal table.Syntax: -
AT LAST.
STATEMENTS.
ENDAT.
Secondary Index: -
You should only create secondary indexes, for database tables from which you mainly read,
since indexes have to be updated each time the database table is changed. Secondary
indexes should contain columns that you use frequently in a selection, and that are as highly
selective as possible to improve performance.
-
7/30/2019 Core Abap Notes
32/38
32 | P a g e S a n t o s h P
Subroutine: -
Subroutines are procedures that you can define in any ABAP program and also call fromany program. Subroutines are normally called internally, that is, they contain sections of
code or algorithms that are used frequently locally. If you want a function to be reusable
throughout the system, use a function module.
Difference between select option and ranges: -
SELECT-OPTIONS RANGES
Select-options generate the selection screen. Ranges do not generate the selection screen.
The table specified as part of select option
must be declared explicitly by using table
keyword.
In case of ranges no need of explicit
declarations.
By default it contains default values for option
and sign.
Ranges explicitly we need to assign the values
for option and sign fields.
Difference between subroutine and function module: -
FUNCTION MODULE SUBROUTINES
They can be tested itself. They cannot.
They can be remote enabled. They cannot.
They can handled exceptions. Only a few can handle.
They have to be maintained in a function
group.
It is not necessary.
Function modules can return the value. Subroutines cannot return the values.
Function module are executable programs Subroutines are not executable programs
The can be independently tested. They cannot be independently tested.
-
7/30/2019 Core Abap Notes
33/38
33 | P a g e S a n t o s h P
Difference between macros and subroutines: -
MACRO SUBROUTINE
The definition of the macro as well as calling
of the macro in the same program.
The definition of the subroutine as well as the
calling of the subroutine may or may not in the
same program.
It can accept up to 9 place holders (Inputs). It can accept any no of place holders.
Definition should be the first and calling should
be the next.
Calling should be the first and definition should
be the next.
We can place any executable statements after
the definition of the macro.
We cannot place any executable statement after
the definition of the subroutine.
Macros are used in HR-ABAP. Subroutines are used in ABAP (conversion
programs).
Difference between SAP Scripts and Smart Forms: -
SAP SCRIPTS SMART FORMS
Simulated by the use of tabulations, so they
can't contain dynamic long texts, no borders. True tables, with borders.
Main window can have several ones, useful for
printing several identical labels per page. Main window can have only once.
There is no XML & HTML Smart forms generate XML output which can
be viewed through the web.
Pages format are only once. Several page formats are possible.It is client dependent. It is client Independent.
It is possible to create smart forms without a
main window.
Conditions like if..endif, case..endcase inside a
window
Exists as conditions on windows
Printer-dependent, only works with printers
that are able to generate barcodes by
themselves (natively or addition of SIMM);
few printers supported by SAP
New barcode technology: SAP converts
barcode data into an image, so it works for all
device types which are able to print graphics
-
7/30/2019 Core Abap Notes
34/38
34 | P a g e S a n t o s h P
Difference between main window and variable window in sap-script: -
MAIN WINDOW VARIABLE WINDOW
We can split the main window into smaller
windows.
We cannot split the variable window.
Without a main window we cannot design
SAP-SCRIPT.
Without a variable window we can design
SAP-SCRIPT.
Data is displayed continuously. Based on the window size data is printed.
We can place the same main window up to 99
times per page. (00 to 99 times)
We can place the variable window only once in
a page.
In the main window text element is
compulsory.
In the variable window text element is
optional.
Top Endtop Bottom Endbottom works with in
the main window only.
These commands are not work in variable
window.
Difference between call transaction and session method: -
CALL TRANSCATION SESSION METHOD
We can process only one transaction at a time. We can process N no of transactions at a time.
We can manually handle the errors in the call
transaction.
The session method generates an error log that
will handle the errors.
Call transaction is faster than session method. Session method is little bit slower than call
transaction.
Call transaction is suitable for less amount of
data in the flat file.
Session method is suitable for large amount of
data in the flat file.
Call transaction is the immediate database
updating.
After processing the session by using session
method the data will be up to in the database.
It returns sy-subrc. It never returns sy-subrc.
We cant schedule the call transaction in back
ground.
We can schedule the session method in back
ground.
-
7/30/2019 Core Abap Notes
35/38
35 | P a g e S a n t o s h P
Difference between call by value and call by reference: -
Call By Value Call By Reference
It creates a new memory location for use
within the subroutine. The memory is freed
once it leaves the subroutine. Changes made to
the variable are not affected outside the
subroutine.
Passes a pointer to the memory location.
Changes made to the variable within the
subroutine affects the variable outside
The subroutine.
In call by value, both the actual and formal
parameters Will be created in differentmemory locations.
Whereas if they are called by reference both
will be created at the same location.
In call by value method, a compiler get a copyof the variable and thus changes made in the
value in function will not reflected back to thecalled function.
But in call by reference method, the compilerdidn't get any copy , but actually it works on
the original copy and thus changes will bereflected back.
Differences between grid display & list display: -
List display Grid display
It displays the output in a list format. It displays the output in a grid format.
It is faster than grid display. It is slower than list display.
It does not support OOPS ALV. It supports OOPS ALV.
EDIT option is not possible EDIT option is possible.
In the output I icon indicates no of records are
displayed.
In the output I icon indicates f1 help.
It supports blocked ALVS and hierarchical
ALV.
It does not support blocked & hierarchical
ALVs.
Logo is not possible in list display. Logo is possible in grid display.
Write statement is enough to display the header
and footer information.
We must use
REUES_ALV_COMMENTRY_WRITE
function module to display the header and
footer information.
Whenever we are working with row color thenit displays the color for non-key fields.
Whenever we are working with row color thenit displays the color for all fields.
-
7/30/2019 Core Abap Notes
36/38
36 | P a g e S a n t o s h P
DIFFERENCES BETWEEN BAPI AND BDC: -
BAPI BDC
It is directly updating data to the
database.
It is updating the data to the database is
always through screens.
BAPI is faster than BDC BDC is slower than BAPI
BAPI never cause to terminate the
program, whenever an error occurred it
simply return that error through return
parameter.
Some times BDC cause to terminate the
program i.e. BDC_GROUP
BDC_INSERT BDC_CLOSE_GROUP
function modules fails.
The flat file data is varying. The flat file is constant.
It performs its own authorization checks. We implement the authorization object in
the BDC program.
Whenever the version is changed we no
need to change the existing code of the
BAPI that is taking care of BOR.
Whenever the version is changed
sometimes we need to change the BDC
code.
DIFFERENCES BETWEEN LSMW AND BDC: -
LSMW BDC
It is purely designed for functional people
who do not do much coding.
BDC is designed for technical people
who know much coding.
In the LSMW, mapping is done by SAP. In the BDC mapping is done by
ABAPER.
LSMW offers 4 methods
1) Direct method2) Batch input recording3) BAPI4) IDOC
BDC offers 2 techniques
1) Call transaction2) Session method
We can develop the LSMW only for the
stand and transaction codes.
We can develop the BDC program for
any transaction code.
The input for the LSMW is always text
file.
The input for the BDC is any file .txt or
.xls.
-
7/30/2019 Core Abap Notes
37/38
37 | P a g e S a n t o s h P
DIFFERENCE BETWEEN ENHANCEMENT AND BADI:-
ENHANCEMENT BADI
We can implement enhancement only
once.
We can implement the BADI in any
no of times.
It is the procedural approach. That
means it needs Some extra time to
implement the logic.
BADI is OOABAP (approach) so it is
easy implement the logic.
Enhancement is always implemented
through project (CMOD T-code).
BADI is always implemented through
BADI implementation (SE19 T-code).
DIFFERENCE BETWEEN CUSTOMER-EXIT AND USER-EXIT:-
CUSTOMER-EXIT USER-EXIT
Customer Exits Are Functions So
They Are Called Using Call
Function (Or More Exactly
Call Customer Function)
User Exits Are Forms And Are
Called By Sap Standard Programs
Using Perform
Inside A Function (Customer Exit)
You Can Only Access YourImport/Export/Changing/Tables
Parameters
Inside The Form (User Exit) You
Can Read And Change Almost AnyG l o b a l Data From Host
Program.
Customer Exits Are More
Restrictive But You Are Sure
Any Change You Can Make
To Any Parameters Will Never
Lead To Inconsistency
User Exits Are More Flexible
Because You Have More
Information To Use In Your
Code But On The Other Hand , It
Is Very Easy To Manipulate
Erroneously Global Data And Lead
The Standard Program To A
Dump Or Even To Make DatabaseInconsistent
Customer-Exit We Ha v e
Function-Module Exit, Screen
Exit, Menu Exit.
User-Exit Doesnt Have Any
Classification
Customer Exits Are Available For
MM,SD,FI,HR. Basically Designed
For All Modules
User Exits Are Basically
Designed For SD Module
Whereas in Customer-Exit No
Access Key Is Needed
Needed
While Changing User-Exit,
Access Key Is Required
-
7/30/2019 Core Abap Notes
38/38
DIFFERENCE BETWEEN BAPI AND RFC:-
BAPI RFC
RFC function module can handle it
BAPI is registered in the
BOR(Business Object Repository)
RFC is not registered in the
BOR(Business Object Repository)
every BAPI is a RFC every RFC is not a BAPI
BAPI are for non sap systems like
I want to access data via java or
vb
RFC enabled are basically for sap
systems
DIFFERENCE BETWEEN BADI AND CUSTOMER-EXIT:-
BADI CUSTOMER-EXIT
Business Add-Ins are a new SAP
enhancement technique based on
ABAP Objects.
CUSTOMER EXITS (enhancements)
are FUNCTIONS so they are
called using CALL FUNCTION
(or more exactly CALL
CUSTOMER FUNCTION
Badis allow for a multi-level
system landscape (SAP, partner, and
customer solutions, as well ascountry versions, industry
solutions, and the like). Business
Add-Ins can be created at each level
Customer exits assumes a two-
level infrastructure
(SAP and customer solutions)
Some BADI can have multiple
independent implementations, which
is much better for software
deployment as several developers can
implement the same BADI
independently.
Customer-exit implemented
in one project cannot be
implemented in other.
BAPI can't handle exceptions , thecalling program has tohandle it