Lecture04 abap on line


Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Lecture04 abap on line

  1. 1. Lecture 4 Local Data Types and Definitions BCO5647 Applications Programming Techniques (ABAP)
  2. 2. Readings & Objectives <ul><li>Readings </li></ul><ul><li>Keller & Kruger Chapter 4 Pages 87 – 103 </li></ul><ul><li>Objectives This lecture will </li></ul><ul><li>Introduce Local Data Types in ABAP </li></ul><ul><li>Identify the ten Elementary Data Types in ABAP </li></ul><ul><li>Examine User-defined Data Types </li></ul><ul><li>Introduce the Structure concept with local and global definitions. </li></ul>
  3. 3. Local Data - Data Type <ul><li>A data field in ABAP is a variable which cannot be broken up into smaller parts. </li></ul><ul><li>All data fields that are to be used in a program must be defined before their first use. </li></ul><ul><li>Data fields in an ABAP program have a type . </li></ul><ul><li>E.g. You can define a data field student_name of type character and length 25 as: data student_name(25) type c. </li></ul>
  4. 4. Local Data : Elementary Data Types <ul><li>There are ten “built-in” data types in ABAP. </li></ul>Since SAP R/3 4.6 ABAP offers two variable length built-in elementary data types STRING and XSTRING : DATA: text-string TYPE string text-string = ‘ABAP programming is FUN!’ XSTRING can contain the hexadecimal content of a byte sequence.
  5. 5. Elementary Data Types <ul><li>data: name(25) type c, city(25) , flag. </li></ul><ul><li>data: student_id(7) type n value ‘6980’. </li></ul><ul><li>write student_id. </li></ul><ul><li>data: book_price type p decimals 2. </li></ul>
  6. 6. User-defined Data Types <ul><li>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. </li></ul><ul><li>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. </li></ul>
  7. 7. Structure <ul><li>Structures consist of a series of variables grouped together under a common name. </li></ul><ul><li>Structures are defined using the keywords begin of and end of . data: begin of customer, id(8) type n, f name( 1 2), lname(15), end of customer. customer-id = ‘12345678’. customer- f name = ‘ Christain ’. customer- l name = ‘ Wong ’. write / customer. write: / customer-id, customer-fname, customer-lname. </li></ul>
  8. 8. Structure <ul><li>You can define a structure type locally using the TYPE statement. </li></ul><ul><li>Structures can be used to set up a work area to store database table record. </li></ul>