SELECT-OPTIONS. SELECT-OPTIONS Syntax TABLES customers. SELECT-OPTIONS id FOR customers-id. START-OF-SELECTION.

Slides:



Advertisements
Similar presentations
SAP Performance & Tuning Bonus material for 201 ABAP Interview Questions Material code : BM02 Author.
Advertisements

SAP Memory Management (an Overview)
ABAP Chapter 5 Modularization Catch Statement.
IF statement (i) Single statement. IF ( logical expression ) statement Example: read(*,*) a if (a. lt. 0) a = -a write(*,*) a Or read(*,*) a if (a < 0)
Users & Authorization Users must be setup and roles assigned to user master records before you can use the SAP System. A user can only log on to the system.
Visit : Call Us: US: , India:
Visit : Call Us: US: , India:
0 UMN 2011 ERP Terapan SAP BASIS General Concept Session # 3.
1 ABAP Basics III Northern Arizona University College of Business.
ABAP/4 PROGRAMMING Internal Table 講 師:呂 昇 燦 2000 年 9 月 26 日.
ABAP Chapter 2 Report Statement Write & Format Statement Flow Control in ABAP Manipulating Character Data Report Driven : Page Report (List Header)
Lecture 1 Introduction to the ABAP Workbench
 SAP AG CSU Chico Searching and Selecting Data from R/3 ABAP/4 class Gail Corbitt - Fall 1998.
ABAP Chapter 6 Message Debugging File Transfer Type Group.
 SAP AG CSU Chico MINS298c ABAP/4 Programming Gail Corbitt Fall 1998 Chapter 1-3.
University of Southern California Enterprise Wide Information Systems ABAP/ 4 Programming Language Instructor: Richard W. Vawter.
ABAP and Stuff MINS298c-01 Fall Overview Control Break Logic in ABAP Nested Selects Debugger Extended Check Runtime Comparisons.
Flow of Control MINS298c Fall 1998 Chapter 9. Overview ABAP Programming Structures for: –Iteration –Decisions Control Flow –If … Then –Do & While loops.
WebDynpro for ABAP Short introduction.
Overview SAP Basis Functions. SAP Technical Overview Learning Objectives What the Basis system is How does SAP handle a transaction request Differentiating.
ABAP Chapter 3 Open SQL Internal Table. SAP System : 3 Tier Client/Server DB Server SAP Application Server SAP GUI Presentation Server SAP GUI.
0 UMN 2011 ERP Terapan ABAP Introduction Session # 8.
Control Break Report ALV Report
Introduction to ABAP and SAP Structure
ABAP/4 PROGRAMMING Menu Painter Modularization 講 師:呂 昇 燦 2000 年 9 月 28 日.
SAP Overview SAP? Company ERP Software package –R/2 –R/3.
ABAP/4 Course. General n Workbench n Program maintenance n Screen Painter n Menu Painter n Transactions n ABAP/4 Query n Translation menu.
Advanced PI Calculation Engine Makes Complex PI Calculations Easy! Use of EDICTvb for Multi-Plant Advanced PI Calculations Dane OverfieldEXELE Information.
SAP Script. 2 The ASP plus Solutions Company SAP Script is the SAP System's own text- processing system. SAP Script is integrated text management system.
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),
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.
Creating Dialog (ABAP Dynpro) Programs. Slide 2 Introduction All of the ERP systems operate similarly with regard to transactional integrity They all.
0 UMN 2011 ERP Terapan Dialogs Programming Session # 11.
Stored procedures1 Stored procedures and functions Procedures and functions stored in the database.
6 Memory Management and Processor Management Management of Resources Measure of Effectiveness – On most modern computers, the operating system serves.
User Dialog Overview. Update Statement TABLES customers. SELECT SINGLE * FROM customers WHERE id = 1. IF sy-subrc = 0. customers-name = ‘John’. UPDATE.
Introduction to ABAP Selection Screens. Slide 2 Screens (Types) There are three types of screens Selection screens get parameter input for reports List.
MS Visual Basic Applications Walter Milner. Event-driven programming Standard approach for GUIs Contrast with old character interfaces – program determines.
ITEC3612 Enterprise Architecture and Resource Planning (Lab) ABAP Programming (2)
CS178 Database Management PL/SQL session 8 References: ORACLE 9i PROGRAMMING A Primer Rajshekhar Sunderraman.
Perl Language Yize Chen CS354. History Perl was designed by Larry Wall in 1987 as a text processing language Perl has revised several times and becomes.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Report Layout Report Heading Report Body Column Heading Report Title.
ABAP 程式設計 楊子青 D3a-1 Create and Use the Authorization Objects in ABAP n Authorization Check –Authorization Objects are used to manipulate the current user’s.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
ABAP/4 PROGRAMMING Data Dictionary(1) 講 師:呂 昇 燦. Data Browser - SE16 ABAP Workbench tool for displaying information about table entries. You use the Data.
Mantova, September 2015 SAP ECC 6.0 DEVELOPMENT ABAP SAP develop enviroment & Transport organizer.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
SAP DEVELOPMENT BASICS Bohuslav Tesar. TRAINING OVERVIEW Amazing life of ABAP developer ;) SAP introduction ABAP basics ABAP Reporting.
Techniques for List Creation (2) Data formatting and control level processing Basics for Interactive Lists Detail lists The Program Interface Interactive.
Introduction to ABAP/4 A dvanced B usiness A pplication P rogram – Release 4 Why Use ABAP? –Programming language of SAP –Main purpose is to provide additional.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Lesson 9: Modular Programming Todd A. Boyle, Ph.D. St. Francis Xavier University.
 / 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.
