Upload
mkpatil
View
1.133
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
Lecture 4Local Data Types and Definitions
BCO5647 Applications Programming Techniques (ABAP)
2BCO5647
Readings & Objectives
Readings
Keller & Kruger Chapter 4Pages 87 – 103
Objectives
This lecture will
Introduce Local Data Types in ABAP
Identify the ten Elementary Data Types in ABAP
Examine User-defined Data Types
Introduce the Structure concept with local and global definitions.
3BCO5647
Local Data - Data Type
A data field in ABAP is a variable which cannot be broken up intosmaller parts.
All data fields that are to be used in a program must be defined before
their first use.
Data fields in an ABAP program have a type.
E.g. You can define a data field student_name of type character andlength 25 as:
data student_name(25) type c.
4BCO5647
Local Data: Elementary Data Types
There are ten “built-in” data types in ABAP.
Since SAP R/3 4.6 ABAP offers two variable length built-in elementary data types STRING and XSTRING:
DATA: text-string TYPE stringtext-string = ‘ABAP programming is FUN!’
XSTRING can contain the hexadecimal content of a byte sequence.
5BCO5647
Elementary Data Types
data: name(25) type c, city(25), flag.
data: student_id(7) type n value ‘6980’.
write student_id.
data: book_price type p decimals 2.
6BCO5647
User-defined Data Types
You can make reference to an existing variable using like.
data: customer_name(25) type c, vendor_name like customer_name,
carridcode like spfli-carrid.
You can create your own data types and apply them to variables.
types: t_name(25) type c.
data: customer_name type t_name,vendor_name type t_name,carridcode type s_carr_id.
7BCO5647
Structure
Structures consist of a series of variables grouped together under a commonname.
Structures are defined using the keywords begin of and end of.
data: begin of customer,id(8) type n,fname(12),lname(15),
end of customer.
customer-id = ‘12345678’.customer-fname = ‘Christain’.customer-lname = ‘Wong’.
write / customer.write: / customer-id, customer-fname, customer-lname.
8BCO5647
Structure
You can define a structure type locally using the TYPE statement.
Structures can be used to set up a work area to store database table record.