0% found this document useful (0 votes)
15 views

BC 414 - Programming Database Changes Complee

Uploaded by

yasra shakil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

BC 414 - Programming Database Changes Complee

Uploaded by

yasra shakil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

Index For BC414

2015年5月25日 20:47

Unit 1 Database Updates with Open SQL


Lesson: Database Updates with Open SQL
Open SQL: Introduction
Open SQL: Syntax
Navigating in the Exercises
Lesson: LUWs in the SAP Client Server Architecture
LUWs in the SAP Client Server Architecture
Unit 3 SAP Locking Concept
Lesson: Reasons for Using Locks
Reasons for Using Locks
The SAP Locking Concept
Lesson: Lock Objects and Lock Modules
SAP Lock Objects
Generating Lock Modules
Lesson: Setting and Releasing Locks
Setting, Removing and Administering SAP Locks
Use and Effect of the Lock Modes
Setting and Releasing Locks (Timecourse)
Lesson: Database changes from within the application program
Direct Updates from Within the Program
Using Delayed Subroutines for Database Updates
Lesson: Database changes using update techniques
Summary: Updates from the Application Program
Principle and Process Flow of the Update
Technical Implementation of the Update
Use and Effect of the Update Modes
Optimization Notes for Database Changes
Lesson: Runtime Architecture and Storage Access for Programs Called Within
Programs Called Within Programs
Accessing ABAP and SAP Memory
Lesson: Passing Data Between Programs
Passing Data Between Programs
Lesson: LUW Logic in Program-Controlled Calls
LUW Logic in Program-Controlled Calls
Unit 6 Appendix
Lesson: Number Assignment
Number Range Objects and Intervals
Function Modules for Number Management
Buffering Numbers
Using Function Groups to Manage Number Ranges
Lesson: Creating Change Documents
Principle of Creating Change Documents
Creating Change Documents
Change Document Management
Lesson: Authorization Checks
Program-Controlled Authorization Checks
Lesson: SAP Buffers
SAP Buffers
Updating SAP Buffers
Buffering Types
Lesson: Native SQL
Native SQL

