MIS 3020 ABAP Programming Lecture 2 Elementary & User Defined Types Domains, Elements, Variables/Fields.

Slides:



Advertisements
Similar presentations
Chapter 10: Designing Databases
Advertisements

Elementary Data Types Prof. Alamdeep Singh. Scalar Data Types Scalar data types represent a single object, i.e. only one value can be derived. In general,
Lecture 1 Introduction to the ABAP Workbench
Lecture 2 Introduction to C Programming
Introduction to the ABAP Data Dictionary
Access - Project 1 l What Is a Database? –A Collection of Data –Organized in a manner to allow: »Access »Retrieval »Use of That Data.
University of Southern California Enterprise Wide Information Systems ABAP/ 4 Programming Language Instructor: Richard W. Vawter.
Using Objects and Properties
 SAP AG CSU Chico MINS298c ABAP/4 Programming Introduction to Data Types Chapter 4 Fall 1998.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Elementary Data Types Scalar Data Types Numerical Data Types Other
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
C++ for Engineers and Scientists Third Edition
With Microsoft Access 2010 © 2011 Pearson Education, Inc. Publishing as Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access.
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Oracle Data Definition Language (DDL)
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
Microsoft Access 2000 Creating Tables and Relationships.
BIS121 IT for Business Application Lecture 8 – Database (Part I)
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Input & Output: Console
Lesson 1: Introduction to ABAP OBJECTS Todd A. Boyle, Ph.D. St. Francis Xavier University.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
SAP ABAP DemoNawin's Training Acadamy1. Enterprise Wide Information Systems ABAP/ 4 Programming Language Mr. RG Nawin Krishna, Bsc(cs);Msc(psychology);MBA(HR);SAP(HCM/HR),
Data Modeling for Integrating SAP with other Applications.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
C Tokens Identifiers Keywords Constants Operators Special symbols.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
CHƯƠNG 3 Finding, Filtering, and Formatting Data.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
0 UMN 2011 ERP Terapan Dialogs Programming Session # 11.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 9 Arrays.
11 3 / 12 CHAPTER Databases MIS105 Lec15 Irfan Ahmed Ilyas.
Introduction to ABAP Selection Screens. Slide 2 Screens (Types) There are three types of screens Selection screens get parameter input for reports List.
Access Project 3 Notes. Introduction Maintaining the Database  Modifying the data to keep it up-to-date Restructure the Database  To change the database.
Term 2, 2011 Week 1. CONTENTS Problem-solving methodology Programming and scripting languages – Programming languages Programming languages – Scripting.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
C++ for Engineers and Scientists Second Edition Chapter 11 Arrays.
WHAT IS A DATABASE? A DATABASE IS A COLLECTION OF DATA RELATED TO A PARTICULAR TOPIC OR PURPOSE OR TO PUT IT SIMPLY A GENERAL PURPOSE CONTAINER FOR STORING.
Enhancing Forms with OLE Fields, Hyperlinks, and Subforms – Project 5.
Database Management Systems.  Database management system (DBMS)  Store large collections of data  Organize the data  Becomes a data storage system.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Databases,Tables and Forms Access Text by Grauer Chapters 1 & 2.
1 CSE 2337 Introduction to Data Management Access Book – Ch 1.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Relational Databases. Relational database  data stored in tables  must put data into the correct tables  define relationship between tables  primary.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
IT Applications Theory Slideshows Databases II: Structure, Naming, data types, data formats.
Database Objective Demonstrate basic database concepts and functions.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Lesson 4.  After a table has been created, you may need to modify it. You can make many changes to a table—or other database object—using its property.
Session 1 Module 1: Introduction to Data Integrity
SAP DEVELOPMENT BASICS Bohuslav Tesar. TRAINING OVERVIEW Amazing life of ABAP developer ;) SAP introduction ABAP basics ABAP Reporting.
Introduction ABAP Fields and Variables. Slide 2 Fields (Introduction) In ABAP, fields (or data objects) are named locations in memory Variables store.
ABAP/4 Defining Data Defining Data: –Data statement –Parameters statement –Tables statement –Constants statement –Data statement to define field strings.
Microsoft Office 2013 Try It! Chapter 4 Storing Data in Access.
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Course Contents Overview: Database basics Lesson 1: Benefits of using a database Lesson 2: Table that data Lesson 3: Analyzing, viewing, and reporting.
Chapter 3 Data Representation
Creating Database Objects
Fundamentals of DBMS Notes-1.
Managing Tables, Data Integrity, Constraints by Adrienne Watt
BASIC ELEMENTS OF A COMPUTER PROGRAM
Other Kinds of Arrays Chapter 11
Chapter 3 The DATA DIVISION.
Oracle Data Definition Language (DDL)
Data Types and Expressions
Data Dictionary Overview
Creating Database Objects
Presentation transcript:

