Curso Introductorio ABAP
Curso Introductorio ABAP
Curso Introductorio ABAP
A course introductory
1
Contents (I)
Requirements
Course objectives
Course goal
Schedule
Evaluation
2
Requirements
Must be an IT Professional Recent programming experience
(within last 5 years) in a 3GL structured programming language
or strong technical background with SAP functional experience
Experience with common programming constructs, algorithms
and computing science concepts (e.g. variables, arrays, loops,
branches, record structures, File I/O, relational database design)
Technical Degree or Diploma (Computer Science or Electrical
Engineering preferred)
Solid working knowledge of Windows 95/98/NT Previous
software development experience in the design and
implementation of GUIs in the Microsoft Windows environment
preferred (e.g. Visual Basic, Microsoft Access, Delphi, etc.)
Database background (SQL, PL/SQL, OpenSQL) or any other
embedded SQL related hybrid
3
Objectives
4
Goal
5
Schedule
Lunes a Viernes:
8:00 am a 12:00am 1:00 pm a 5:00 pm
2 Break de 15 min 9:30 am y 3:00 pm.
6
Contents (II)
Arquitecture SAP R/3
General vision of SAP R/3
System Kernel
Program Flow in an ABAP Program
ABAP Statements and Data Declarations
ABAP Dictionary
Database Dialogs
Internal table operations
Internal Program Modularization
7
Arquitectura SAP R/3
Sistemas Operativos Compatibles con el Sistema Sap R/3
1.- UNIX
2.- Open VMS
3.- MPE/iX
4.- Windows NT
Bases de datos compatibles con el sistema R/3
1.- Informix
2.- Oracle
3.- Software AG
4.- Sybase
Compatibilidad entre la presentaciones del tipo front-end
1.- Windows
2.- OSF/Motif
3.- OS/2PM
4.- Macintosh
8
SAP products (I)
mySAP Business Suite
SAP R/3
SAP R/3 Enterprise
SAP Financial Supply Change Management
SAP Strategic Enterprise Management
SAP Customer Relationship Management
SAP Supplier Relationship Management
SAP Supply Change Management
Industry Portfolios
SAP for Oil and Gas
SAP for Mill products
SAP for Mining
SAP for Engineering, Construction and Operations
SAP for Retail
9
SAP products (II)
SAP Solutions for Small and Midsize Business
SAP Business One
SAP xApps
SAP Solutions for Mobile Businesses
SAP NetWeaver
SAP Web Applications Server
SAP Exchange Infrastructure
SAP Business Information Warehouse
SAP Enterprise Portal
Other Technology Components
SAP Solution Manager
SAP GUI
www.mysap.com
http://es.intelligence.de/es/122.php
10
Evolution of Business
ERP E-Business
Business Enterprise centric...
m
...extended and collaborative
Model
/3 .c o
Processes R
Integrated, core within
P
...and collaborative, beyond
enterprise...
P company boundaries
A
Goals
S A
Internal process
optimization...
yS
...and value creation through
collaboration
11
mySAP.com Technology
Enterprise Portals
Portal
mySAP Enterprise Portals
Infra-
structure
Exchange
Infra-
Exchange
structure
mySAP Exchanges
12
SAP R/3 Evolution
SAP
R/3 Enterprise
SAP
SAP R/3 4.6
SAP R/3 4.5
SAP R/3 4.0
R/3 3.1
13
Basis and Web AS
R/3 Basis
Performance
Additionally:
Reliability
Scalability
Native Internet
Versioning
Support (SOAP,XML)
Monitoring
Open Integration
Workflow
Web Services
Development workbench
Java and J2EE
Transport management
Webflow
Business object repository Security
Security Enhancements
Platform Independence
New Upgrade Tools
14
SAP R/3 Integration Model
15
SAP R/3
16
SAP R/3
17
SAP R/3
Relevant Business Objects
Finance documents
Vendor Invoice
Customer Invoice
Vendor Payment
Accounting document
Purchase documents
Purchase Requisitions / Sales requisitions
Request for Quotation / RFQ for customers
Contracts for Vendor / Contract for Customer
Purchase Order / Sales Order
Other Logistics documents
Good receipt
Good issue
Service Entry Sheet
Logistic Invoice receipt
Maintenance documents
Work order
Notification
18
SAP R/3 Client (SAP GUI)
Navigation inside R/3.
Basics tips
Favorites
19
Planning the R/3 System
Landscape
20
R/3 System Client / Server
Configurations
The fundamental services in a business application system are
presentation services, application services, and database services.
21
R/3 System Client / Server
Configurations
22
The System Kernel
Applications
Communication Interface
Programming Interface
User Interface
Screen ABAP
Interpreter ABAP Interpreter
Dictionary
Runtime Environment
Data entered by the user is sent through the user interface (the SAP GUI) to
the dispatcher, which coordinates further processing.
23
Processing User Request
Presentation
SAP GUI SAP GUI SAP GUI
Communication
Application
Dispatcher
24
R/3 Database Interface
ABAP Local
Database
interpreter Buffers
DB
Data
Select *
From interface
OPEN Native SQL
SQL
Exec SQL.
Select.. Data Database Data
END EXEC
Native SQL
Database Data
25
R/3 Application Services
26
Locks in R/3
The lock mechanisms in todays RDBS are usually not able to
handle business data objects that affect several database tables.
You can specify the lock mode (S:shared or E: exclusive) for lock
object. An E mode can only be set if no other user has set a lock (E
o S).
27
SAP R/3 - Clients
28
Workbench ABAP
Programs ABAP Queries y
Functions Quickviewer
Data dictionary Transactions
Classes and Objects BAPIs
Tables maintenance Enhancements and
views BADIs
Screen Painter Business Objects
Menu Painter RFCs
29
Object Navigator
30
Creacion de un Programa
-Attributos
31
ABAP Syntax
32
Chain of registers
WRITE 'XYZ'.
WRITE NAME.
WRITE COUNTER.
ADD 1 TO COUNTER1.
ADD 1 TO COUNTER2.
ADD 1 TO COUNTER3.
33
Comments
* Cuenta nueva
* Inicializar campo de totales
CLEAR SUM.
34
Database Selection (I)
Descripcin de la tabla SBOOK
SHOW SBOOK Data
Dictionary
SBOOK-CARRID CHAR C 3
REPORT RSAAA02A.
TABLES SBOOK.
SELECT * FROM SBOOK.
WRITE: / SBOOK-CARRID,SBOOK-CONNID,
SBOOK-FLDATE, ... .
ENDSELECT.
35
Database Selection (II)
REPORT RSAAA02B.
TABLES: SBOOK.
SELECT * FROM SBOOK
WHERE CARRID = 'LH '.
Sentencias
ENDSELECT.
IF SY-SUBRC NE 0.
Sentencias
ENDIF.
36
Write command
REPORT RSAAA02C.
WRITE: '******************************'.
SKIP 2.
WRITE: Sentencia 1
**********************************************
Fecha 01.01.1996 Hora 14:46:10
**********************************************
37
Format definitions
REPORT RSAAA02D.
WRITE: 5'******************************'.
SKIP.
WRITE: 5 'Fecha', 20 SY-DATUM,
/5 'Hora',20 SY-UZEIT.
ULINE /5(30).
SKIP 2.
ULINE.
ABAP/4 Programm
Atributos de programa
Attribute
ABAP/4
WRITE: Definiciones de formato
********************************************
Fecha 01.01.1996
Hora 16:18:38
-----------------------------------------------------
---------------------------------------------------------------------
Columna 5 Columna 20
38
Text icons
REPORT RSAAA02G.
Elementos de texto
N. Texto Idioma D
001 Fecha
Iconos de texto 002 Hora
Fecha 01.01.1996
Hora 13:25:07
39
Write options
REPORT RSAAA02E.
.
.
.
WRITE: 5 'Fecha',
20 SY-DATUM.
WRITE: /5 'Hora',
SY-UZEIT UNDER SY-DATUM.
Fecha 01.01.1995
Hora 07:08:17
Columna 5 Columna 20
40
Starting an ABAP report
1 2
Inicio a travs de men Inicio desde el editor
ABAP/4
ABAP/4
Desarrollo ABAP/4
EditorProgramm Attribute
ABAP/4 RSDEMO00
Reporting
Ejecucin
Report RSDEMO00.
.
RSDEMO00 Ejecutar .
.
WRITE
Ejecucin
41
Where-used list
Interno al programa A nivel de sistema
ABAP/4
ABAP/4
SELECT * FROM SBOOK Workbench
WHERE ... . Objetos de Data Dictionary
Tablas
SBOOK
Referencia de utilizacin
Referencia de utilizacin
RSAAA022
SELECT * FROM SBOOK ...
RSAAA022
TABLES: SBOOK . RSAAA02A
42
System fields
Comando de editor
SHOW SY
SHOW SY
43
SAP R/3
Ejercicio I
1. Crear un programa abap tipo ejecutable. La nomenclatura a utilizar
para el programa sera Zcursoxx, donde xx varia dependiendo del
numero de participantes.
2. Una vez en el editor, realizar una busqueda sobre la tabla AUFK sin
restricciones.
3. Mostrar contenido de los campos AUFNR y KTEXT utilizando la
instruccion WRITE.
4. Localizar un numero de orden (campo AUFNR) y delimitar la
busqueda a ese valor.
5. Crear dos elementos de textos uno con el literal Registro
encontrado y otro con Regfistro no encontrado y escribirlos con la
instruccion WRITE segun aplique en cada caso luego de realizar la
busqueda en el paso 4.
Time: 20 Min
44
SAP R/3
Data types
45
Data types
46
Arithmetical expressions
47
Arithmetical expressions
48
Arithmetical expressions
49
Constants
Literal de cifras
715, -431
Secuencia de cifras, nmeros
negativos,
precedidos del signo menos
Literal de texto
'ABC', 'Esto es un texto'
Secuencia de caracteres entre Tipo Constante
comillas simples hasta un mximo de
255 caracteres.
P 579, -713, '2.17'
I 917, -882
F '25.873', '1.213E15', '17E-6', '0.556E7'
N '778', '87931'
C 'AXZ', 'B123', 'AB"CD'
D '19920221'
T '105743'
X '0FFF'
50
Types and Data object (Like)
Tipos de datos
Types T1(20) Types T2(5)
Type C. Type P.
Objetos de datos
DATA D3
Type T1
DATA D1 VALUE '123'. DATA D5
Type T1. Type T2.
VALUE '1.23'.
DATA D2 DATA D6
Type T1. DATA D4 Type T2.
Type T1
VALUE '999'.
51
Data declaration
DATA: COUNTER TYPE I ,
NAME1(25) VALUE 'SAP',
START_DATE TYPE D,
FIRST_LINE TYPE I
VALUE 1,
SUM1(5) TYPE P DECIMALS 2.
52
Type declaration
TYPES: MYTYPE TYPE I,
NAME1(25),
DATE1 LIKE SY-FECHA,
SUM_FIELD TYPE P DECIMALS 2.
53
Declaration using Like
CLEAR <campo>.
Inicializa un campo de modo
adecuado al tipo.
54
Output of types
Tipo Longitud estndar de salida Salida
P 2* Ig alineado a la derecha
N Ig alineado a la izquierda
C Ig alineado a la izquierda
D 8 alineado a la izquierda
T 6 alineado a la izquierda
55
SAP R/3
56
SAP R/3
Ejercicio 2
Time: 10 Min
57
SAP R/3
ABAP Dictionary
58
ABAP Workbench Integration
Entorno de desarrollo
Dictionary
ABAP/4
59
Basic Objects of the
Dictionary
Tabla
Campo de tabla
Elemento
utiliza de datos
Dominio
utiliza
60
Domain of two levels
Tabla SBOOK Tabla SFLIGHT
. . . . . . FORCURAM . . . . . . . . . . . . . . . . . PRICE . . . . . .
Elemento de Elemento de
datos datos
S_F_CUR_PR S_PRICE
Dominio
S_PRICE
61
Transparent table
Dictionary ABAP/4
Definicin lgica de tablas
62
Creation of a transparent
table
63
Structure
Dictionary ABAP/4
Definicin lgica
64
Views
Vista Vista
Tablas
Dictionary ABAP/4
Base
de datos
65
Search help
N de rea de
especializacin Nombre N de rea de N de N de Denominacin
... especializacin curso perfil del curso
... Test
4711 Matemticas 4711 444 4709 Anlisis I
Tablas ... ...
...
Anlisis II Matemticas 4711
Ayuda de bsqueda ...
Ayuda ...
ONLINE _Matemticas Anlisis I 4711
rea de espe- xMatemticas Anlisis II 4711 Area de espe-
cializacin n: ? ... cializacin n 4711
F4
66
Partial fields
REPORT RSAAA04C.
DATA: ACCOUNT(10) TYPE C,
START LIKE SY-FECHA.
ACCOUNT = '1234567890'.
START = '19950715'.
WRITE: ACCOUNT+8(2), '**',
START(4).
*Comienzo de mes
START+6(2) = '01'.
ACCOUNT+6 = '9999'.
WRITE: / ACCOUNT, '****',
START. 90 ** 1995
1234569999 **** 01.07.1995
67
Field symbols
REPORT RSAAA04F.
DATA COUNTER TYPE I. COUNTER
FIELD-SYMBOLS <F>. 15 100
COUNTER = 15. <F>
ASSIGN COUNTER TO <F>. 100 150
WRITE : / COUNTER, <F>.
<F> = 17. Direccin
WRITE : / COUNTER, <F>.
15 15
17 17
68
Assigning dynamically a partial string
of characters
REPORT RSAAA04G.
DATA: TEXT_LINE(30)
VALUE 'ABCDEFGH ...',
START TYPE I,
STRING_LENGTH TYPE I.
FIELD-SYMBOLS: <FSTRING>.
START = 2.
STRING_LENGTH = 5.
ASSIGN
TEXT_LINE+START(STRING_LENGTH) * CDEFG *
TO <FSTRING>.
WRITE: / '*' <FSRTING>, '*'.
<FSTRING> = '1234567890'.
.
.
. <FSTRING>
A B C D E F G H I ...
69
Assigning dynamically a field
REPORT RSAAA04H.
PARAMETERS: SY_FIELD(8) DEFAULT 'SY-FECHA'
FIELD-SYMBOLS: <FIELD>.
ASSIGN (SY_FIELD) TO <FIELD>.
*ASSIGN TABLE FIELD(SY_FIELD) TO <FIELD>.
IF SY-SUBRC EQ 0.
WRITE:/ TEXT-001, SY_FIELD, 50 <FIELD>.
ENDIF.
*D: TEXT-001: Contenido actual del campo de sistema.
Tabla SY
SY-FIELD INDEX ... Fecha
... 19960218
S Y - F E C H A
<FIELD>
70
SAP R/3
71
String operations
CONCATENATE F1 F2 F3 INTO G. F1 F2 F3 G
REPORT RSAAA04I.
DATA: ONE(1) VALUE 'I', TWO(4) VALUE 'LIKE',
THREE(6) VALUE 'ABAP/4', TARGET(20).
WRITE: / TARGET.
.
.
CLEAR: ONE, TWO, THREE.
.
SPLIT TARGET AT SPACE INTO ONE TWO THREE.
72
Date calculations
REPORT RSAAA04D.
DATA: DIFF TYPE P.
DATE_1 LIKE SY-FECHA,
DATE_2 LIKE SY-FECHA.
DATE_1 = SY-FECHA.
DATE_2 = SY-FECHA.
*Comienzo del mes
DATE_2+6(2) = '01'.
*ltimo da del mes anterior
DATE_2 = DATE_2 - 1.
*Das de diferencia
DIFF = DATE_1 - DATE_2.
73
Ejercicio 3
Time: 35 Min
74
Parameters
PARAMETERS <campo>.
REPORT RSAAA04E.
PARAMETERS:PAR1 TYPE P,
PAR2 DEFAULT 'X'.
.
.
.
Selection
screen
75
Control sentences
Distinction of cases
IF ENDIF
CASE ENDCASE
Loops
DO ENDDO
WHILE ENDWHILE
CHECK
EXIT
76
Relation operators
Representation Signification
Signification
EQ = Igual
NE <> >< Desigual
GT > Mayor
GE >= => Mayor o igual
LT < Menor
LE <= =< Menor o igual
DATA: START TYPE D,
SUM1 TYPE F,
BETWEEN f1 and f2 Intervalo
SUM2 TYPE P.
.
. IS INITIAL Valor inicial
.
IF START IS INITIAL ... .
IF SUM1 GT SUM2 ... .
IF SUM1 BETWEEN 0 AND 100 ... .
77
Sentence IF
IF <expresin lgica>.
Sentencias
ENDIF.
IF <expresin lgica>.
Sentencias
ELSE.
Sentencias
ENDIF.
IF <expresin lgica>.
Sentencias
Sentencias
ELSE.
Sentencias
ENDIF.
78
Sentence CASE
CASE <campo>.
WHEN <valor1>.
Sentences
WHEN <valor2>.
Sentences
WHEN <valor3>.
Sentences
WHEN OTHERS.
Sentences
ENDCASE.
79
Loop DO
DO <n> TIMES.
Sentences
ENDDO.
80
Loop WHILE
WHILE <logical expression >.
Sentence
ENDWHILE.
81
CHECK sentence
CHECK <logical expression >.
WHILE COUNTER GT 0.
Sentences
ENDWHILE.
Sentences
CHECK <condicin>.
Sentences
82
EXIT sentence
EXIT.
DO.
Sentences
IF COUNTER GE 100.
EXIT.
ENDIF.
Sentences
ENDDO.
Sentences
IF ... .
EXIT.
ENDIF.
Sentences
83
SAP R/3
Ejercicio 4
1. Utilizando la instruccion IF verificar si existen registros en la
tabla AUFK, en caso contrario emitir un mensaje de error que
diga No se encontraron registros en la tabla.
2. Utilizar la variable entera creada anteriormente y moverle el
campo AUFNR de la tabla AUFK, tomar la primera posicion de la
variable y utilizando la instruccion CASE, colocar lo siguiente:
- Si es 1 -- Orden Vigente
- Si es 2 - Orden Temporal
- Clausula WHEN OTHERS - Orden desconocida
3. Crear un parametro de entrada que lleve por nombre ORDEN,
ejecutar el programa para visualizar resultados.
Time: 15 Min
84
SAP R/3
Selection Screens
85
Selection screen
Aeropuerto
SAN FRANCISCO
de origen
86
Select options
SELECT-OPTIONS <nombre de la seleccin> FOR <campo>
REPORT RSDEMO00.
TABLES SPFLI.
SELECT-OPTIONS SCARR FOR SPFLI-CARRID
DEFAULT 'DL' TO 'LH'.
SCARR
Tabla SIGN OPTION LOW HIGH
interna I BT DL LH
...
SCARR DL hasta LH
87
Table structure
SIGN
SIGN OPTION
OPTION LOW
LOW HIGH
HIGH
II EQ
EQ ____
____
EE NE
NE ____
____
LT
LT ____
____
GT
GT ____
____
LE
LE ____
____
GE
GE ____
____
BT
BT ____
____ ____
____
NB
NB ____
____ ____
____
CP
CP ____
____
NP
NP ____
____
88
Relational operators
Opciones
Opciones de
de seleccin
seleccin
Valor
Valor individual
individual
Mayor
Mayor oo igual
igual
Menor
Menor oo igual
igual
Difiere
Difiere
Menor
Menor que
que
Mayor
Mayor que
que .. .. ..
89
Set of values
...
90
Selection text
REPORT RSDEMO00.
TABLES SPFLI.
SELECT-OPTIONS:
Elementos
Elementos
SCARR FOR SPFLI-CARRID.
de
de texto
texto
.
.
.
Nombre del programa RSDEMO00
Idioma D
Nombre Texto
SCARR Compaa area
91
Field declaration with
PARAMETERS
PARAMETERS <campo>.
REPORT RSDEMO00.
TABLES SPFLI.
SELECT-OPTIONS SCARR FOR SPFLI-CARRID.
PARAMETERS:
CITY_FR LIKE SPFLI-CITYFROM.
...
92
SAP R/3
Internal Tables
93
Types of Definitions for Internal
Tables
94
The Data type of an Internal
Table
95
Table Attribute: Line Type
96
Table Attribute: Table Kind
and Key
97
Standard Table with Local
Type
98
Sorted and Hashed Table
99
The Standard Table Type
100
Internal Tables with an Unstructured
Line Type
101
Using Internal Tables
102
Types of Operation
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Ejercicio 5
Time: 25 min
123
SAP R/3
Open SQL
124
Summary
Programa
ABAP
Base de datos
Dictionary
SELECT ...
ABAP/4
Lista
125
Sets
} Varias lneas
}
Columna
determinada
126
Individual access
SELECT SINGLE * FROM...
REPORT RSAAA08A.
TABLES: SPFLI.
SELECT SINGLE * FROM SPFLI
WHERE CARRID EQ 'LH '
AND CONNID EQ '0400'.
IF SY-SUBRC = 0.
WRITE: / SPFLI-CARRID, SPFLI-CONNID,
SPFLI-CITYFROM, SPFLI-CITYTO.
ELSE.
WRITE: / TEXT-001.
ENDIF.
127
Processing loops without
limits
SELECT * FROM...
ENDSELECT.
REPORT RSAAA08B.
TABLES: SPFLI.
SELECT * FROM SPFLI.
WRITE: / SPFLI-CARRID, SPFLI-CONNID,
SPFLI-CITYFROM, SPFLI-CITYTO.
ENDSELECT.
IF SY-SUBRC NE 0.
WRITE: / TEXT-001.
ENDIF.
128
Processing loops with limits
SELECT * FROM...
WHERE.....
ENDSELECT.
REPORT RSAAA08C.
TABLES: SPFLI.
SELECT * FROM SPFLI
WHERE CITYFROM EQ 'FRANKFURT'.
WRITE: / SPFLI-CARRID, SPFLI-CONNID,
SPFLI-CITYFROM, SPFLI-CITYTO.
ENDSELECT.
IF SY-SUBRC NE 0.
WRITE: / TEXT-001. < Operadores relacionales>:
ENDIF. EQ =
GE >= =>
LE <= =<
NE <> ><
GT >
LT <
129
Selecting specific columns
REPORT RSAAA08D.
TABLES: SPFLI.
DATA: ZIEL LIKE SPFLI-CITYTO,
START LIKE SPFLI-CITYFROM.
SELECT CITYTO CITYFROM INTO (ZIEL, START)
FROM SPFLI WHERE CARRID = 'LH'.
WRITE: / START, ZIEL.
ENDSELECT.
IF SY-SUBRC NE 0.
WRITE: / TEXT-001.
ENDIF.
130
Selecting specific columns (II)
aggregates functions
SELECT MAX( DISTANCE )
MIN( DISTANCE )
COUNT(*) FROM <t abla> INTO (..., ..., ...)
WHERE.....
REPORT RSAAA08E.
TABLES: SPFLI.
DATA: MAXFIELD LIKE SFLIGHT-DISTANCE,
MINFIELD LIKE SFLIGHT-DISTANCE, COUNTER TYPE I.
SELECT MAX( DISTANCE )
MIN( DISTANCE )
COUNT(*)
FROM SPFLI INTO
(MAXFIELD, MINFIELD, COUNTER).
WRITE: / TEXT-001, MAXFIELD,
/ TEXT-002, MINFIELD,
/ TEXT-003, COUNTER.
131
Selecting data component to
component
SELECT ... INTO CORRESPONDING FIELDS OF <wa>.
SELECT ... INTO CORRESPONDING FIELDS OF TABLE <itab>.
SELECT ... APPENDING CORRESPONDING FIELDS OF TABLE <itab>.
REPORT RSAAA08N.
TABLES: SPFLI.
132
Select with intervals
REPORT RSAAA08H.
TABLES: SFLIGHT.
133
Select with list
REPORT RSAAA08J.
TABLES: SFLIGHT.
134
Select with operator IN
SELECT * FROM <tabla> WHERE <campo de tabla> IN <itab>.
REPORT RSAAA08K.
TABLES: SFLIGHT.
135
Dynamic table name
SELECT * FROM (<tabla>) INTO <rea de trabajo>.
REPORT RSAAA08F.
DATA: BEGIN OF WA,
LINE(100),
END OF WA.
PARAMETERS: TABNAME(10) DEFAULT 'SPFLI'.
136
Dynamic Where
SELECT * FROM (<tabla>) WHERE (<itab>).
REPORT RSAAA08G.
* Declaracion de Tabla Interna Line
PARAMETERS: PCARRID LIKE SFLIGHT-CARRID,
PCONNID LIKE SFLIGHT-CONNID.
CONCATENATE 'CARRID = ''' PCARRID '''' INTO LINE.
APPEND LINE. AND = 'AND'.
CONCATENATE AND ' CONNID = ''' PCONNID '''' INTO LINE.
APPEND LINE.
SELECT * FROM SPFLI WHERE (LINE).
WRITE: / SPFLI-CARRID, SPFLI-CONNID,....
ENDSELECT.
137
Load DB tables into internal
tables
SELECT * FROM (<tabla>) INTO TABLE <itab>.
REPORT RSAAA08L.
TABLES: SFLIGHT.
* Declaracion de Tabla Interna Itab
138
Select . for all entries
SELECT * FROM (<tabla>) FOR ALL ENTRIES IN <itab>
WHERE <condicin>.
REPORT RSAAA08M.
TABLES: SPFLI.
139
Select .. order by
SELECT * FROM (<tabla>) ORDER BY <campo1> <campo2>..
PRIMARY KEY.
REPORT RSAAA08O.
TABLES: SPFLI.
140
Select .. group by
SELECT <a1> <a2>... INTO <f1>, <f2>,...FROM <tabla> GROUP BY...
REPORT RSAAA08Q.
TABLES: SFLIGHT.
DATA: CARRID LIKE SFLIGHT-CARRID,
MINIMUM TYPE P DECIMALS 2,
MAXIMUM TYPE P DECIMALS 2.
141
Select .. bypassing buffer
SELECT * FROM <tabla> BYPASSING BUFFER.
REPORT RSAAA08P.
TABLES: SFLIGHT.
142
Others access to DB tables
INSERT
UPDATE
DELETE
MODIFY
143
Update database table (I)
INSERT <dbtab>.
144
Update database table (II)
UPDATE <dbtab> .
DELETE <dbtab>.
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
Function module
162
RFC Enabled Function
Modules
Function Builder : Administration
Processing type
Normal
.
.
.
163
Creating a function module
Biblioteca de funciones
Mdulo Z_FREESEAT
de funciones
Creacin
164
ABAP Function Modules
Function Builder
Interface parameters
Function group : ZIBU EXPORTING ...
Import
IMPORTING ...
Export Z_FB_03
CHANGING ...
Changing
Z_FB_04
Tables TABLES ...
Program
Documentation
Administration
165
RFC with ABAP Function
Modules
Function Module Interface Function Module Exceptions
...
EXCEPTIONS
166
RFC with External Server
Programs
RFC library
( platform-specific )
TABLES
f3 = a3
Error = ...
167
Calling and documentation
Documentacin acerca de CALCULATE_REVENUE_LOSS
Nombre del parmetroTexto breve Tipo del parmetro
REPORT RSAAA10G.
TABLES: SFLIGHT.
DATA: p_loss like sflight-paymentsum, p_revenue like ...
CALL FUNCTION 'CALCULATE_REVENUE_LOSS'
EXPORTING
PAYMENTSUM = SFLIGHT-PAYMENTSUM
SEATSOCC = SFLIGHT-SEATSOCC
PRICE = SFLIGHT-PRICE
IMPORTING
LOSS = P_LOSS
REVENUE = P_REVENUE.
168
Transfering and internal
table
Mdulo de funciones ABAP/4 FILL_SEATTAB
REPORT RSAAA10H.
TABLES: SFLIGHT.
DATA: ITAB like BCAXX OCCURS 10 WITH HEADER LINE.
CALL FUNCTION 'FILL_SEATTAB'
EXPORTING
YEAR = YEAR
TABLES
SEATTAB ==
SEATTAB ITAB.
ITAB
169
Exceptions
Mdulo de funciones ABAP/4
FILL_SEATTAB
Excepciones
REPORT RSAAA10H.
NO_ENTRY CALL FUNCTION 'FILL_SEATTAB'
EXPORTING
YEAR = YEAR
TABLES
SEATTAB = ITAB
EXCEPTIONS
NO_ENTRY = 01
OTHERS = 02.
CASE SY-SUBRC.
WHEN 1.
WRITE 'Sin entradas'.
WHEN 2.
WRITE 'Otro error'.
ENDCASE.
170
Sub-routines
Programa de control
*System-defined Include-files
INCLUDE L<gr>TOP. " Global Data
* User-defined Include-files
INCLUDE L<gr>F01. " Subprograms
171
Program organization
L<gr>TOP
SAPL <gr>
FUNCTION-POOL<gr>
* System-defined Include-files
MESSAGE-ID ZZ.
INCLUDE L<gr>TOP. DATA: "Global Data
INCLUDE L<gr>UXX
* User-defined Include-files
L<gr>UXX
INCLUDE L<gr>U01.
INCLUDE L<gr>U02.
.
.
L<gr>U01 .
FUNCTION FA.
L<gr>U02
FUNCTION FB.
172
Function Module - Gestion
173
Function Module - Patron
174
Ejercicio 6
Time: 25 Min
175
Contents (III)
176
SAP R/3
Reporting
177
Reporting
REPORT
QUERY
178
Reading data
Dictionary ABAP/4
1 2
REPORT ... . Base de datos lgica
TABLES: ... . TABLES: ... .
SELECT... . SELECT... .
SELECT ... . SELECT ... .
Procesamiento ... .
ENDSELECT.
ENDSELECT. ENDSELECT.
ENDSELECT.
REPORT REPORT
TABLES: TABLES:
GET GET
Procesamiento Procesamiento
GET
Procesamiento
179
Report and data program
SPFLI
REPORT SAPDBF1S
. DEFINING DATABASE F1S. Report RSBBB01B.
. ...
.
SELECT * FROM SPFLI... .
. .
. .
.
ENDSELECT. GET SPFLI.
... Write: SPFLI-CARRID,
...
180
Events
Instantes 1 en la base
de datos lgica
INITIALIZATION.
AT SELECTION-SCREEN OUTPUT.
AT SELECTION-SCREEN.
START-OF-SELECTION.
GET .... .
END-OF-SELECTION.
Instantes en la creacin
de lista
TOP-OF-PAGE.
END-OF-PAGE.
181
Events
AT LINE-SELECTION.
AT PFxx.
AT USER-COMMAND.
182
Interactive reporting
Reporting
interactivo
Llamada a Llamada a
una transaccin un report
183
Selecting lines
REPORT RSAAA11A. Lista bsica
TABLES: SPFLI. CAR ID de a Salida
SELECT-OPTIONS: SCARRID ... . LH 0400 Frankfurt New York 10:10:00
LH 0402 Frankfurt New York 13:30:00
START-OF-SELECTION. ...
SELECT * FROM SPFLI LH 3577 Rom Frankfurt 07:05:00
WHERE ... .
WRITE: /SPFLI-CARRID,
SPFLI-CONNID ... .
HIDE: SPFLI-CARRID, SPFLI-CONNID. Lista ramificada
ENDSELECT.
184
Hide area
HIDE <campo>.
rea Hide
CAR ID de a Salida
LH 0400 Frankfurt New York 10:10:00 Lnea SPFLI-CARRID SPFLI-CONNID
LH 0402 Frankfurt New York 13:30:00
... 1 LH 0400
LH 3577 Rom Frankfurt 07:05:00
2 LH 0402
...
11 LH 3577
Seleccionar
REPORT RSAAA11A
...
START-OF-SELECTION.
SELECT * FROM SPFLI WHERE ... .
WRITE: / SPFLI-CARRID, SPFLI-CONNID, ... .
HIDE: SPFLI-CARRID, SPFLI-CONNID.
ENDSELECT.
185
Selecting lines (II)
rea Hide
AT LINE-SELECTION.
WRITE: TEXT-001, SPFLI-CARRID,
SPFLI-CONNID, TEXT-002.
186
Selecting valid lines
REPORT RSAAA11A.
START-OF-SELECTION.
SELECT * FROM SPFLI WHERE ... .
WRITE: SPFLI-CARRID, SPFLI-CONNID, ... .
HIDE: SPFLI-CARRID, SPFLI-CONNID.
ENDSELECT.
END-OF-SELECTION.
CLEAR SPFLI-CARRID.
AT LINE-SELECTION.
CHECK NOT SPFLI-CARRID IS INITIAL.
...
CLEAR SPFLI-CARRID.
187
User messages
REPORT RSDEMO00 MESSAGE-ID AT.
.
.
.
MESSAGE E027.
Tabla T100
S ID Nr. Texto del mensaje
D AT 001 Registro &1 &2 no existente
. .. ... ...
D AT 011 Error al actualizar
. .. ... ...
D AT 027 Sin autorizacin
188
Message
.
.
.
Annn
Xnnn
MESSAGE Ennn WITH <campo1> <campo2> <campo3> <campo4>.
Wnnn
Innn
Snnn
189
Example
REPORT RSAAA11B MESSAGE-ID AT.
TABLES SPFLI.
PARAMETERS: P_CARRID LIKE SPFLI-CARRID.
AT SELECTION-SCREEN.
AUTHORITY-CHECK OBJEKT 'S_CARRID'
ID 'CARRID' FIELD P_CARRID
ID 'ACTVT' FIELD '03'.
IF SY-SUBRC NE 0.
MESSAGE E045 WITH P_CARRID.
ENDIF.
START-OF-SELECTION.
SELECT * FROM SPFLI WHERE CARRID = P_CARRID.
...
ENDSELECT.
190
Normal report vs. Query
Base de datos lgica, Lista
p. ej. F1S Report
(ABAP/4)
Reporting
Query
Generador
Generador de
de
reports
reports
rea
rea funcional
funcional
Definicin
Definicin de
de lista
lista
(query)
(query)
Creacin
Creacin de
de una
una lista
lista mediante
mediante
Report: sentencias de un
Report: sentencias de un lenguaje
lenguaje de
de programacin
programacin (ABAP/4)
(ABAP/4)
Query: descripcin del resultado deseado
Query: descripcin del resultado deseado
191
ABAP Query
Areas funcionales
Query
Definicin de listas
Lista estndar
Estadstica
Lista ranking
Inicio de query
192
Ejercicio 7
Time: 15 Min
193
SAP R/3
Debugging
194
How enter to debugging
mode Desarrollo
ABAP
1 3
Debugging
Ejecutar
2
Editor ABAP Pantalla de seleccin
Programa... Utilidades... /h
Ejecutar
Parmetros programa
195
Debugging mode
REPORT RSAAA04D.
DATA: DIFF TYPE P,
.
.
.
COMPUTE DATE_1 = SY-DATE.
.
.
.
Variables
DATE_1 00000000
SY-DATE 19950223
X R
196
Important debugging options
197
Breakpoint
1
Editor ABAP Men Utilidades --> Breakpoints
2
Modo debugging Seleccin de lnea
198
Watchpoint
199
SAP R/3
Authorization check
200
Authorization check -
definition
Autorizacin Visualizar
para el objeto S_CARRID
CARRID: *
ACTVT: Visualizar
Objeto: S_CARRID
CARRID (Compaa area)
ACTVT (Actividad)
Autorizacin Modificar
para el objeto S_CARRID
CARRID: LH
ACTVT: Modificar
201
Authority check in the
program
REPORT RSAAA09A.
. Objeto S_CARRID
. verificar
. ACTVT
AUTHORITY-CHECK
OBJECT 'S_CARRID'
ID 'CARRID' FIELD 'LH' notificar el
resultado 03 x x x x x
ID 'ACTVT' FIELD '02' .
IF SY-SUBRC NE 0. 02 xx
...
ENDIF.
AA DA DL LH UA CARRID
202
Syntax
IF SY-SUBRC NE 0.
...
ENDIF.
203
Summary
Seleccin
AUTHORITY Registros
CHECK maestros
de usuario
No
SY-SUBRC
=0?
S
Mensaje
SELECT informativo
204
SAP R/3
Dialog Programming
205
Main components of a dialog
program
Entorno de desarrollo
206
Screen painter
Screen
Painter
Atributos de dynpro Disposicin de Atributos de campo
la pantalla Lgica de proceso
N de dynpro100 PROCESS BEFORE OUTPUT.
NUMBER
Descripcin breve Nmero: MODULE INIT.
CHAR
Test
10 lugares
Tipo de dynpro normal
Entrada x PROCESS AFTER INPUT.
Siguiente dynpro 200 ... MODULE READ.
...
ABAP/4
Datos globales Mdulos PBO Mdulos PAI
DATA: NUMBER(10) MODULE INIT OUTPUT. MODULE READ INPUT.
TYPE C. CLEAR NUMBER. SELECT ...
. ENDMODULE. .
.
. . .
ENDMODULE.
. . .
. .
.
207
Communication: Dynpro
Screen PROCESS
PROCESS BEFORE
BEFORE OUTPUT. PROGRAM
PROGRAM SAPMTALA
SAPMTALA MESSAGE-ID
MESSAGE-ID AT.
OUTPUT. AT. ABAP/4
Painter 1 TABLES SPFLI.
TABLES SPFLI.
MODULE INITIALIZE.
MODULE INITIALIZE.
MODULE
MODULE INITIALIZE
INITIALIZE OUTPUT.
OUTPUT.
2 CLEAR
CLEAR SPFLI.
SPFLI.
ENDMODULE.
ENDMODULE.
MODULE
MODULE READ_SPFLI
READ_SPFLI INPUT.
INPUT.
PROCESS
PROCESS AFTER
AFTER INPUT.
INPUT. 1 SELECT
SELECT SINGLE
SINGLE ** FROM
FROM SPFLI
SPFLI
MODULE
MODULE READ_SPFLI.
READ_SPFLI. WHERE
WHERE ...
...
..
MODULE ... 2 ..
MODULE ... ..
.. ENDMODULE.
.. ENDMODULE.
LOS
LOS MISMOS
MISMOS NOMBRES
NOMBRES
208
Creating a dialog program
Compaa area LH
...
Conexin area prevista
Conexin de FRANKFURT
Conexin a NEW YORK
Tiempo de vuelo 08:24:00
...
209
Program attribute
Ttulo
Test
Tipo M
Aplicaciones S
Grabar
210
Taking field from ABAP
dictionary
Campos de Dictionary/
Full screen
Programa
Campos de Dictionary/Programa
Nombre de tabla/ Traer del Dictionary
Nombre de campo
Traer del programa
Palabra clave
- breve
- mediana
- larga
- ttulo
Tomar
211
Screen painter
Atributo
Atributo de
de campo.
campo. Campos
Campos de
de Dictionary/Programa
Dictionary/Programa Lista
Lista de
de campos
campos
Text
Text
Entry
Entry
Check
Check
Compaa area
Radio
Radio
Nmero de conexin
Frame
Frame
212
Fields attributes
Atributos de campo
Tipo grfico
Nombre de campo
.
.
.
Atributos del Dictionary
Atributos del programa
Atributos de visualizacin
213
Process control
Screen
Painter
PROCESS BEFORE OUTPUT.
MODULE INITIALIZE.
214
Creating a second dynpro
Dynpro 100 Copiar Dynpro 200
Dynpro 200
215
Process the module pool
ABAP/4
MODULE INITIALIZE OUTPUT.
CLEAR SPFLI.
ENDMODULE.
ABAP/4
MODULE READ_SPFLI INPUT.
SELECT SINGLE * FROM SPFLI
WHERE CARRID = SPFLI-CARRID
AND CONNID = SPFLI-CONNID.
.
.
.
ENDMODULE.
216
Sequence
Screen Secuencia de acciones
PROCESS BEFORE OUTPUT. Painter
MODULE A. Ejecutar el mdulo A
ENTER
Ejecutar el mdulo B
217
Validating format
Screen
Painter
Lista de campos
FECHA DATS
.
.
.
IMPORTE DEC
218
Validating inputs
Screen
PROCESS AFTER INPUT. Painter MODULE <modul> INPUT. ABAP/4
FIELD <campo de dynpro> .
.
MODULE <modul>. .
MESSAGE E ... .
ENDMODULE.
1 1
E... Mensaje
219
Field sentence and data
transport S
e Screen
ENTER
Screen Screen
Painter Painter
PROCESS
PROCESS AFTER
AFTER INPUT.
INPUT. PROCESS
PROCESS BEFORE
BEFORE OUTPUT
OUTPUT
MODULE OK_CODE.
MODULE OK_CODE. ..
..
..
ABAP/4
MODULE OK_CODE INPUT.
. PROCESS AFTER
.
. PROCESS AFTER INPUT.
INPUT.
..
SET SCREEN 200. ..
..
LEAVE SCREEN.
221
Consulting function code ok
code Screen
Painter
PROCESS
. AFTER INPUT.
.
.
Screen MODULE USER_COMMAND.
Painter
Ver
ABAP/4
DATA: OKCODE(4),
SAVE_OKCODE(4).
222
Ejercicio 8
Time: 25 Min
223
BAPI - Definition
Business Application Programming Interface
BAPI
224
BAPIs - Uses
R/3 satellite systems /
distributed scenarios ( ALE)
Business
Workflow
VisualBasic /JAVA...
Internet /
Intranet
Business Business
B
Component Component
Forming R/3
Inhouse development
components Business
Component R
by customers/partners
225
BAPI - Properties
Object-oriented
Stable interface
BAPIs can be used both within the R/3 System and from outside
Independent
226
Using ABAP to Access BAPIs
ABAP program
R/3
PROGRAM ...
Business Object
Repository
TABLES ...
DATA ... Business object A:
Method1 = M1
CALL FUNCTION
Method2 = M2
'BAPI_A_M1'
DESTINATION Function modules:
BAPI_A_M1
EXPORTING RFC
IMPORTING BAPI_A_M2
TABLES .
227
RFC Between R/3 and External
Programs
R/3 System External system
ABAP
...
External
CALL FUNCTION ...
RFC server
DESTINATION ...
program
...
RFC
Function module
External
FUNCTION ...
RFC client
ENDFUNCTION. program
228
Ejercicio 9
Time: 25 Min
229
Data Conversions
Conversions ABAP programs
Upload data, Download
Processing
Batch Input
Direct input
BAPIs
Data Conversions Workbench
Legacy System Migration Workbench
Recordings
SM35
230
Ejemplo Grabacion
231
Ejemplo Grabacion
232
Ejemplo Grabacion
233
Review and Test
Review
Test
Questions
Practical
234
Bibliografy
www.mysap.com
www.solocursos.net/sap-slckey14276.htm
www.saphelp.com
Herreros L, Jose Luis Programacion en Abap4
para Sap R/3
http://espanol.geocities.com/emoly188/que_es_sap_
r3.htm
235