ABAP Data/Internal Tables ITP 321 Anthony Borquez & Jim Graver.

Slides:



Advertisements
Similar presentations
Structured Query Language (SQL)
Advertisements

PHP II Interacting with Database Data. The whole idea of a database-driven website is to enable the content of the site to reside in a database, and to.
Dr. Alexandra I. Cristea CS 252: Fundamentals of Relational Databases: SQL5.
SQL: The Query Language Part 2
Introduction to SQL, OleDB interface to Access from VB.NET.
WaveMaker Visual AJAX Studio 4.0 Training
Advanced ABAP Objects Programming Horst Keller / Stefan Bresch Business Programming Languages, SAP AG.
 SAP AG CSU Chico MINS298c Fall 1998 Three Levels of ABAP Dictionary Chapter 5 & 6.
ABAP/4 PROGRAMMING Internal Table 講 師:呂 昇 燦 2000 年 9 月 26 日.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)MySQL Recap.
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Query-By-Example (QBE) 2440: 180 Database Concepts.
University of Southern California Enterprise Wide Information Systems ABAP/ 4 Programming Language Instructor: Richard W. Vawter.
A Guide to SQL, Seventh Edition. Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 11.
Introduction to Structured Query Language (SQL)
COMPREHENSIVE Access Tutorial 2 Building a Database and Defining Table Relationships.
FIRST COURSE Access Tutorial 2 Building a Database and Defining Table Relationships.
Introduction to Structured Query Language (SQL)
Concepts of Database Management Sixth Edition
Microsoft Access 2010 Chapter 7 Using SQL.
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
ABAP Chapter 3 Open SQL Internal Table. SAP System : 3 Tier Client/Server DB Server SAP Application Server SAP GUI Presentation Server SAP GUI.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Access Lesson 2 Creating a Database
Control Break Report ALV Report
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
ABAP/4 Course. General n Workbench n Program maintenance n Screen Painter n Menu Painter n Transactions n ABAP/4 Query n Translation menu.
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),
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
Database Queries. Queries Queries are questions used to retrieve information from a database. Contain criteria to specify the records and fields to be.
Analyzing Data For Effective Decision Making Chapter 3.
In the next step you will enter some data records into the table. This can be done easily using the ‘Data Browser’. The data browser can be accessed via.
Microsoft Office 2007 Access Chapter 2 Querying a Database.
0 UMN 2011 ERP Terapan Dialogs Programming Session # 11.
Discovering Computers Fundamentals Fifth Edition Chapter 9 Database Management.
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
MIS 3020 ABAP Programming Lecture 2 Elementary & User Defined Types Domains, Elements, Variables/Fields.
Access Project 3 Notes. Introduction Maintaining the Database  Modifying the data to keep it up-to-date Restructure the Database  To change the database.
CS 1308 Computer Literacy and the Internet
ITEC3612 Enterprise Architecture and Resource Planning (Lab) ABAP Programming (2)
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Chapter 8: SQL. Data Definition Modification of the Database Basic Query Structure Aggregate Functions.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Report Layout Report Heading Report Body Column Heading Report Title.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
 / 1 Optimize Database Access From ABAP QL.  / 2 Copyright Please note: No part of this Training Session may be reproduced or transmitted in any form.
Constraints Advanced Database Systems Dr. AlaaEddin Almabhouh.
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
How to: SQL By: Sam Loch.
Databases.
ABAP EVENTS & Interaction
PL/SQL LANGUAGE MULITPLE CHOICE QUESTION SET-1
ABAP/4程序员之路——第3天 上海华和得易信息技术有限公司 王勇.
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
Access: SQL Participation Project
Creating and Managing Database Tables
Unit 8 Search Help 、 Unit 7 Views
Dialog Programming 整合實例
Chapter 3 Query and Report.
Presentation transcript:

ABAP Data/Internal Tables ITP 321 Anthony Borquez & Jim Graver

Examples of Data Types and Objects This example shows how to declare elementary data objects with reference to predefined ABAP types. PROGRAM demo_elementary_data_objects. DATA text1(20) TYPE c. DATA text2 TYPE string. DATA number TYPE i. text1 = 'The number'. number = 100. text2 = 'is an integer.'. WRITE: text1, number, text2.