MIS 3020 ABAP Programming Lecture 2 Elementary & User Defined Types Domains, Elements, Variables/Fields

Objectives To introduce : ABAP elementary and user defined data types keywords used to declare data items complex record structures the use of internal tables in ABAP declaring an internal table populating fields of an internal table the ABAP data dictionary domains, elements & tables integrity constraints

ABAP Data Types Elementary Data Types User Defined Types

ABAP Data Types & Structures Elementary Types supported by ABAP characters numbers Date Time Hexadecimal Non- Elementary Types ( User Defined Structures) records internal tables

Character Types c character default type when none is specified used for regular text information pads right end with spaces n numeric text contains strings of digits used for numbers that are used for identification and as sort criteria for internal tables house numbers, postcodes, phone numbers,... pads left end with zeros

Number Types iintegers fixed length of 4 bytes possible values range from to ppacked numbers stored in compressed formats, ie, 2 digits per byte of storage. can be used for all types of calculations ffloating point possible range from 1E-307 to 1E307 can be used in all types of calculations but beware of rounding errors. (Don’t use in eq condition tests)

Date Type ddate fixed length of 8 and internal representation of YYYYMMDD several output formats supported set default output format in your User Profile/Defaults can specify different/specific output format when writing value out supports date arithmetic

Time Type ttime fixed length of 6 and format HHMMSS several output formats supported can specify different/specific output format when writing value out supports time arithmetic

Hexadecimal Type xhexadecimal values in hexadecimal fields are stored in binary (bit stream) format eg ‘F089’ would be stored as hex digits are stored in 1 storage byte

Elementary Types & Default Lengths and Values TypeLengthInitial Value c 1space n 1‘0’ i 4 0 p 8 0 f d 8‘ ’ t 6‘000000’ x 1X’00’

The ABAP Statement most ABAP statements begins with a reserved keyword, e.g. data, types, select all end with a period (.) can combine a sequence of statements starting with the same keywords into a single statement using colon and comma (for most keywords)

The data keyword variables are declared using the data keyword data varname[(len)] type typedef [value val]. data postcode(4) type n value ‘4001’. data counter type i value 1. data price type p decimals 2. data varname like objname [value val]. where objname is a previously declared item (or database object) data DOB like sy-datum.

The data statement multiple variable declarations can be made in the same data statement by using data: data: DOB like sy-datum, counter type i.

The parameters keyword PARAMETERS: P1 TYPE P, P2(6) TYPE C DEFAULT ‘ITB255’. PARAMETERS TYPE [DEFAULT ]. X P1 P2 ITB255 Selection Screen

The constants keyword Constants are declared like fields with the addition of the value clause. constants: max_counter type i value A constant cannot be changed trying to change the value of a constant will result in a runtime error (if the change can only be detected at runtime, ie, if the constant is used as an actual parameter)

Records (or Structures) records consist of a fixed number of data objects called components of the record declared using data begin of and data end of data: begin of student, stnum(8)type n, stname(25)type c, stDOBlike sy-datum, stphone(12)type n, end of student.

Working With Records components of records are referenced by recordname-componentname data IT_student like student. student-stnum = ‘ ’. student-stname = ‘F.Jones’. student-stDOB = ‘ ’. student-stphone = ‘ ’. move student to IT_student.

The types keyword used to create a user defined type types: begin of student_type, stnum(8)type n, stname(25)type c, stDOBlike sy-datum, stphone(12)type n, end of student_type. data: student_rec type student_type, student_tab type student_type occurs 0.

The tables keyword tables, e.g. tables spfli Creates a structure in the program work area with the same: name row structure field names, datatype, sequence as the referenced database table, structure or view

