Introduction ABAP Fields and Variables. Slide 2 Fields (Introduction) In ABAP, fields (or data objects) are named locations in memory Variables store.

Slides:



Advertisements
Similar presentations
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Advertisements

L2:CSC © Dr. Basheer M. Nasef Lecture #2 By Dr. Basheer M. Nasef.
Lecture Set 4 Data Types and Variables Part B – Variables, Constants, Expressions Conversion Rules Options Strict, Option Explicit Scope of Definition.
Types and Arithmetic Operators
Introduction to Computing Concepts Note Set 7. Overview Variables Data Types Basic Arithmetic Expressions ▫ Arithmetic.
Introduction to C Programming
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
Chapter 3 Numerical Data. Topics Variables Numeric data types Assignment Expressions.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
String Escape Sequences
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 2 Elementary Programming.
CPS120: Introduction to Computer Science Lecture 8.
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
Variables and Data Types
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
1 Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
C Tokens Identifiers Keywords Constants Operators Special symbols.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
1 Do you have a CS account? Primitive types –“ building blocks ” for more complicated types Java is strongly typed –All variables in a Java program must.
Java Data Types Data types, variable declaration, and initialization.
CS1 Lesson 2 Introduction to C++ CS1 Lesson 2 -- John Cole1.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Computer Science 101 Introduction to Programming.
CPS120: Introduction to Computer Science
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Programming Fundamental Slides1 Data Types, Identifiers, and Expressions Topics to cover here: Data types Variables and Identifiers Arithmetic and Logical.
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
Primitive Variables.
Chapter 3 – Variables and Arithmetic Operations. Variable Rules u Must declare all variable names –List name and type u Keep length to 31 characters –Older.
Chapter 2 Variables.
COMP Primitive and Class Types Yi Hong May 14, 2015.
This will all add up in the end. Assignment operator =Simple Assignment operator Arithmetic Operators +Additive operator – Subtraction operator * Multiplication.
CMPSC 121- Spring 2015 Lecture 6 January 23, 2015.
1 Week 5 l Primitive Data types l Assignment l Expressions l Documentation & Style Primitive Types, Assignments, and Expressions.
CPS120: Introduction to Computer Science Variables and Constants.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
1 09/03/04CS150 Introduction to Computer Science 1 What Data Do We Have.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
Tokens in C  Keywords  These are reserved words of the C language. For example int, float, if, else, for, while etc.  Identifiers  An Identifier is.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
1 1 Chapter 2 Elementary Programming. 2 2 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from.
Arithmetic Operations (L05) * Arithmetic Operations * Variables * Declaration Statement * Software Development Procedure Problem Solving Using C Dr. Ming.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Java Programming: Guided Learning with Early Objects Chapter 1 Basic Elements of Java.
A variable is a name for a value stored in memory.
Chapter 2 Variables.
BASIC ELEMENTS OF A COMPUTER PROGRAM
Data Types, Arithmetic Operations
ITEC113 Algorithms and Programming Techniques
Data Types, Identifiers, and Expressions
Revision Lecture
Java Programming: From Problem Analysis to Program Design, 4e
Lecture Set 4 Data Types and Variables
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Chapter 2 Variables.
Primitive Types and Expressions
Chapter 2 Variables.
Chapter 2 Primitive Data Types and Operations
Variables and Constants
Programming Fundamental-1
Presentation transcript:

Introduction ABAP Fields and Variables

Slide 2 Fields (Introduction) In ABAP, fields (or data objects) are named locations in memory Variables store data that might change Constants store data that does not change As before, fields are declared with the DATA keyword KEEP IN MIND THAT ABAP IS A ‘BUSINESS’ PROGRAMMING LANGUAGE

Slide 3 Field Naming Field names must begin with a letter or underscore character Subsequent characters can be digits 30 character maximum variable length Avoid special characters Don’t use anything but an underscore Don’t use a dash for reasons you will discover shortly Cannot be reserved words

Slide 4 Fields (Characteristics) They nave a name A defined length And a data type And possibly a length And possibly an initial value

Slide 5 Fields (Primary Data Types)

Slide 6 Data Types and the ABAP Dictionary ABAP data types and ABAP dictionary data types are not exactly the same Dictionary types map to more simple ABAP types See handout

Slide 7 Numeric Data Types (1) Integer numbers are whole number having a value range between -2**31 to 2**31-1 Results are rounded not truncated Floating point numbers (data type F) are similar to IEEE floating point numbers They are converted to a binary value and are subject to rounding error

Slide 8 Numeric Data Types (2) Packed numbers (data type P) use an internal SAP format The size is program defined between 1 and 16 bits Each digit occupies 4 bits So two decimal digits are packed into one byte Up to 14 digits allowed after the decimal point Make sure that fixed-point arithmetic is set. otherwise values are treated as integers P fields are slow

Slide 9 Declaring Variables (1) The DATA statement declares a variable Syntax: DATA VARNAME TYPE DATATYPE [VALUE INITIALVALUE]. Example: Declare an integer having an initial value of 5. DATA IntValue1 TYPE I VALUE 5.

Slide 10 Packed Numbers (Example) DATA packed16 TYPE P LENGTH 7 DECIMALS 2. packed16 = ' '. WRITE packed16. Produces

Slide 11 LIKE Declare a variable having the dame data type as another variable Makes it easier to change data types DATA demo16instance1 LIKE packed16. DATA demo16instance2 LIKE packed16.

Slide 12 Arithmetic Operators are as usual +, -, /, * Use DIV for integer division and MOD for integer remainder THERE MUST BE A BLANK CHARACTER BEFORE AND AFTER THE ‘=‘ SIGN AND BETWEEN ARITHMETIC OPERATORS AND PARENTHESIS

Slide 13 Arithmetic (Type Conversion) Looks like any other arithmetic expression (plus the space requirements) SAP calls this compatible and convertible data types Compatible types have the same data type, field type, … Comparable types are converted using conversion rules (See handout)

Slide 14 Type Coercion (1) The following produces “1” because the result is rounded to an int

Slide 15 Type Coercion (2) Floating point data (F, P) are rounded and converted to integers Floating point numbers are rounded when converted to packed values When converting character fields to numbers, the source field must contain a valid number More about dates later

Slide 16 Numeric Overflow Outcome

Slide 17 System Fields System fields are constants defined by the system SY-SUBRC – return code of a procedure SY-UNAME – logon name of the user SY-DATUM – current date SY-UZEIT – current type SY-TCODE – current transaction code

Slide 18 Constants The CONSTANTS statement declares a constant CONSTANTS pi TYPE P LENGTH 15 DECIM ALS 14 VALUE ' '.