Subroutines (PrArith, Math,projCP1, PrAdrProc, PrAdrProcFunc) Please use speaker notes for additional information!
SAP R/3 User Administration1. 2 User administration in a productive environment is an ongoing process of creating, deleting, changing, and monitoring.
CTS Change & Transport System. Introduction The Change and Transport System (CTS) is a tool that helps you to organize development projects in the ABAP.
SPECTO TRAINING contact us: , mail :
ABAP Workbench Fundamentals
SAP Overview.
ABAP EVENTS & Interaction
SAP ABAP Online Training
Handling Exceptions.
Microsoft Access Illustrated
PL/SQL Scripting in Oracle:
ABAP/4程序员之路——第3天 上海华和得易信息技术有限公司 王勇.
Subroutines and Functions
SAP Memory Management (an Overview)
Screen Elements for Input/Output
Presentation transcript:

SELECT-OPTIONS

SELECT-OPTIONS Syntax TABLES customers. SELECT-OPTIONS id FOR customers-id. START-OF-SELECTION.

SELECT-OPTIONS “ ต้องการให้แสดงข้อมูล customers ของ ลูกค้าที่มีชื่อ ( คอลัมน์ name) ขึ้นต้นด้วย ตัว ‘M’ และลูกค้าที่ชื่อ ‘Smith’ และลูกค้า ที่ชื่ออยู่ระหว่าง ‘A’ กับ ‘John’ โดยใช้ คำสั่ง SELECT” SELECT * FROM customers WHERE (name LIKE ‘M%’) OR (name = ‘Smith’) OR (name BETWEEN ‘A’ AND ‘John’).

SELECT-OPTIONS TABLES customers. SELECT-OPTIONS sname FOR customers-name. START-OF-SELECTION. SELECT * FROM customers WHERE name IN sname.

Internal Structure of Select-options sname Internal Table Header Line

Internal Structure of SELECT-OPTIONS Field Value. Sign I = Include E = Exclude Option BT = Between CP = Contains Pattern EQ = Equal GT = Greater Than LT = Less Than GE = Grater Than or Equal LE = Less Than or Equal NE = Not Equal NB = Not Between

Internal Structure of SELECT-OPTIONS sname

SELECT-OPTIONS sname SELECT * FROM customers WHERE name IN sname. SELECT * FROM customers WHERE (name LIKE ‘M%’) OR (name = ‘Smith’) OR (name BETWEEN ‘A’ AND ‘John’). Transform

SELECT-OPTIONS Options SELECT-OPTIONS sname FOR customers-name OBLIGATORY.

INITIALIZATION Event PARAMETERS: nextday LIKE sy-datum. INITIALIZATION. nextday = sy-datum + 1. START-OF-SELECTION. WRITE nextday.