Internal Tables used as snapshots of database tables containers for volatile data exist only at runtime, (unlike database tables) consist of any number of records declared using occurs n data student_tab like student occurs 0. data student_tab like student occurs 0 with header line. note that it is not necessary to declare the exact size of the table: SAP’s memory management allows the table to be ‘infinitely’ extensible.

Internal Tables – with header line Program Work Area R/3 Database a record structure of the same name is automatically created

Internal Tables – without header line Program Work Area R/3 Database need to define a record structure explicitly in your abap program

Internal Tables - header lines advantages of header lines convenient declaration table and header line structure declared in same statement ease of use don’t have to explicitly move data into the work area structure and then append the work area structure to the table some statements require a table with header line disadvantages of header lines performance - I/O is faster for tables without header line cannot use in embedded structure

Internal Tables - header lines default declaration is without a header line to declare a table with a header line data: itab {type tabtype | like objname} occurs n with header line data book_tab like sbook occurs 0 with header line.

More Complex Structures It is possible to create nested structures a structure can contain another structure a record can contain an internal table as one of its components a table can contain another table, etc types: begin of addr_type, city(25), street(30), end of addr_type, begin of person, name(25), address type addr_type, end of person. data: emp type person. emp-address-city = ‘Sydney’.

The Data Dictionary Domains Data Elements Tables & Structures

3 Levels of the Dictionary Tables or Structures composed of one or more fields Data Elements each field refers to a data element that describes the meaning of the field Domain determines the technical properties of the field data type and size (including number of decimal places) allowed data values output characteristics

Elements and Domains Domain provides the technical description Element determines the role played create a domain called ID_Number create elements Student_ID and Staff_ID based on the ID_Number domain

Data Element Definition Referential Integrity Check Data Element Definition Referential Integrity Check

Field Information

Define the text to be displayed on screen or report Domain Definition

Range/Value Integrity Check

Integrity Checking Domain Range/Value Integrity Checks value table only values contained in the value table can be entered in fields referring to this domain fixed values only values that match a value in the user specified list of admissible values can be entered in fields referring to this domain

Integrity Checking Referential Integrity Checking check table foreign key values must match an entry in the specified check table check tables bound to input fields on data entry screens position the cursor on input field and press F4 to get a list of permissible values the default check table for a field is the value table of the underlying domain from the “Dictionary: Table/Structure: Display Fields” screen, Select GoTo…Foreign Keys (F8)

Foreign Key value must match Primary Key value of the check table Cardinality Ratio of Foreign Key Scroll Through Other Defined Foreign Keys

Viewing the Contents of a Database Table From the Data Dictionary Click on the Table Radio Button & enter the Table Name From the Dictionary Table: Table/Structure: Display Fields screen choose Utilities…Table Contents Data Browser (from main menu item Overview) Enter the Table Name Choose Table…Table Contents or press Enter Fill in the appropriate Selection Screen entries Click on the Execute icon on the application toolbar, (or press F8)

Table Name Number of Rows Selected Sort Buttons

Conclusion This lecture covered aspects of defining identifiers in an ABAP program the data dictionary In particular we covered the basic data types supported by ABAP character, number, integer, float, packed, date, time, hexadecimal We also discussed user defined structures records, tables

Conclusion User defined structures are declared using the types keyword. Identifiers are declared using the data keyword the parameters keyword Constants are declared using the constants keyword. The datatype of an identifier can be specified using type specific type like previously defined identifier/dictionary object

Conclusion Structures records defined by data begin of / data end of internal tables defined using occurs complex structures can be created by nesting records and internal tables

Conclusion The second half of the lecture covered Data Dictionary Organization of Data in the Dictionary Domain  Elements  Tables/Structures Using the Dictionary to see the definitions of Domains, Elements, Tables the contents of Tables How the Dictionary maintains Value and Referential Integrity

Related Reading Online Help R/3 Library...Basis Components... ABAP Workbench BC ABAP Users Guide The ABAP Programming Language … Basic Statements … Declaring Data … Creating Data Objects and Data Types The DATA Statement BC ABAP Dictionary …Tables BC ABAP Dictionary … Data Elements BC ABAP Dictionary … Domains