分区 Index 的第 1 页
Native SQL
Lesson: Cluster Tables
Data Cluster
Syntax
ABAP Cluster Databases
Key of Database Table INDX
Cluster Tables and Transparent Tables
Lesson: SAP Locks
Update and Lock Durations for _scope = 1
Lesson: BAPI Transaction Model
BAPI Definition
Where Are BAPIs Used?
BAPI Properties
BAPI Transaction Model as of Release 4.6 (Example

分区 Index 的第 2 页
Lesson: Database Updates with Open SQL
2015年5月25日 20:44

Open SQL: Introduction


Overview: SQL terms

Target Quantity and Return Values

Accessing Client-Specific Tables

分区 Unit 1 Database Updates with Open SQL 的第 3 页


分区 Unit 1 Database Updates with Open SQL 的第 4 页
Open SQL: Syntax
2015年5月25日 21:08

Open SQL: Syntax


Creating a Single Record

This INSERT variant has the following return codes:

• 0: Line inserted successfully.


• 4: Line could not be inserted because a line with the same key already exists.

Creating Several Records

Changing a Single Record


分区 Unit 1 Database Updates with Open SQL 的第 5 页
Changing a Single Record

These two UPDATE variants have the following return codes :


• 0: Line was changed.
• 4: Line could not be changed because, for example, the specified key does
not exist.

Changing Several Records (Through Condition)

Changing Several Records (Through Internal Table)

分区 Unit 1 Database Updates with Open SQL 的第 6 页


Changing Several Records (Through Internal Table)

Modifying Single Record / Several Records

Deleting a Single Record

分区 Unit 1 Database Updates with Open SQL 的第 7 页


Deleting Several Records (Through Condition)

Deleting Several Records (Through Internal Table)

分区 Unit 1 Database Updates with Open SQL 的第 8 页


Restoring Previous Database Status

There are two ways of causing a database rollback:


• Sending a termination dialog message (A-Message)
• UsingtheROLLBACK WORK ABAP statement

分区 Unit 1 Database Updates with Open SQL 的第 9 页


Navigating in the Exercises
2015年5月25日 21:39

Navigating in the Exercises

分区 Unit 1 Database Updates with Open SQL 的第 10 页


Lesson: LUWs in the SAP Client Server Architecture
2015年5月26日 15:17

LUWs in the SAP Client Server Architecture


SAP Logical Unit of Work (SAP LUW):

Database LUW

Implementing a SAP LUW Within a DB LUW

分区 Unit 2 LUWs and Client Server Architecture 的第 11 页


Implementing a SAP LUW Within a DB LUW

Client-Server Architecture of the R/3 System

Implicit DB Commits

分区 Unit 2 LUWs and Client Server Architecture 的第 12 页


分区 Unit 2 LUWs and Client Server Architecture 的第 13 页
Lesson: Reasons for Using Locks
2015年5月26日 15:28

Reasons for Using Locks

分区 Unit 3 SAP Locking Concept 的第 14 页


The SAP Locking Concept
2015年5月26日 15:34

The SAP Locking Concept


Database Locks Are Not Enough

In the R/3 System, this means that each database lock is released when a new
screen is displayed, since a change of screen triggers an implicit database commit.
Therefore, database locks are not sufficient if data is collected throughout several
screens and the respective data records are to be kept locked during this time frame.

SAP Locking Concept Logical Locks

分区 Unit 3 SAP Locking Concept 的第 15 页


分区 Unit 3 SAP Locking Concept 的第 16 页
Lesson: Lock Objects and Lock Modules
2015年5月26日 15:41

SAP Lock Objects

Lock objects are maintained in the ABAP Dictionary. Customer lock objects must
begin with EY or EZ

分区 Unit 3 SAP Locking Concept 的第 17 页


Generating Lock Modules
2015年5月26日 15:43

Generating Lock Modules

分区 Unit 3 SAP Locking Concept 的第 18 页


Lesson: Setting and Releasing Locks
2015年5月26日 15:44

Setting, Removing and Administering SAP Locks

If an application program that has created lock entries is terminated, the locks are
released automatically (implicitly). Program termination takes place, for example,
if you have messages of the type A / X, if you have the statements LEAVE
PROGRAM and LEAVE TO TRANSACTION , or if the user enters /n in the
command field..

Calling the Lock Modules

分区 Unit 3 SAP Locking Concept 的第 19 页


Release all the blocks: DEQUEUE_ALL.

Lock argument

The core part of a lock entry is the lock argument that consists of the
lock parameters (key fields of the respective table) and the key of the table
entry(entries) to be locked.

Setting Up and Managing the Lock Table

To display the lock table, use transaction SM12.

分区 Unit 3 SAP Locking Concept 的第 20 页


Parameters in ENQUEUE Module

Using the Lock Container

Faster

Delete: RESET_ENQUEUE

分区 Unit 3 SAP Locking Concept 的第 21 页


Use and Effect of the Lock Modes
2015年5月26日 15:58

Use and Effect of the Lock Modes


Lock mode

Effect of Lock Modes (View: Other User)

Effect of Lock Modes (View: Same Program)

分区 Unit 3 SAP Locking Concept 的第 22 页


分区 Unit 3 SAP Locking Concept 的第 23 页
Setting and Releasing Locks (Timecourse)
2015年5月26日 16:03

Setting and Releasing Locks (Timecourse)

These steps pertain to lock requests and database accesses:


1. Setting locks for the data to be processed.
2. If the lock has been successfully set, read the current data from the database.
3. Change the program data (user inputs) and update the changes to the database.
4. Release set locks once again.

Danger If Locks Used Incorrectly

分区 Unit 3 SAP Locking Concept 的第 24 页


分区 Unit 3 SAP Locking Concept 的第 25 页
Lesson: Database changes from within the application program
2015年5月26日 20:29

Direct Updates from Within the Program


Timescale

Data flow

分区 Unit 4 Organizing Database Updates 的第 26 页


Lock

分区 Unit 4 Organizing Database Updates 的第 27 页


Using Delayed Subroutines for Database Updates
2015年5月26日 20:56

Using Delayed Subroutines for Database Updates


PERFORM ON COMMIT: Timescale

PERFORM ON COMMIT: Data flow

分区 Unit 4 Organizing Database Updates 的第 28 页


分区 Unit 4 Organizing Database Updates 的第 29 页
Lesson: Database changes using update techniques
2015年5月26日 21:14

Summary: Updates from the Application Program

分区 Unit 4 Organizing Database Updates 的第 30 页


Principle and Process Flow of the Update
2015年5月26日 21:17

Principle and Process Flow of the Update


Update Principle

Process: Writing Requests

分区 Unit 4 Organizing Database Updates 的第 31 页


Process: Completing Requests

Process: Having Requests Read

Process: Performing Database Updates

分区 Unit 4 Organizing Database Updates 的第 32 页


Process: Deleting Requests

分区 Unit 4 Organizing Database Updates 的第 33 页


Technical Implementation of the Update
2015年5月26日 21:24

Technical Implementation of the Update


Update Modules

Writing/Closing Requests

Discarding Requests (Generation Phase)

分区 Unit 4 Organizing Database Updates 的第 34 页


Discarding Requests (Generation Phase)

Discarding Requests (Processing Phase)

Setting Locks in the Update

分区 Unit 4 Organizing Database Updates 的第 35 页


分区 Unit 4 Organizing Database Updates 的第 36 页
Use and Effect of the Update Modes
2015年5月26日 21:31

Use and Effect of the Update Modes


Asynchronous Update

In asynchronous updates, the dialog program and update program run separately:

• The dialog program writes the change requests to the log table and closes
the LUW with a COMMIT WORK.
• The update initiated by the COMMIT WORK now processes the change
requests. The dialog program is continued; the system does not wait for
the update to end.
• The update program runs in a special update work process. This can be on an
application server other than the one used for the R/3 System.

Synchronous Update

分区 Unit 4 Organizing Database Updates 的第 37 页


If you have a synchronous update that is triggered by COMMIT WORK AND
WAIT, the dialog program waits for the udpate to end before program processing
is continued.

Local Update

V1 and V2 Updates

分区 Unit 4 Organizing Database Updates 的第 38 页


Generating V1 and V2 Requests

Update Execution

分区 Unit 4 Organizing Database Updates 的第 39 页


Setting Locks in the Update

分区 Unit 4 Organizing Database Updates 的第 40 页


Optimization Notes for Database Changes
2015年5月26日 21:45

Optimization Notes for Database Changes


Shortest Possible Database Locks

PERFORM ON COMMIT in the Update

分区 Unit 4 Organizing Database Updates 的第 41 页


Lesson: Runtime Architecture and Storage Access for Programs
Called Within Programs
2015年5月27日 12:39

Programs Called Within Programs


Synchronous Calls

Asynchronous Call of a Function Module

分区 Unit 5 Complex LUW Processing 的第 42 页


Accessing ABAP and SAP Memory
2015年5月27日 13:02

Accessing ABAP and SAP Memory


Logical Memory Level Model

Storage access for a synchronous function module call

Storage access for SUBMIT AND RETURN and CALL TRANSACTION


分区 Unit 5 Complex LUW Processing 的第 43 页
Storage access for SUBMIT AND RETURN and CALL TRANSACTION

Storage access for SUBMIT

Storage access for LEAVE TO TRANSACTION

分区 Unit 5 Complex LUW Processing 的第 44 页


Storage access for an asynchronous function module call

分区 Unit 5 Complex LUW Processing 的第 45 页


Lesson: Passing Data Between Programs
2015年5月27日 13:20

Passing Data Between Programs

Data Transfer Through the Call Interface

If you are calling an ABAP program that has a standard selection screen, you can
pass values to the input fields on the selection screen.. There are two ways to
do this:
• You enter a variant for the call (SUBMIT addition USING SELECTION-SET)
• By entering actual values for the input fields on the selection screen during the call (see next figure).

分区 Unit 5 Complex LUW Processing 的第 46 页


• By entering actual values for the input fields on the selection screen during the call (see next figure).

SUBMIT . . . WITH

Passing Data Using the ABAP Memory

Data Transfer Through the SAP Memory

分区 Unit 5 Complex LUW Processing 的第 47 页


Screen Default Value Through the SAP Memory

分区 Unit 5 Complex LUW Processing 的第 48 页


Lesson: LUW Logic in Program-Controlled Calls
2015年5月27日 21:11

LUW Logic in Program-Controlled Calls


SAP LUWs in Synchronous Program Calls

SAP LUWs for CALL TRANSACTION

Call Mode in CALL TRANSACTION

分区 Unit 5 Complex LUW Processing 的第 49 页


分区 Unit 5 Complex LUW Processing 的第 50 页
Lesson: Number Assignment
2015年5月28日 10:04

Number Range Objects and Intervals


Overview

Number assignment takes place either externally or internally.

External:
The user inputs a number that is then checked by the system
to see if it has been reserved for external assignment.

Internal:
the system automatically assigns a number to a business object. Thus,
there are different number ranges for external and internal number assignment.

Number Range Objects

分区 Unit 6 Appendix 的第 51 页
Number Range Object Transaction Code : SNRO
Number range objects can be organized according to subobjects (for example,
according to company code, user department, or airline carrier).

Number Range Intervals

Subobjects

分区 Unit 6 Appendix 的第 52 页
分区 Unit 6 Appendix 的第 53 页
Function Modules for Number Management
2015年5月28日 10:19

Function Modules for Number Management


Getting Numbers (From Internal Number Range)

When assigning numbers internally, call the function module


NUMBER_GET_NEXT to determine the next number(s) available.

Check Number (in the External Number Range)

Use the function module NUMBER_CHECK for checking external numbers to


see if they lie within a number range interval that has been designated for external
use.

Getting Number Range Information


分区 Unit 6 Appendix 的第 54 页
Getting Number Range Information

分区 Unit 6 Appendix 的第 55 页
Buffering Numbers
2015年5月28日 10:25

Buffering Numbers
Accessing Table NRIV Without a Buffer

The data for number ranges is stored in table NRIV.

The advantages of non-buffered access are:


• number assignment without gaps
• chronological sequence of numbers
Disadvantages are:
• Serialization due to database lock
• Possible mulitiplication effects (see next figure)

分区 Unit 6 Appendix 的第 56 页
Access Through Number Range Buffer (Standard)

Number range servers are logical units on the application server and run their own
LUWs. Thus gaps can occur in number assignments due to rollback or network
errors.

Parallel Access to Number Ranges

分区 Unit 6 Appendix 的第 57 页
Another means of assigning buffered numbers is to buffer the numbers block by
block for each application server on the database.

Features:
• Serialization only takes place for each individual server.
• No gaps.
• Not in chronological order.

分区 Unit 6 Appendix 的第 58 页
Using Function Groups to Manage Number Ranges
2015年5月28日 10:38

Using Function Groups to Manage Number Ranges

分区 Unit 6 Appendix 的第 59 页
Lesson: Creating Change Documents
2015年5月28日 10:40

Principle of Creating Change Documents

You must transfer the following data to the update module that writes the change
documents:
• Application data before it is changed by the program
• Application data updated in the program
• Administration data for the document header (user ID, change date, change
time, name of the transaction making the change, and so on).

分区 Unit 6 Appendix 的第 60 页
Creating Change Documents
2015年5月28日 10:48

Creating Change Documents


Structure of Change Documents

Document-Relevant Fields of a Data Record

Creating Change-Document Objects

分区 Unit 6 Appendix 的第 61 页
Generating Document-Creation Module and Call

For each defined change-document object, the system can generate the
corresponding document-generation function module and also call the module
together with the required data declarations (ABAP syntax).

Structure of the generated Includes

分区 Unit 6 Appendix 的第 62 页
Use of Includes in the Application Program

分区 Unit 6 Appendix 的第 63 页
Change Document Management
2015年5月28日 10:58

Change Document Management


Displaying Change Documents

Function Groups for Processing Change Documents

分区 Unit 6 Appendix 的第 64 页
Lesson: Authorization Checks
2015年5月28日 11:35

Program-Controlled Authorization Checks


The R/3 Authorization Concept

Authorization Object / Authorization (Example)

Performing Authorization Checks

分区 Unit 6 Appendix 的第 65 页
Authorization Checks for Transactions

分区 Unit 6 Appendix 的第 66 页
Lesson: SAP Buffers
2015年5月28日 11:43

SAP Buffers

The aims of buffering are to:

• Reduce the time needed to access data with read accesses. Data on the
application server can be accessed more quickly than data on the database.
• Reduce the load on the database. Reading the data from application server
buffers reduces the number of database accesses.

分区 Unit 6 Appendix 的第 67 页
Updating SAP Buffers
2015年5月28日 19:41

Updating SAP Buffers

分区 Unit 6 Appendix 的第 68 页
Buffering Types
2015年5月28日 19:44

Buffering Types

There are three different types of buffering:

• Resident buffering (100%): The whole table is loaded to the table buffer
when the table is accessed for the first time.
• Generic buffering: A generic key (first n key fields) must be specified in
the technical settings for the table in the ABAP Dictionary.
• Single-record buffering: Only single records are read by the database and
stored in the table buffer.

分区 Unit 6 Appendix 的第 69 页
Lesson: Native SQL
2015年5月28日 19:47

Native SQL

分区 Unit 6 Appendix 的第 70 页
Lesson: Cluster Tables
2015年5月28日 19:49

Data Cluster

A data cluster is a combination of data objects. Data objects are fields, structured
fields, internal tables, and complex structures derived from these.

分区 Unit 6 Appendix 的第 71 页
Syntax
2015年5月28日 19:54

Syntax: EXPORT to Cluster Database

Syntax: IMPORT and DELETE

分区 Unit 6 Appendix 的第 72 页
ABAP Cluster Databases
2015年5月28日 19:57

ABAP Cluster Databases

You can create your own ABAP cluster databases To do this, proceed as follows:
• Define a database table as a transparent table in the ABAP Dictionary. This
table represents its cluster database.
• Build the table structure as shown above.
• The MANDT field can be omitted (it will be filled automatically if it exists).
• The fields RELID, SRTF2, CLUSTR, CLUSTD and the cluster ID are filled
automatically within an EXPORT action.
• Any user-defined fields must be filled before the EXPORT. They can then be
evaluated after an IMPORT.
• You can choose the field names for the cluster ID and your own fields. The
remaining field names are specified by the system.
• The length of the part used for the data cluster is calculated from the total
length of the structure minus the length of the first six fields.

分区 Unit 6 Appendix 的第 73 页
Key of Database Table INDX
2015年5月28日 20:01

Key of Database Table INDX

The INDX database is an example of a database table in which you can store data
clusters. It is installed in your system by default and has a key length of 31 bytes.

The key consists of a client, area, cluster ID, and subsequent record number.

Example: Catalog for INDX

分区 Unit 6 Appendix 的第 74 页
Cluster Tables and Transparent Tables
2015年5月28日 20:08

Cluster Tables and Transparent Tables

分区 Unit 6 Appendix 的第 75 页
Lesson: SAP Locks
2015年5月28日 20:19

Update and Lock Durations for _scope = 1

Update and Lock Durations for _scope = 3

分区 Unit 6 Appendix 的第 76 页
Lesson: BAPI Transaction Model
2015年5月28日 20:24

BAPI Definition

BAPIs can perform various functions such as:


• Creating an object
• Retrieving the attributes of an object
• Changing the attributes of an object

分区 Unit 6 Appendix 的第 77 页
Where Are BAPIs Used?
2015年5月28日 20:26

Where Are BAPIs Used?

分区 Unit 6 Appendix 的第 78 页
BAPI Properties
2015年5月28日 20:27

BAPI Properties

分区 Unit 6 Appendix 的第 79 页
BAPI Transaction Model as of Release 4.6 (Example External
Client)
2015年5月28日 20:30

BAPI Transaction Model as of Release 4.6 (Example External Client)

分区 Unit 6 Appendix 的第 80 页

You might also like