Checking User Input TABLES customers. DATA pcode_len TYPE i. PARAMETERS pcode LIKE customers- postcode. AT SELECTION-SCREEN. pcode_len = STRLEN( pcode ). IF pcode_len <> 5. “ IF STRLEN( pcode ) <> 5. MESSAGE e000(38) WITH ‘Please enter postcode 5 characters’. ENDIF. START-OF-SELECTION. SELECT * FROM customers WHERE postcode = pcode. …

ABAP Program Processing Steps TABLES sflight. PARAMETERS nextday LIKE sy-datum. INITIALIZATION. nextday = sy-datum + 1. AT SELECTION-SCREEN. IF nextday < sy-datum. MESSAGE e000(38) WITH ‘Please enter date >= today’. ENDIF. START-OF-SELECTION. SELECT * FROM sflight WHERE... fldate = nextday… …

ABAP Exercise

Modularization

 Subroutine  Function Module

Subroutine START-OF-SELECTION. PERFORM routine1. PERFORM routine2. FORM routine1. SELECT * FROM customers INTO TABLE tab. ENDFORM. FORM routine2. LOOP AT tab. WRITE: / tab-id,tab-name. ENDLOOP. ENDFORM. START-OF-SELECTION. SELECT * FROM customers INTO TABLE tab. LOOP AT tab. WRITE: / tab-id,tab-name. ENDLOOP. LOOP AT tab. WRITE: / tab-id,tab-name. ENDLOOP.

Modularization  Avoid redundancy  Make your program easy to read & improve their structure  Re-use Program components

Subrountine (Program Structure) REPORT ZSR1. *Data declaration TYPES: BEGIN OF strucbkpf, belnr TYPE bkpf-belnr, gjahr TYPE bkpf-gjahr, END OF strucbkpf. DATA tab TYPE TABLE OF strucbkpf with header line. *Processing block START-OF-SELECTION. SELECT belnr gjahr INTO TABLE tab FROM bkpf WHERE blart = 'SA'. LOOP AT tab. WRITE: / tab-belnr,tab-gjahr. ENDLOOP. LOOP AT tab. WRITE: / tab-belnr,tab-gjahr. ENDLOOP. REPORT ZSR2. *Data declaration TYPES: BEGIN OF strucbkpf, belnr TYPE bkpf-belnr, gjahr TYPE bkpf-gjahr, END OF strucbkpf. DATA tab TYPE TABLE OF strucbkpf with header line. *Processing block START-OF-SELECTION. PERFORM read_data. PERFORM display_data. *& * FORM read_data. SELECT belnr gjahr INTO TABLE tab FROM bkpf WHERE blart = 'SA'. ENDFORM. *& * FORM display_data. LOOP AT tab. WRITE: / tab-belnr,tab-gjahr. ENDLOOP. ENDFORM.

Calling and Defining Subroutines REPORT ztest. * Global Data TABLES customers. DATA tmp TYPE i. * Subroutine Calls PERFORM routine1. PERFORM routine2. * Subroutine FORM routine1. DATA tmp1 TYPE p. “Local data WRITE tmp. ENDFORM. FORM routine2. DATA tmp2(10). “Local data ….. ENDFORM.

Call by Value a1 Memory Space(Subroutine) f1 Copy

Call by Value DATA: a1,a2. a1 = ‘A’. a2 = ‘A’. PERFORM routine1 USING a1 a2..…... FORM routine1 USING VALUE(f1) VALUE(f2). f1 = ‘X’. f2 = ‘X’. ENDFORM.

Call by Reference a3 Memory Space(Subroutine) f3 Address Passing

Call by Reference DATA: a3. a3 = ‘A’. PERFORM routine2 USING a3..…... FORM routine2 USING f3. f3 = ‘X’. ENDFORM.

Call by Value and Result a4 Memory Space(Subroutine) f4 Copy

Call by Value and Result DATA: a4,a5. a4 = ‘A’. a5 = ‘A’. PERFORM routine3 USING a4 a5..…... FORM routine3 CHANGING VALUE(f4) VALUE(f5). f4 = ‘X’. f5 = ‘X’. ENDFORM.

