You are on page 1of 10

Data Types

ABAP uses different types of Data Types for Objects, basically there are three types
of data types Elementary Data types, Complex Types, Reference Types.
In Elementary types there are again two types of data types (Categories) Fixed
Length and Variable Length.
Fixed Length:
C Text Field
N Numeric
D Date
T Time
H Hexadecimal
P Parked Number
I Integer
F Float
Variable Length:
STRING Character Sequence
XSTRING Byte Sequence
Complex Types includes Structure Types and Table Types.
Reference Types includes Data References and Object References

What is a Modularization in SAP ABAP Programming? Types of


Modularization techniques in SAP ABAP programming
The concept of modularization is dividing the main program into sub-programs for
better readability and re-usability. Modularization can be implemented in the
following ways.
Include Programs.
Function Modules.
Sub-routines.
Classes.
MACRO`s (Use in HR ABAP only).
Include Programs:
These are sub-programs which contains a set of re-usable statements.
These programs can not be executed directly.
These include programs must be embedded inside a main program for execution.
This program doesn't contain parameter interface that is no importing and
exporting parameters.

Function Modules
These are also sub-programs which contain set of reusable statements for better
readability and re-usability.
Function modules contains parameter interface that is importing and exporting
parameters.
These Function Modules can be executed independently.
Function modules contain exceptions to catch certain type of errors.
T-code for Function Module explorer is SE37.
Sub-routines
Sub-routines are also sub-programs in SAP ABAP which contains certain re-usable
statements.
Most of the times we use sub-routines for re-usability inside the program.
We may use sub-routines for external re-usability.
These sub-routines contain importing and exporting parameters.
CLASSES
Classes are Object Oriented implementations of SAP ABAP.
Classes are used for better re-usability.

Function Modules are sub-programs which contain set of re-usable statements


with importing, exporting parameters, exceptions. Unlike include programs
Function Modules can be executed independently.
Function group is a container of Function modules, every Function Module
must be saved in a Function group. T-codes for Function Modules and Function
groups are SE37 OR SE80. We can save N number of Function Modules in a
Function Group.
Components of Function Module:
Import: These are input parameters of a Function Module.
Export: These are output parameters of a Function Module.
Changing: These are parameters which act as importing and exporting
parameters to a
Function Module.
Tables: These are internal tables which also act as importing and exporting
parameters.
Exceptions: Exceptions in Function Modules are used to catch certain type of
errors.

DECLARATION SYNTEX:FORM < form name>


< statements>.
End form.
Calling mechanism.
Perform < form name>.
parameters:a(5) type c.
case a.
when 'SAP'.
perform india.
when 'ABAP'.
perform usa.
when others.
message'invalid type' type 'I'.
endcase.
form india.
write: / 'this is SAP'.
write: / 'this is ABAP'.
endform.
form usa.
write: / 'this is abap'.
write: / sy-datum.
endform.

perform india(Zinternalsubroutine).
perform usa(Zinternalsubroutine).

Select-Options functionality in SAP ABAP


Whenever we declare Select-Options, an internal table will be created with the
following fields.
1.SIGN: This field contains I or E, where I stands for inclusive (Include that
values) and E stands for exclusive (Exclude that values), default value is I.
2.OPTIONS: This field can accept values BT (Between), NB (Not Between),
EQ (Equal), NE (Not equal), GT (Greater than), LT (Less than).
3.LOW: This field stores low value of entered range.
4.HIGH: This field stores high value of entered range.

Events in Classical Reports


Load-of-program: This event is used to load program into memory for execution and
this is the first Event in execution sequence.
Initialization: This event is used to initialize variables, screen default values and other
default actions.
At Selection-Screen output: By using this event we can manipulate dynamic
selection-screen changes.
At Selection-Screen on field: This event is used to validate a single selection-screen
input parameter.
At Selection-Screen on value request: This event is used to provide value/field help
for an input field.
At Selection-Screen on help request: By using this event we can provide F1 help for
an input field.
At Selection-Screen: This event is used to validate multiple input fields
Start-of-Selection: This is default event which is used to write actual business logic.
End-of-Selection: We can use this event just to state that start-of-selection is ended,
this event is used with logical databases and logical databases are in HR ABAP only. In
normal ABAP we don`t have much importance.
Top-of-Page: This event prints constant heading for all pages.
End-of-Page: This event prints constant footer for all pages. Before using this event,
we need to reserve some lines for displaying footer.

TABLES: ZVIVEK190.
SELECT-OPTIONS: ZID FOR ZVIVEK190-ZID.
DATA: BEGIN OF ITAB OCCURS 0,
ZID LIKE ZVIVEK190-ZID,
ZNAME1 LIKE ZVIVEK190-ZNAME1,
ZAGE LIKE ZVIVEK190-ZAGE,
END OF ITAB.
INITIALIZATION.
ZID-LOW = 0000001'.
ZID-HIGH = 0000788'.
APPEND ZID.
CLEAR ZID.
AT SELECTION-SCREEN.
SELECT SINGLE ZID FROM ZVIVEK190
INTO ZID-LOW
WHERE ZID EQ ZID-LOW.
IF SY-SUBRC NE 0.

START-OF-SELECTION.
SELECT ZID ZNAME1 ZAGE FROM ZVIVEK190 INTO TABLE ITAB WHER
E ZID IN ZID.
LOOP AT ITAB.
WRITE:/1 SY-VLINE, 2 ITAB-ZID,
14 SY-VLINE,15 ITAB-ZNAME1,
25 SY-VLINE,26 ITAB-ZAGE,
40 SY-VLINE.
ENDLOOP.
WRITE:/1(40) SY-ULINE.
TOP-OF-PAGE.
WRITE:/2 'CURRENT PROGRAM:',SY-REPID.
WRITE:/2 'DATE:',
SY-DATUM.
WRITE:/2 'TIME:',
SY-UZEIT.
WRITE:/1(40) SY-ULINE.
WRITE:/1 SY-VLINE,5 'ZID',
14 SY-VLINE,16 'ZNAME1',
25 SY-VLINE,30 'ZAGE',
40 SY-VLINE.
WRITE:/1(40) SY-ULINE.