This example shows how to declare local elementary data types within a program. REPORT demo_types_statement. TYPES mytext(10) TYPE c. TYPES myamount TYPE p DECIMALS 2. DATA text TYPE mytext. DATA amount TYPE myamount. text = ' 4 / 3 = '. amount = 4 / 3. WRITE: text, amount.

This example shows how to declare structures. REPORT demo_structure. TYPES: BEGIN OF name, title(5) TYPE c, first_name(10) TYPE c, last_name(10) TYPE c, END OF name. TYPES: BEGIN OF mylist, client TYPE name, number TYPE i, END OF mylist. DATA list TYPE mylist. list-client-title = 'Lord'. list-client-first_name = 'Howard'. list-client-last_name = 'Mac Duff'. list-number = 1. WRITE list-client-title. WRITE list-client-first_name. WRITE list-client-last_name. WRITE / 'Number'. WRITE list-number.

ClauseDescription SELECT The SELECT clause defines the structure of the data you want to read, that is, whether one line or several, which columns you want to read, and whether identical entries are acceptable or not. INTO The INTO clause determines the target area into which the selected data is to be read. FROM The FROM clause specifies the database table or view from which the data is to be selected. It can also be placed before the INTO clause. WHERE The WHERE clause specifies which lines are to be read by specifying conditions for the selection. GROUP BY The GROUP-BY clause produces a single line of results from groups of several lines. A group is a set of lines with identical values for each column listed in. HAVING The HAVING clause sets logical conditions for the lines combined using GROUP BY. ORDER BY The ORDER-BY clause defines a sequence for the lines resulting from the selection. Reading Data

Reading certain columns of a single line: DATA WA TYPE SPFLI. SELECT SINGLE CARRID CONNID CITYFROM CITYTO INTO CORRESPONDING FIELDS OF WA FROM SPFLI WHERE CARRID EQ 'LH' AND CONNID EQ '0400'. IF SY-SUBRC EQ 0. WRITE: / WA-CARRID, WA-CONNID, WA- CITYFROM, WA-CITYTO. ENDIF.

Reading particular columns of more than one line: DATA: ITAB TYPE STANDARD TABLE OF SPFLI, WA LIKE LINE OF ITAB. SELECT CARRID CONNID CITYFROM CITYTO INTO CORRESPONDING FIELDS OF TABLE ITAB FROM SPFLI WHERE CARRID EQ 'LH'. IF SY-SUBRC EQ 0. LOOP AT ITAB INTO WA. WRITE: / WA-CARRID, WA-CONNID, WA- CITYFROM, WA-CITYTO. ENDLOOP. ENDIF.

Reading all columns of more than one line: DATA WA TYPE SPFLI. SELECT * INTO CORRESPONDING FIELDS OF WA FROM SPFLI WHERE CARRID EQ 'LH'. WRITE: / SY-DBCNT, WA-CARRID, WA-CONNID, WA- CITYFROM, WA-CITYTO. ENDSELECT.

Specifying Columns Dynamically DATA: ITAB TYPE STANDARD TABLE OF SPFLI, WA LIKE LINE OF ITAB. DATA: LINE(72) TYPE C, LIST LIKE TABLE OF LINE(72). LINE = ' CITYFROM CITYTO '. APPEND LINE TO LIST. SELECT DISTINCT (LIST) INTO CORRESPONDING FIELDS OF TABLE ITAB FROM SPFLI. IF SY-SUBRC EQ 0. LOOP AT ITAB INTO WA. WRITE: / WA-CITYFROM, WA-CITYTO. ENDLOOP. ENDIF.

Specifying Internal Tables When you read several lines of a database table, you can place them in an internal table. To do this, use the following in the INTO clause: SELECT... INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE [PACKAGE SIZE ]... The same applies to the line type of, the way in which the data for a line of the database table are assigned to a table line, and the CORRESPONDING FIELDS addition as for flat work areas (see above). The internal table is filled with all of the lines of the selection. When you use INTO, all existing lines in the table are deleted. When you use APPENDING; the new lines are added to the existing internal table. With APPENDING, the system adds the lines to the internal table appropriately for the table type. Fields in the internal table not affected by the selection are filled with initial values.