Passing Structure as Parameters TABLES sflight. SELECT * FROM sflight. PERFORM subproc USING sflight. ENDSELECT. FORM subproc USING rec LIKE sflight. WRITE: / rec-carrid. ENDFORM.

Passing Internal Table as Parameters DATA: tab LIKE sflight OCCURS 0 WITH HEADER LINE. … PERFORM sub TABLES tab.

Passing Internal Table as Parameters FORM sub TABLES tab1 STRUCTURE tab. LOOP AT tab1. WRITE: / tab1-carrid. ENDLOOP. ENDFORM.

Function Module

Function Module : SE37  Function Group  Function Library - Admin - Import/Export Parameter - Source Code - Main Program - Documentation

Creating Function Module

Function Group When you create a function module, you must assign it to function group The function group is the main program in which a function module is embedded The function group is a program type F,and not executable The entire function group is loaded in a program the first time that you call a function module that belongs to it

Function Group is a container for function modules When a function module is called,the entire function group is loaded into the session of the program Function group is used to define global data for function modules A DATA statement in the global memory of a function group is shared by all the function modules that belong to that function group

Function Group : SE37

Function Group : SE80

Function Module is a code that can be called from any ABAP program,therefore making it a globally accessible object ABAP program pass data to function module from import parameters or internal tables Function module receives data from a program,process the information in its own code, and then sends back information in the export parameters or internal tables

Function Module : SE37

Function Module

Function Module : Import

Function Module : Export

Function Module : Source Code (Logic) FUNCTION z_fmtest. result = number1 ** number2. ENDFUNCTION.

Program Example I REPORT ztest. PARAMETERS: no1 TYPE i, no2 TYPE i. DATA result TYPE i. START-OF-SELECTION. CALL FUNCTION ‘Z_FMTEST’ EXPORTING number1 = no1 number2 = no2 IMPORTING result = result. WRITE: / result.

Exercise : Function Module ? ABAP Program Function Module

EXCEPTIONS

Function Module FUNCTION z_fmtest. IF number1 > 9 AND number2 > 9. RAISE invalidnumber. ELSE. result = number1 ** number2. ENDIF. ENDFUNCTION.

Example II : Exceptions Handler REPORT ztest. PARAMETERS: no1 TYPE i, no2 TYPE i. DATA result TYPE i. START-OF-SELECTION. CALL FUNCTION ‘Z_FMTEST’ EXPORTING number1 = no1 number2 = no2 IMPORTING result = result EXCEPTIONS invalidnumber = 1. IF sy-subrc = 1. write: / ‘Please enter number < 10’. ELSEIF sy-subrc = 0. write: / result. ENDIF.

Exercise : Exceptions ? ABAP Program Function Module

EXCEPTIONS VS AT SELECTION-SCREEN FUNCTION Z_FMTEST. IF number1 > 9 AND number2 > 9. RAISE invalidnumber. ELSE. result = number1 ** number2. ENDIF. ENDFUNCTION. REPORT ztest. PARAMETERS: no1 TYPE i, no2 TYPE i. AT SELECTION-SCREEN. IF no1 > 9 AND no2 > 9. MESSAGE e000(38) WITH ‘Please enter no < 10’. ENDIF. START-OF-SELECTION. CALL FUNCTION ‘Z_FMTEST’. ….. VS

Optional ABAP Program Function Module

Structure in Function Module

Example : Structure

Internal Table in Function Module

Example : Internal Table

CATCH Statement REPORT ztest. PARAMETERS: num1 TYPE i, num2 TYPE i. DATA result TYPE i. START-OF-SELECTION. CATCH SYSTEM-EXCEPTIONS others = 1. result = num1 / num2. ENDCATCH. IF sy-subrc = 1. WRITE: /'Divide by zero'. ELSE. WRITE: / result. ENDIF.

CATCH in Function Module FUNTION Z_CAL. IF number1 > 9 AND number2 > 9. RAISE invalidnumber. ELSE. result = number1 ** number2. ENDIF. ENDFUNCTION. FUNCTION Z_CAL. CATCH SYSTEM-EXCEPTIONS others = 1. result = number1 ** number2. ENDCATCH. IF sy-subrc = 1. RAISE invalidnumber. ENDIF. ENDFUNCTION.

