Escolar Documentos
Profissional Documentos
Cultura Documentos
Appendix
SAP AG 1999
(C) SAP AG
BC400
14-1
0.2
Typical Information System Requests
Search by attributes
Display all objects of type X
with attribute Y
WhereWhere-used lists
Display all objects of type X
which use attribute Y
Information about
tables and relationships
SAP AG 1999
(C) SAP AG
Modified objects
Display all objects of
type X which were changed by
user Y on date DDMMYY
BC400
14-2
0.3
Overview: Creating Programs
Assign to a
development class
Determine
attributes
Assign project
Editor
Program object
SAP AG 1999
When you create a new program you must first enter various administrative details.
Programs must be assigned to a particular development class. . This classifies the program logically.
Such designation only takes place once, when the repository object is initially created (development
classes are in turn assigned to the component to which they logically belong).
Additionally, several general program attributes must be determined. One important attribute is the
program type. The program type determines how a program is executed in the R/3 client/server
environment, for example if subsequent source text is an executable program or a reusable piece of
code.
Finally, a program must be assigned to a Workbench Organizer project (change request). This
classifies the repository object chronologically. Once the current project is finished, a program can
then be assigned to a new project.
A program can only be edited after these initial designations have been made.
(C) SAP AG
BC400
14-3
0.4
Structures and internal Tables can be Nested
SAP AG 1999
(C) SAP AG
BC400
14-4
0.5
Type Groups in the ABAP Dictionary
TYPE-POOL Z400.
TYPES: z400_name_type(25) TYPE C,
BEGIN OF z400_flightrec_type,
...
,
END OF z400_flightrec_type.
REPORT ... .
TYPE-POOLS z400.
DATA: name TYPE z400_name_type,
wa TYPE z400_flightrec_type.
... .
ABAP
SAP AG 1999
You can define data types in a type group in the ABAP Dictionary instead of defining them within an
ABAP program.
The type group name in the ABAP Dictionary has a maximum of 5 characters. Type names within
type group <typepool> must begin with <typepool> followed by an underscore.
The types in a type group must be declared in ABAP programs with the TYPE-POOLS command.
(C) SAP AG
BC400
14-5
0.6
PARAMETERS and TABLES
PA_CARR
Airline Carrier
Flight number
Continue
Data transport
pa_carr
sdyn_conn
sdyn_conn
TABLES sdyn_conn.
PARAMETERS pa_carr LIKE spfli-carrid.
MOVE pa_carr TO sdyn_conn-carrid.
CALL SCREEN 100.
SAP AG 1999
(C) SAP AG
BC400
14-6
0.7
Deleting an Internal Table
CLEAR <wa>.
CLEAR <itab>.
CARRID
AA
LH
CONNID
0017
0400
SAP AG 1999
Use CLEAR to reset the contents of a data object to the initial value for its type.
Since internal table entries are always of a single type, only one CLEAR statement is
necessary to delete the entire table.
CLEAR <wa> initializes work area <wa>.
(C) SAP AG
BC400
14-7
0.8
Summary of Declarative Statements
Type
TYPES
Elementary Field, Structure,
Internal Table
DATA
Constant
CONSTANTS
Input Parameter
PARAMETERS
Table Work Area
TABLES
SAP AG 1999
Definition of types
Definition of elementary fields, structures, and internal tables
Definition of constants
Definition of input parameters
Definition of table work areas
In the unit Internal Tables as well as in the sub-unit on Selection Screens in the unit on
Dialogs you will learn about the following declarative statement:
SELECT-OPTIONSDefinition of selection possibilities
(C) SAP AG
BC400
14-8
0.9
Type Conversion
Compatible types can be assigned without conversion
Two elementary types are compatible if they are
identical in type and length (and decimal places) ,
in the case of type P).
SAP AG 1999
If you assign data objects of different types to one another, ABAP carries out a type conversion as
long as a conversion rule has been defined for the types concerned.
(C) SAP AG
BC400
14-9
0.10
Logical Expressions
... <field> <operator> <literal> ...
... <field1> <operator> <field2> ...
... <logical expression> AND <logical expression>
... <logical expression> OR <logical expression>
... NOT <logical expression> ...
Operator
DATA: START TYPE D,
SUM1
TYPE P,
SUM2
TYPE P.
.
.
.
IF SUM2 GE 1000.
IF START IS INITIAL.
IF SUM1 GT SUM2 AND
SUM1 BETWEEN 0 AND 100.
IF SUM1 = 1000 AND
( SUM2 LE 2000 OR
START IS INITIAL ).
EQ
NE
<>
GT
>
GE
>=
LT
<
LE
<=
Meaning
Equal
><
Unequal
Greater than
=>
=<
BETWEEN f1 and f2
Interval
IS INITIAL
Initial value
SAP AG 1999
(C) SAP AG
BC400
14-10
0.11
DO and WHILE Loops
DO
<n>
TIMES.
statements
statements
ENDWHILE.
ENDDO.
SY-INDEX
Loop index
SAP AG 1999
(C) SAP AG
BC400
14-11
0.12
CHECK and EXIT
EXIT.
WHILE COUNTER GT 0.
DO.
Statements
Statements
CHECK sy-subrc = 0.
IF counter GE 10.
EXIT.
ENDIF.
Statements
ENDWHILE.
Statements
counter = counter + 1.
ENDDO.
SAP AG 1999
(C) SAP AG
BC400
14-12
0.13
Termination Conditions 2
EXIT
Loops:
WHILE, DO,
SELECT, LOOP
Events:
Exit current
loop
CHECK:
If logical condition not
met, then...
End of program,
list displayed
START-OF-SELECTION
GET
END-OF-SELECTION
Events:
INITIALIZATION
AT SELECTION-SCREEN ...
...
Jump to end of
processing block
FORM routines
SAP AG 1999
Use the ABAP statement CHECK <logical condition> outside of loops to end a processing block
prematurely whenever the logical condition following the keyword is not fulfilled.
EXIT outside of a loop also ends the current processing block. There are several events that are an
exception to this rule. An EXIT statement in their event blocks leads to program termination. In this
case a list is displayed immediately after the EXIT statement has been processed.
(C) SAP AG
BC400
14-13
0.14
Includes: Type I Programs
Include: <include-name>
( Program type: I )
Program: <program-name>
REPORT <program-name>.
:
INCLUDE <Include-Name>.
ABAP statements
SAP AG 1999
(C) SAP AG
BC400
14-14
0.15
TOP Includes
Create program
Repository Browser:
Program
Create program
Program: <name>TOP
<name>
REPORT <name>.
Program type: I
TYPES:...
DATA: ...
Program: <name>
INCLUDE <name>TOP.
Program type: 1
START-OF-SELECTION.
:
SAP AG 1999
(C) SAP AG
BC400
14-15
0.16
Standard Includes for Function Groups
Function group
BC400
BC400_PERCENTAGE
Determines percentage
Subroutines
Includes
LBC400TOP
LBC400F01
Subroutines
LBC400U01
LBC400U02
Determines percentage
LBC400UXX
SAP AG 1999
(C) SAP AG
BC400
14-16
0.17
Central Role of Function Modules
Internet /
Intranet
Customer and partner
development
RFC
Function
modules
asynchrono
us
Encapsulation:
parallel
functions
Dialogs
SAP AG 1999
(C) SAP AG
BC400
14-17
0.18
Exception Handling
Exceptions
Exceptions
FUNCTION bc400_free_seats.
OCC_GT_MAX
MAX_EQ_0
Define exception
.
.
.
IF seatsmax = 0.
RAISE max_eq_0.
ELSEIF seatsocc > seatsmax.
RAISE occ_gt_max.
ENDIF.
.
.
.
Raise exception
ENDFUNCTION.
SAP AG 1999
You can anticipate possible errors and write your program so that these errors do not cause
runtime errors. You give these possible exceptions names in the function module interface,
and trigger them from the program code using the RAISE statement. Each program that
calls the function module can then interpret the exceptions by querying sy-subrc.
In the function module, you can also ensure that the system displays an error message if
the exception occurs, even if it is not explicitly handled by the calling program. For further
information, see the key word documentation for MESSAGE ... RAISING.
(C) SAP AG
BC400
14-18
0.19
Catching Exceptions
REPORT.
DATA:
free_seats LIKE sflight-seatsmax.
PARAMETERS: pa_occ LIKE sflight-seatsocc,
pa_max LIKE sflight-seatsmax.
START-OF-SELECTION.
CALL FUNCTION 'BC400_FREE_SEATS'
EXPORTING
seatsmax
= pa_max
seatsocc
= pa_occ
IMPORTING
seatsfree = free_seats
EXCEPTIONS
occ_gt_max
= 1
max_eq_0
= 2
others
= 3.
CASE sy-subrc.
WHEN 1.
WRITE text-ex1.
WHEN 2.
WRITE text-ex2.
WHEN 3.
WRITE text-oth.
ENDCASE.
SAP AG 1999
(C) SAP AG
BC400
14-19
0.20
Colors/Icons/Symbols in Lists
Colors in Lists
Flight
from
to
AA 0017
LH 0400
LH 0402
NEW YORK
FRANKFURT
FRANKFURT
SAN FRANCISCO
NEW YORK
BERLIN
SAP AG 1999
You can set several list display attributes within a WRITE statement. One such attribute is color,
which can be adjusted using the formatting option COLOR <n>. You can choose from seven
background colors that are activated by either a numeric value or a symbolic name based on where
they appear on a normal list.
0
col_background Background
1
col_heading
Headers
2
col_normal
List entries
3
col_total
Totals
4
col_key
Key columns
5
col_positive
Positive threshold values
6
col_negative Negative threshold values
7
col_group
Control levels
SAP provides guidelines for creating lists in color. Please consult transaction LIBS for examples.
The addition AS ICON within a WRITE statement allows you to add icons to your list. In order to be
able to use AS ICON you must, however, add the include <LIST> to your program.
You can find an overview of all available icons in either the keyword documentation under WRITE,
or in the WRITE statement structure.
(C) SAP AG
BC400
14-20
0.21
External Data Transfer
External
Server
Sequential
Files
SAP
Interfaces /
Checks
SAP AG 1999
When transferring data from another SAP or external system to your own SAP system it is important
to ensure data integrity.
Thus the necessity of subjecting this type of data transfer to the same checks as data transfer in
dialog mode.
Since dialog mode checks in transactions are comprehensive and partially cross-application, it is
extremely difficult to program them yourself.
Therefore, it is much easier to check transactions using the same checks as in the SAP dialog mode.
Concretely, this means that SAP transactions are also used during data transfer.
The techniques used for foreign data transfer are called batch input processes.
SAP offers standardized foreign data transfer procedures for many areas within R/3. The procedures
use the programming techniques batch input, call transaction, and direct input. You can access SAP
standard data transfer procedures using the Data Transfer Workbench (transaction SXDA). If
no SAP data transfer procedures are available, transfer can be programmed individually using batch
input or call transaction.
(C) SAP AG
BC400
14-21
0.22
External Data Transfer
BATCH INPUT:
Sequential
file
CALL TRANSACTION:
Sequential
file
BDC
BDC table
table
DIRECT INPUT:
Sequential
file
BDC
BDC table
table
Queue file
CALL
TRANSACTION
SAP
transfer program
Program
Batch
Batch input
input function
function
Application
Application function
function
SAP
database
Application
Application function
function
SAP
database
SAP
database
SAP AG 1999
(C) SAP AG
BC400
14-22
0.23
Advanced Techniques: Dynamic Screen Sequencing
Screen Attributes
Screen number
Next screen
PBO
100
Screen Attributes
100
100
PAI
Screen number
Next screen
200
PBO
200
200
200
PAI
0
SAP AG 1999
You can use this technique to program clusters of integrated screens without having to
continually return to the source code and call them using CALL SCREEN.
(C) SAP AG
BC400
14-23
0.24
Advanced Techniques: Update
Dialog process
PAI
PBO
PAI
PBO
UPDATE
Request
PBO
INSERT
Request
PAI
DELETE
Request
Log
table
UPDATE req.
INSERT req.
DELETE req.
COMMIT WORK
Update process
UPDATE
INSERT
DELETE
Database process
SAP AG 1999
Another way of bundling database changes at the end of an SAP LUW is to use the update
technique. Here, you do not pass updates directly to the database, but enter them as
update requests in a log table instead.
The dialog part of the SAP LUW ends when the system reaches the COMMIT WORK
statement. The R/3 System then triggers a special work process called an update work
process, which processes the update requests that you have registered in the log table.
The SAP LUW ends when the update work process has finished the database update.
The dialog and update parts of the SAP LUW can run either synchronously or
asynchronously.
The advantage of update in contrast to bundling using subroutines is that you can enter
your update requests in the log table at any time instead of having to keep them in the
program area. Its disadvantage is the impaired performance caused by using the log table.
Use asynchronous update when response times are important and the database updates
are complicated enough to justify the overheads involved in using the log table.
Use synchronous update whenever you need the changed data immediately and when the
database updates are complicated enough to justify the overheads involved in using the log
table.
(C) SAP AG
BC400
14-24