You are on page 1of 32

ABAP Notes

Details
• ABAP is part of application layer in SAP
Architecture.
• Tcode - ABAPDOCU is used to learn with
sample code in SAP.
Programs
• Reports
– Reports are the programs that results into list of
data for the query from the presentation layer to
application layer
• Dynpros (Dynamic Programs)
– Program that require user input for decision
making to proceed processing.
Work Processes
• Work processes executes programs and have access to
all the memory area it uses.
– Dispatcher
• Handles distribution of work process and Optimize it.
– Dynpro Processor
• Handle flow logic depending user interaction.
• Dialog control but can’t perform calculation
– ABAP Processor
• It performs the calculation request received from Dynpro dialogs.
• It can check authorization, read/write to DB
– Database Interface
• These are Abap statements that are DB independent (Open SQL).
ABAP Program Structures
• Declaration Sections
– Declare Global and Local variables
– Declare Data types, Tables
– Parameters used for Selection screens
• Processing Blocks
– All logic for the program
– Can be called from Dynpro processes
Common Development Tools
• ABAP Dictionary (SE11) helps to create tables or view data fields in
the tables.
• ABAP Editor (SE38) helps to create programs.
• Function Builder (SE37) helps to define specific task that can be
called from any program and is used to create interface where you
define different data elements and tables that you can pass to and
from databases.
• Menu Painter (SE41) helps to create menu items and menu bars
• Screen Painter (SE31) helps to define user input screen such text,
check box etc. It also helps to define events when user interacts.
• Object Navigator (SE80) helps to navigate across the project while
development.
• Maintenance & Transport Message (SE91) used to view and add
messages to the table.
Data Dictionary
• It helps to create
tables, fields,
elements and
domains
• It helps to enhance
table and data
• It helps to view and
data to the tables.
Types of Program
• Executable Program
• INCLUDE Program
• Module Program
• Function Group
• Sub-routine Pool
• Interface Pool
• Class Pool
Variables & Constants
• We can define the variable in the program with a
data type or reference a data type from other
variable or column of table defined.
• We can provide attributes to that definition like
decimals.
• We can also assign initial value or default value to
the variables using value attribute
• Constants have same value throughout the
program. It is defined in similar way as variable.
Data types
• Integer i
• Packed p
• Character c
• NumC n
• Date d (char)
• Time t (char)
• Quantity and currency (pack)
Character Operations
• Concatenation
• Shift
• Length
• Replace
• Split
• Search / Substring
• Subfields
• Condense
Coding Details
• (*) in the 1st column is used to comment all text or
statement on that line in the program.
• (“) is used to comment text or statement to the right of
it on that line.
• Report statement is the 1st statement in any executable
program.
• Program names is specified in the Report statement.
• Report statement is terminated using (.) .
• (‘’) is used to provide string data.
• (:) is used after keyword to chain the same statement.
• (/) is used for New line
Coding Keywords
• Write- To print output
• Select\ Endselect- for SQL queries
• Uline- Underling
• Skip- To print blank lines till specified
• Arithmetic Operator. (+, -, *, /, %).
• Arithmetic Integer operations ADD, MUL, SUB,
DIV, MOD.
Debugging
• Debugging helps to find logical errors in the code.
• There various ways of debugging such as single
step, execute, return, continues, breakpoint,
display list and watch-list.
• Debugger displays contents tabs of various
resources such as fields, tables, break-points, call,
watch-point overview and setting.
• There are systems field at the bottom which get
update by execution of the program and can’t be
edited. Such field are sy-subrc, sy-tabix and sy-
dbcnt in field mode.
Open SQL Statements
• Open SQL is dependent of underlying
database.
• Select, Insert, Update, Modify and Delete.
Condition Statements & Loops
• If-elseif-else-endif statement
• Case-when-others-endcase
• Select-endselect.
• Do-enddo
• While-endwhile.
All the statements and loops can be nested. For looping remember to
have an exiting condition or it will stuck running. There are termination
statements to exit based on logic.
• Continue - Will skip code below it to new loop.
• Check - It is combination of continue and if. If statement is false it
skips to new loop.
• Exit – It terminates the current loop and will move execution to
parent loop.
Abap User Dialogs
• Screens
• Selection Screens
• Lists
• Messages.
Selection Screens
• Parameters
• Ranges
• Select-options
• Selection Screens
• Call Selection screens
• At Selection Screens
• Modification groups on selection
• Definition of Titles and text on selection screen (Text
elements)
• Dynamic Selections
• Variants ( used to save the search for later use)
Parameters
• Text
• Table column
• Radio buttons
• Check boxes
• Select Options
Select Options
• Provides range of values
• Low and High
• Provide operator options such as greater than,
less than, equal to, not equal to, etc.
• Provide sign to either include or exclude
option on the selection screen
Messages
• The message are used to provide feedback to
the user.
• Message e001(zemp).
• Where zemp will be the message table with
001 key containing message.
Events
Events
• Initialization
• Selection Screen
• Start of Selection
• End of Selection
• At Line Selection
Internal Tables
• Old Method (Data)
– We use table header to insert, read or delete
records from the table.
– We iterate through table on record at a time.
• New Method (Types)
– We use work area to insert, read or delete records
from the table.
– We have to define line type so with same name as
columns in the table so that we can transfer data
directly.
Different type of internal table
• Standard table
– Can contain duplicate record as it doesn’t has key
– For sorting column name is required
• Sorted table
– Table is indexed based on the key field
– Records are sorted
• Hash Table
– Table has key field based on hash algorithm
Functions related to Internal Tables
• Read
• Move (Append/Corresponding)
• Delete
• Modify
• Insert
• Sort (ascending/descending)
• Describe
• Loop-Endloop
• Select
• Clear
• Refresh
• Free
Messages
• The messages are used to inform the user about
the response status
• Types of Messages
– Information
– Error
– Warning
– Status
– Exit
• We create a message table which has message
stored with key which is 3 digit.
Types of Report
• Classic (Only single view)
• Interactive (Multiple view)
• ALV (ABAP List View) (Provides function such
as Sort and other functions)
Sequence Of Classic list Program
• Load Program – we don’t see it.
• Initialization (initializing statement will be executed)
• At Selection-screen (Parameters are defined)
– At Selection-screen output
– At Selection-screen on value request for #field
– At Selection-screen on help request for #field
– At Selection-screen on #field
• Start of Selection
• End of Selection
• Top of Page
• End of Page
Interactive list
• This list provides list of secondary list which
can be opened by clicking on it.
• There can be 21 secondary list from list 0 to 20
• The list no. is stored in system variable sy-lsind
• If you select any line, the selected line data is
stored in system variable sy-lisel
Sequence of Interactive list program
• At line selection: the event is triggered when the
user double clicks on any list line.
– Hide ( used to hide the selected line)
– Get cursor (used to get field values from the selected
line).
• At User command : event triggered when used
interacts with buttons of the screen
• Top of page during line selection: used to provide
heading for the secondary list
• At PF <Function key>: event triggered when we
press f1 or f2, but this function is obsolete
ALV Report
• Pre-defined report format in SAP
• Allows to perform various function
dynamically on the report
• Function such as sorting, filtering, retrieving
data.
• Can display more that 90 columns or more
with various display options

You might also like