This example shows how to define an internal table. PROGRAM demo_internal_table. TYPES: BEGIN OF mytext, number TYPE i, name(10) TYPE c, END OF mytext. TYPES mytab TYPE STANDARD TABLE OF mytext WITH DEFAULT KEY. DATA text TYPE mytext. DATA itab TYPE mytab. text-number = 1. text-name = 'John'. APPEND text TO itab. text-number = 2. text-name = 'Paul'. APPEND text TO itab. text-number = 3. text-name = 'Ringo'. APPEND text TO itab. text-number = 4. text-name = 'George'. APPEND text TO itab. LOOP AT itab INTO text. WRITE: / text-number,text-name. ENDLOOP.

Flat structure as target area DATA WA TYPE SPFLI. SELECT * INTO WA FROM SPFLI. WRITE: / WA-CARRID... ENDSELECT.

This example uses a flat structure with the same data type as the database table SPFLI as the target area in a SELECT loop. Within the loop, it is possible to address the contents of the individual columns. DATA SPFLI TYPE SPFLI. SELECT * FROM SPFLI. WRITE: / SPFLI-CARRID... ENDSELECT.

Internal table as target area DATA: BEGIN OF WA, CARRID TYPE SPFLI-CARRID, CONNID TYPE SPFLI-CONNID, CITYFROM TYPE SPFLI-CITYFROM, CITYTO TYPE SPFLI-CITYTO, END OF WA, ITAB LIKE SORTED TABLE OF WA WITH NON-UNIQUE KEY CITYFROM CITYTO. SELECT CARRID CONNID CITYFROM CITYTO INTO CORRESPONDING FIELDS OF TABLE ITAB FROM SPFLI. IF SY-SUBRC EQ 0. WRITE: / SY-DBCNT, 'Connections'. SKIP. LOOP AT ITAB INTO WA. WRITE: / WA-CARRID, WA-CONNID, WA-CITYFROM, WA- CITYTO. ENDLOOP. ENDIF.

Reading packets into an internal table DATA: WA TYPE SPFLI, ITAB TYPE SORTED TABLE OF SPFLI WITH UNIQUE KEY CARRID CONNID. SELECT CARRID CONNID FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE ITAB PACKAGE SIZE 3. LOOP AT ITAB INTO WA. WRITE: / WA-CARRID, WA-CONNID. ENDLOOP. SKIP 1. ENDSELECT.

Single fields as target area: DATA: AVERAGE TYPE P DECIMALS 2, SUM TYPE P DECIMALS 2. SELECT AVG( LUGGWEIGHT ) SUM( LUGGWEIGHT ) INTO (AVERAGE, SUM) FROM SBOOK. WRITE: / 'Average:', AVERAGE, / 'Sum :', SUM.

Using aliases: DATA: BEGIN OF LUGGAGE, AVERAGE TYPE P DECIMALS 2, SUM TYPE P DECIMALS 2, END OF LUGGAGE. SELECT AVG( LUGGWEIGHT ) AS AVERAGE SUM( LUGGWEIGHT ) AS SUM INTO CORRESPONDING FIELDS OF LUGGAGE FROM SBOOK. WRITE: / 'Average:', LUGGAGE-AVERAGE, / 'Sum :', LUGGAGE-SUM.

Adding single lines TABLES SPFLI. DATA WA TYPE SPFLI. WA-CARRID = 'LH'. WA-CITYFROM = 'WASHINGTON'.... INSERT INTO SPFLI VALUES WA. WA-CARRID = 'UA'. WA-CITYFROM = 'LONDON'.... INSERT SPFLI FROM WA. SPFLI-CARRID = 'LH'. SPFLI-CITYFROM = 'BERLIN'.... INSERT SPFLI

Udpating Data TABLES SPFLI. DATA WA TYPE SPFLI. MOVE 'AA' TO WA-CARRID. MOVE '0064' TO WA-CONNID. MOVE 'WASHINGTON' TO WA-CITYFROM.... UPDATE SPFLI FROM WA. MOVE 'LH' TO SPFLI-CARRID. MOVE '0017' TO SPFLI-CONNID. MOVE 'BERLIN' TO SPFLI-CITYFROM.... UPDATE SPFLI.