Authorization in ABAP

Database Server Application Server Dispatcher Request Queue DDDB … SAP Buffer Program … User Context Area Report zpsm1. Tables customers. Select single * from customers where id = 1. Write: / customers-name. 5 Execute ABAP stateme nt Check Program in Program Buffer Roll in 8 Load&Generate Program SQL Request Send List Generate Screen(List) Send Request Request List 2 Search for free WP Store request to queue Send request to WP SAP GUI.. D010S Report zpsm1. Tables customers. Select single * from customers where id = 1. Write: / customers-name. SAP System : Dialog Processing customers

TaskHandler DYNPRO Processor ABAP Processor Local Memory Memory Space DB Interface List Buffer Database Server Dialog Work Process User Context Dialog Work Process Architecture Result Set Memory

SAP Authorization Principles  All data in the SAP system must be protected against access by unauthorized users  Since the SELECT statement does not perform any authorization checks,you must program these yourself with AUTHORITY-CHECK

No Authorization Check TABLES spfli. SELECT * FROM spfli. WRITE: / spfli-carrid, spfli-connid, spfli-cityfrom, spfli-cityto. ENDSELECT.

Authorization Check Syntax AUTHORITY-CHECK OBJECT ID FIELD ……. ID DUMMY. IF sy-subrc <> 0. …. ENDIF.

Authorization Check Selection SELECT AUTHORITY-CHECK Process Data Message sy-subrc = 0 ? No Yes Local Memory User Context Memory Space List Buffer

Authorization Check TABLES spfli. SELECT * FROM spfli. AUTHORITY-CHECK OBJECT ‘S_CARRID’ ID ‘CARRID’ FIELD spfli-carrid ID ‘ACTVT’ FIELD ‘03’. IF sy-subrc = 0. WRITE: / spfli-carrid, spfli-connid, spfli-cityfrom, spfli-cityto. ENDIF. ENDSELECT.

SAP Authorization Objects Transaction : SU03

Authorization Object Field u ABAP Editor : Pattern

Message in ABAP

Dynamic Message REPORT ztest1. PARAMETERS today LIKE sy-datum. AT SELECTION-SCREEN. IF today <> sy-datum. MESSAGE e000(38) WITH ‘Please enter today :’ sy-datum. ENDIF. START-OF-SELECTION. WRITE: / ‘Today is :’, today.

Message Type Message Type Syntax MESSAGE [ A ](message class) WITH. E, W, I, S

Messages Type - A(Abend) Message A000(38)... Program Start Selection Screen A Message Exit

Messages Type - E(Error) Message E 000(38)... Program Start Selection Screen Error Message New input Require

Messages Type - W(Warning) Message W 000(38)... Program Start Selection Screen Warning Message New input possible START-OF-SELECTION Enter

Messages Type - I(Information) Message i 000(38)... Program Start Selection Screen Information Message Enter START-OF-SELECTION

Messages Type - S(Success) Message S 000(38)... Program Start Selection Screen List (Next Screen)

Debugging

Debugging Mode

Debugging Mode : Internal Table

Debugging Mode : Watchpoint

Watchpoint : SAP ECC 6.0

GUI TITLE... SET TITLEBAR ‘ 0100 ’.

ABAP Exercise III

Sale Document : Data Model

Report Example VBAK-VBELNVBAK-ERDAT KNA1-NAME1 VBAP-MATNR VBAP-NETWR ZEX_T

Report Example : Group Header

ON CHANGE OF … … SORT tab BY vbeln. LOOP AT tab. ON CHANGE OF tab-vbeln. WRITE: / sy-vline,2(24) tab-vbeln COLOR 4 INTENSIFIED OFF, 25 sy-vline,26(20) tab-erdat COLOR 4 INTENSIFIED OFF, 45 sy-vline,46(30) tab-name1 COLOR 2 INTENSIFIED OFF. ENDON. WRITE: sy-vline, 25 sy-vline, 45 sy-vline, 75 sy-vline,76(25) tab-matnr COLOR 2 INTENSIFIED OFF, 100 sy-vline,101(18) tab-netwr COLOR 2 INTENSIFIED OFF, 120 sy-vline. NEW-LINE. ENDLOOP. …