Curso Introductorio ABAP

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 235

ABAP Workbench

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

After completing this course you will be able


to:
Describe the SAP Application server system
architecture
Program applications based on Advanced
Business Application Programming
Search for and use Functions, BAPIs, Classes
and dictionary structure of R/3 system.

4
Goal

Make activities of technical consultancy SAP


R/3 in clients and commercial partners.

5
Schedule

Lunes Martes Miercoles Jueves Viernes


08/03 09/03

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

Architecture Integrated system... m


...and open integration platform

SAP SAP R/3


Offering mySAP.com and mySAP.com Solutions

11
mySAP.com Technology
Enterprise Portals
Portal
mySAP Enterprise Portals
Infra-
structure

SRM HR SCM CRM PLM FIN BI


mySAP mySAP mySAP mySAP mySAP mySAP mySAP 3rd Legacy
SRM HR SCM CRM PLM Finan- BI Party ...
SAP Web
cials ...
Application
Server

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

New developments in SAP R/3 Enterprise are encapsulated in


Extensions and can be optionally and flexibly deployed.
SAP R/3 Enterprise Extensions have a separate release cycle
to the SAP R/3 Enterprise core.

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

Enterprise organizational structure


Client
Company Code
Purchase Organization
Sales Organization
Plant
Purchase Group
Sales Group

16
SAP R/3

Relevant Master Data


Vendors
Customers
Accounts
Cost Center
Project Definition
WBS Elements
Personal

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.

One-tier configuration: one server classic mainframe processing.

Two-tier configuration: Database and Application on the same


machine, presentation on a windows PC, for example.

Three-tier configuration: separate servers are used for each tier.

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

Operating System and Hardware Platform

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

Work Work Work


process process process Buffer

Database Database processes DB

24
R/3 Database Interface

APPLICATION SERVER DATABASE SERVER

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).

The name of a user defined object must begin with EY or EZ.

If a lock object is activated, the system generates an ENQUEUE


and a DEQUEUE function module.

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.

WRITE: 'XYZ', NAME,


COUNTER.

ADD 1 TO COUNTER1.
ADD 1 TO COUNTER2.
ADD 1 TO COUNTER3.

ADD 1 TO: COUNTER1,


COUNTER2,
COUNTER3.

33
Comments

DATA: SUM TYPE P, " Campo de totales


COUNTER TYPE P.

* 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

Tabla SBOOK-CONNID NUMC N 4

SBOOK SBOOK-FLDATE DATS D 8


SBOOK-BOOKID NUMC N 8

rea de trabajo de tabla SBOOK Nombre Tipo Longitud

CARRID CONNID FLDATE BOOKID

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: 'Fecha', SY-DATUM.


WRITE: 'Hora', SY-UZEIT.
SKIP 2.
WRITE: '******************************'.

Programa Atributo ABAP/4

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.

WRITE: TEXT-001, 10 SY-DATUM,


/ TEXT-002, 10 SY-UZEIT.

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.

ABAP/4 Programm Attribute


WRITE: Opciones de edicin (UNDER) 1

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

Nombre Tipo Longitud Significado


SY-DATE DATE 8 Fecha del da
SY-UZEIT TIME 6 Hora
SY-USER CHAR 12 Nombre del usuario
SY-SUBRC HEX 2 Cdigo de retorno
SY-REPID CHAR 8 Nombre del programa
SY-LANGU CHAR 1 Idioma de trabajo
.
.
.

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.

Reglas para la asignacin de nombres de campo


Un nombre consta un mximo de
30 caracteres (letras, cifras, caracteres especiales).
Los siguientes caracteres especiales no estn permitidos:
( ) + . , :
SPACE es un campo predefinido

No se puede emplear en una sentencia ABAP/4 el nombre


de un parmetro simultneamente como nombre de campo.

52
Type declaration
TYPES: MYTYPE TYPE I,
NAME1(25),
DATE1 LIKE SY-FECHA,
SUM_FIELD TYPE P DECIMALS 2.

Reglas para la asignacin de nombres de tipos


Un nombre consta de un mximo de 30 caracteres
(letras, cifras, caracteres especiales).
Los siguientes caracteres especiales no estn permitidos:
( ) + . , : - < >
El nombre no puede constar nicamente de cifras.

Recomendacin: utilice siempre como primer carcter


una letra; para los nombres compuestos utilice
lnea de subrayado.

53
Declaration using Like

TYPES: NAMETYPE1 LIKE SCUSTOM-NAME,


NAMETYPE2(25).
DATA: NAME1 TYPE NAMETYPE1,
NAME2 TYPE NAMETYPE2,
NAME3 LIKE NAME1.

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

(*) alineado a la derecha


I
F 22 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

X 2 *Ig alineado a la izquierda

lg = Longitud (en bytes) del campo


(*) segn el nmero representable ms alto

55
SAP R/3

56
SAP R/3

Ejercicio 2

1. Utilizando el programa anterior crear las variables MONTO


empaquetado de 10 posiciones con 2 decimales, NRO tipo Integer,
FECHA tipo date, HORA tipo uzeit.
2. Mover valores a las variables creadas y mostrarlas con la instruccion
WRITE.

Time: 10 Min

57
SAP R/3

ABAP Dictionary

58
ABAP Workbench Integration
Entorno de desarrollo

Herramientas Modelador Screen


ABAP/4 de datos Painter

Dictionary
ABAP/4

Intrprete Control de Programas de Intrprete de


ABAP/4 dilogo interfases dynpro

Entorno de tiempo de ejecucin de la aplicacin

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

Campo 1 Campo 2 Campo 3 Campo 4

Campo1 Campo 2 Campo 3 Campo 4 Base de datos


- definicin fsica de la tabla

62
Creation of a transparent
table

63
Structure

Dictionary ABAP/4
Definicin lgica

Campo 1 Campo 2 Campo 3 Campo 4

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

SPLIT G AT SPACE INTO F1 F2 F3.

REPORT RSAAA04I.
DATA: ONE(1) VALUE 'I', TWO(4) VALUE 'LIKE',
THREE(6) VALUE 'ABAP/4', TARGET(20).

CONCATENATE ONE TWO THREE INTO TARGET SEPARATED BY SPACE .

WRITE: / TARGET.
.
.
CLEAR: ONE, TWO, THREE.
.
SPLIT TARGET AT SPACE INTO ONE TWO THREE.

WRITE: / 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

1. Crear una tabla transparente que tenga como nomenclatura


ZCursoXX donde XX variara dependiendo de la cantidad de
participantes.
2. Tomar como referencia los campos de la tabla AUFK
3. Incluir valores a la tabla.
4. Crear una ayuda de busqueda sobre la tabla AUFK, recordar que el
nombre a colocar no debe exceder de 4 caracteres.
5. Crear una estructura utilizando los elementos de datos de la tabla
AUFK.

Time: 35 Min

74
Parameters
PARAMETERS <campo>.

REPORT RSAAA04E.
PARAMETERS:PAR1 TYPE P,
PAR2 DEFAULT 'X'.
.
.
.

MOVE PAR1 TO ... .

WRITE: PAR1, PAR2.


.
. .
.
. .
PAR1 -
PAR2 X

Selection
screen

75
Control sentences
Distinction of cases

IF ENDIF
CASE ENDCASE

Loops

DO ENDDO
WHILE ENDWHILE

Other sentences of control

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

ELSEIF <expresin lgica>.


Sentencias

ELSEIF <expresin lgica>.

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.

SY-INDEX Contador de loops

80
Loop WHILE
WHILE <logical expression >.
Sentence

ENDWHILE.

SY-INDEX Contador de loops

WHILE COUNTER > 0.


.
.
.
SUBTRACT 1 FROM COUNTER.
ENDWHILE.

81
CHECK sentence
CHECK <logical expression >.

1 CHECK dentro de la estructura de un loop

WHILE COUNTER GT 0.
Sentences

CHECK FLAG NE SPACE.


Sentences

ENDWHILE.

2 CHECK fuera de la estructura de un loop

Sentences

CHECK <condicin>.
Sentences

82
EXIT sentence
EXIT.

1 EXIT dentro de la estructura de un loop.

DO.
Sentences
IF COUNTER GE 100.
EXIT.
ENDIF.
Sentences

ENDDO.

2 EXIT fuera de la estructura de un loop

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

Compaa area DL hasta LH ...

Aeropuerto
SAN FRANCISCO
de origen

DEMO/CHAP 07.A: Pantalla de seleccin 1


CAR Id de a Salida Llegada
DL 1984 SAN FRANCISCO NEW YORK 10:00:00 18:25:00
LH 0455 SAN FRANCISCO FRANKFURT 15:00:00 10:30:00

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
...

Delimitaciones de valores individuales


AA
+
+
Intervalos
+ DL hasta LH
+ hasta SR ABAP/4
SA
SCARR
SIGN OPTION LOW HIGH
I BT DL LH
I BT SA SR
I EQ AA

90
Selection text

Compaa area ...


hasta

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.
...

Compaa area hasta

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

Disenar una Tabla Interna de nombre IT_TABLA.


Uilizando el SELECT que se ha venido trabajando sobre la tabla AUFK
introducir las columnas de esta tabla con la instruccion INTO TABLE en la
tabla interna creada en el punto 1.
Realizar un recorrido de la tabla interna utilizando la instruccion LOOP y
mostrando sus campos con la instruccion WRITE.
Visualizar resultados

Time: 25 min

123
SAP R/3

Open SQL

124
Summary

Programa
ABAP
Base de datos

Dictionary
SELECT ...
ABAP/4

Definicin de datos Datos

Lista

125
Sets

Una sola lnea

} 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

SELECT <a1> <a2>...INTO (<f1>, <f2>, ...) FROM...


WHERE.....
ENDSELECT.

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.

* Declaracion de la tabla Interna Itab

SELECT * FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE ITAB.


.
.
LOOP AT ITAB.
WRITE: /10 ITAB-CITYFROM, ITAB-CITYTO.
ENDLOOP.

132
Select with intervals

SELECT * FROM <tabla> WHERE <campo de tabla> BETWEEN <campo1>


AND <campo2>.

REPORT RSAAA08H.
TABLES: SFLIGHT.

SELECT * FROM SFLIGHT WHERE SEATSMAX


BETWEEN 100 AND 900.
WRITE: / SFLIGHT-CARRID, SFLIGHT-CONNID,
SFLIGHT-SEATSMAX.
ENDSELECT.

133
Select with list

SELECT * FROM <tabla> WHERE <campo de tabla> IN (...., ....).

REPORT RSAAA08J.
TABLES: SFLIGHT.

SELECT * FROM SFLIGHT WHERE PRICE


IN (123, 1000).

WRITE: / SFLIGHT-CARRID, SFLIGHT-CONNID,


SFLIGHT-PRICE.
ENDSELECT.

134
Select with operator IN
SELECT * FROM <tabla> WHERE <campo de tabla> IN <itab>.

REPORT RSAAA08K.
TABLES: SFLIGHT.

* Declaracion de tabla Interna Itab

*RANGES: ITAB FOR SFLIGHT-PRICE.


MOVE: 'I' TO ITAB-SIGN, 'BT' TO ITAB-OPTION,
'500' TO ITAB-LOW, '1000' TO ITAB-HIGH.
APPEND ITAB. CLEAR ITAB.
MOVE: 'I' TO ITAB-SIGN, 'EQ' TO ITAB-OPTION.
'440' TO ITAB-LOW.
APPEND ITAB.
SELECT * FROM SFLIGHT WHERE PRICE IN ITAB.
WRITE: / SFLIGHT-CARRID, SFLIGHT-CONNID,
SFLIGHT-PRICE.
ENDSELECT.

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'.

SELECT * FROM (TABNAME) INTO WA.


WRITE: / WA-LINE.
ENDSELECT.

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>.

SELECT * FROM (<tabla>) APPENDING TABLE <itab> .

REPORT RSAAA08L.
TABLES: SFLIGHT.
* Declaracion de Tabla Interna Itab

SELECT * FROM SFLIGHT INTO TABLE ITAB WHERE


CARRID = 'AA'.
LOOP AT ITAB.
WRITE: / ITAB-CARRID, ITAB-CONNID,....
ENDLOOP.

138
Select . for all entries
SELECT * FROM (<tabla>) FOR ALL ENTRIES IN <itab>
WHERE <condicin>.

REPORT RSAAA08M.
TABLES: SPFLI.

* Declaracion de Tabla Interna Itab

ITAB-CITYFROM = 'FRANKFURT'. ITAB-CITYTO = 'BERLIN'.


APPEND ITAB.
ITAB-CITYFROM = 'NEW YORK'. ITAB-CITYTO = 'SAN FRANCISCO'.
APPEND ITAB.
SELECT * FROM SPFLI FOR ALL ENTRIES IN ITAB WHERE
CITYFROM = ITAB-CITYFROM AND
CITYTO = ITAB-CITYTO.
WRITE: / ....
ENDSELECT.

139
Select .. order by
SELECT * FROM (<tabla>) ORDER BY <campo1> <campo2>..
PRIMARY KEY.

REPORT RSAAA08O.
TABLES: SPFLI.

SELECT * FROM SPFLI ORDER BY CITYFROM.


WRITE: / SPFLI-CARRID, SPFLI-CONNID,
SPFLI-CITYFROM.
ENDSELECT.
IF SY-SUBRC NE 0.
WRITE: / TEXT-001.
ENDSELECT.

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.

SELECT CARRID MIN( PRICE ) MAX( PRICE )


INTO (CARRID, MINIMUM, MAXIMUM) FROM SFLIGHT
GROUP BY CARRID.
WRITE: / CARRID, MINIMUM, MAXIMUM.
ENDSELECT.
IF SY-SUBRC NE 0.
WRITE: / TEXT-001.
ENDIF.

141
Select .. bypassing buffer
SELECT * FROM <tabla> BYPASSING BUFFER.

REPORT RSAAA08P.
TABLES: SFLIGHT.

SELECT * FROM SFLIGHT


BYPASSING BUFFER.
WRITE: / SFLIGHT-CARRID,
SFLIGHT-CONNID,
SFLIGHT-SEATSMAX.
ENDSELECT.
IF SY-SUBRC NE 0.
WRITE: / TEXT-001.
ENDSELECT.

142
Others access to DB tables

INSERT

UPDATE

DELETE

MODIFY

143
Update database table (I)

INSERT INTO <dbtab> VALUES <wa>.

INSERT <dbtab> FROM <wa>.

INSERT <dbtab>.

INSERT <dbtab> FROM TABLE <itab> [ACCEPTING DUPLICATE KEYS].

MODIFY <dbtab> FROM <wa>.

MODIFY <dbtab> FROM TABLE <itab>.

144
Update database table (II)

UPDATE <dbtab> FROM <wa>.

UPDATE <dbtab> .

UPDATE <dbtab> SET <S1>...<Sn> WHERE <condition>.

UPDATE <dbtab> FROM TABLE <itab>.

DELETE <dbtab> FROM <wa>.

DELETE <dbtab>.

DELETE FROM <dbtab> WHERE <condition>.

DELETE <dbtab> FROM TABLE <itab>.

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

Remote Function Call supported

Use in update, start immediately

.
.
.

163
Creating a function module
Biblioteca de funciones

Mdulo Z_FREESEAT
de funciones

Creacin

Grupo de funciones ZDEM


Aplicacin
Texto breve
F4

Grupo de funciones Texto breve Responsable

ZDEM Sentencia LOTZ

164
ABAP Function Modules

Function Builder

Function group : FIBU


Maintenance Use
FB_01

FB_02 FB_02 CALL FUNCTION 'FB_02'

Interface parameters
Function group : ZIBU EXPORTING ...
Import
IMPORTING ...
Export Z_FB_03
CHANGING ...
Changing
Z_FB_04
Tables TABLES ...

Exceptions EXCEPTIONS ...

Program

Documentation

Administration

165
RFC with ABAP Function
Modules
Function Module Interface Function Module Exceptions

Import parameters Reference field Error


f1 Dictionary field

Export parameters Reference field


f2 Dictionary field

...

Tables parameters Reference field


f4 Dictionary structure

CALL FUNCTION 'TEST'

DESTINATION 'DEST' ABAP Function Module


Pass to
EXPORTING
FUNCTION test .
f1 = a1
...
IMPORTING
ENDFUNCTION.
f2 = a2

TABLES Receive from


f4 = a4

EXCEPTIONS

... Function module is executed in the


Error = ... remote destination

166
RFC with External Server
Programs
RFC library
( platform-specific )

CALL FUNCTION ' TEST' Link


DESTINATION ' EXTPRG'
EXPORTING
External server program
f1 = a1 Data passed
IMPORTING
C routine TEST
f2 = a2

TABLES

f3 = a3

EXCEPTIONS Data returned


...

Error = ...

167
Calling and documentation
Documentacin acerca de CALCULATE_REVENUE_LOSS
Nombre del parmetroTexto breve Tipo del parmetro

PAYMENTSUM Ingresos alcanzados I


SEATSOCC Plazas ocupadas I
PRICE Precio por pasajero I
LOSS Prdidas E
REVENUE Ingresos E

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

Parmetro Campo Tipo Valor Opcional Referencia


para export de referencia de referencia por defecto
YEAR

Parmetro Estructura Opcional


para tablas de referencia
SEATTAB BCAXX

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

Programa ABAP/4 L<gr>F01 Llamada

FORM SUB1 USING ... . FUNCTION ...


. .
. .
. .
ENDFORM. PERFORM SUB1 USING ... .
FORM SUB2 USING ... . .
.
. .
. ENDFUNCTION.
.
ENDFORM.
.
.
.

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

Crear una funcion utilizando la transaccion SE37.


Crear una subrutina dentro de la funcion e incluir dentro
de ella una busqueda a la tabla AUFK.
Realizar dentro de la la RFC un llamado a la funcion
STATUS_TEXT_EDIT.
Mostrar el resultado arrojado por la funcion en los
parametros de salida.

Time: 25 Min

175
Contents (III)

User dialogs: List


User dialogs: Selection Screens
User dialogs: Screens
Reuse components
Calling programs and passing data

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

Instantes en el reporting interactivo

AT LINE-SELECTION.
AT PFxx.
AT USER-COMMAND.

TOP-OF-PAGE DURING LINE-SELECTION.

182
Interactive reporting

Listas ramificadas Windows

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.

AT LINE-SELECTION. Ha elegido vuelo LH 0402


SKIP TO LINE 12.
WRITE: TEXT-001, SPFLI-CARRID,
SPFLI-CONNID, TEXT-002.
*D: TEXT-001: 'Ha elegido'
*D: TEXT-002: 'vuelo'

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

CAR ID de a Salida Lnea SPFLI-CARRID SPFLI-CONNID


LH 0400 Frankfurt New York 10:10:00
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

LH 0402 Frankfurt New York 13:30:00 LH 0402 ?


SY-LISEL SPFLI-CARRID SPFLI-CONNID SPFLI-DEPTIME
REPORT RSAAA11A.

AT LINE-SELECTION.
WRITE: TEXT-001, SPFLI-CARRID,
SPFLI-CONNID, TEXT-002.

186
Selecting valid lines

Lneas de cabecera rea Hide


"SPFLI-CARRID" LH
"SPFLI-CONNID" 0400
"SPFLI-CARRID" LH
Lneas de pie "SPFLI-CONNID" 3577

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

E027 Sin autorizacin

188
Message

REPORT <nombre de report> MESSAGE-ID <id de mensaje>.

.
.
.

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

Seleccin de una base de Grupos de usuarios


datos lgica

Agrupamiento de campos Asignacin de usuarios


a reas funcionales
Definicin de campos auxiliares

Query

Definicin de listas
Lista estndar
Estadstica
Lista ranking

Inicio de query

192
Ejercicio 7

Ejecutar el programa ZIRPM001.


Visualizar listas interactivas.

Time: 15 Min

193
SAP R/3

Debugging

194
How enter to debugging
mode Desarrollo
ABAP

1 3

Debugging

Programa RSAAA04D Programa RSAAA04D

Ejecutar

2
Editor ABAP Pantalla de seleccin

Programa... Utilidades... /h
Ejecutar
Parmetros programa

195
Debugging mode

Seleccionar Paso a paso Ejecutar Continuar Intro Tabla Ver Lista

REPORT RSAAA04D.
DATA: DIFF TYPE P,
.
.
.
COMPUTE DATE_1 = SY-DATE.
.
.
.

Variables
DATE_1 00000000
SY-DATE 19950223

X R

196
Important debugging options

Paso a paso Se procesa la siguiente lnea del programa.

Ejecutar A diferencia de la funcin PASO A PASO, se realizan todos los pasos


de procesamiento pertenecientes a una lnea por completo.
Continuar El procesamiento contina hasta el siguiente breakpoint o el final del
programa .
Tabla Se visualizan los contenidos de las tablas internas.

Breakpoint Puede definir breakpoints mediante las funciones de este men.

Editor Puede acceder al editor ABAP/4.

Visualizacin Los contenidos de los datos se pueden visualizar en hexadecimal.


hexadecimal

Reemplazar Puede modificar contenidos de datos durante el debugging.

197
Breakpoint
1
Editor ABAP Men Utilidades --> Breakpoints

Palabra clave BREAK-POINT

2
Modo debugging Seleccin de lnea

Men: Colocar breakpoints

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

AUTHORITY-CHECK OBJECT <objeto de autorizacin>


ID <campo de autorizacin 1> FIELD <valor necesario>
ID <campo de autorizacin 2> FIELD <valor necesario>
....
ID <campo de autorizacin n> DUMMY .

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

Dictionary Screen Menu


ABAP/4
ABAP/4 Painter Painter

Entorno de tiempo de ejecucin

Procesador online Procesador ABAP/4

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.

1 El control pasa del procesador online al procesador ABAP/4


2 El control pasa del procesador ABAP/4 al procesador online
Screen
rea de trabajo dynpro rea de trabajo modulpool ABAP/4
Painter
SPFLI-CARRID TABLES: SPFLI.
LH LH 0400
PBO CARRID CONNID
SPFLI-CONNID
0400 DATA: OK-CODE (4).
PAI
OK-CODE

LOS
LOS MISMOS
MISMOS NOMBRES
NOMBRES

208
Creating a dialog program

Compaa area LH

Nmero de conexin 0400

...
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

Nombre Formato Texto


de campo Longitud breve Patrn

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

Full screen Atributos de campo

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.

PROCESS AFTER INPUT.


MODULE READ_SPFLI.

214
Creating a second dynpro
Dynpro 100 Copiar Dynpro 200

Dynpro 200

Atributos Control de proceso


..
. PROCESS BEFORE
OUTPUT.
Segundo dynpro PROCESS AFTER
INPUT.

Screen Lista de campos


SPFLI-CARRID
SPFLI-CARRID ___
SPFLI-CONNID
SPFLI-CONNID ____
SPFLI-CITYFROM
SPFLI-CITYFROM ______ SPFLI-CITYTO
..
SPFLI-CITYTO ______ .

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

PROCESS AFTER INPUT.


MODULE B. Transporte de datos desde
ABAP/4 al rea de trabajo
de dynpros

Emisin de la imagen de pantalla

ENTER

Transporte de datos desde


el dynpro al rea de trabajo
de ABAP/4

Ejecutar el mdulo B

217
Validating format
Screen
Painter
Lista de campos

Nom. campo Formato

FECHA DATS
.
.
.

IMPORTE DEC

Fecha 30.02.1996 Fecha

Importe Importe 12A3

E: La fecha no es vlida E: Introduzca un valor numrico

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

1 de nuevo listo para la entrada

219
Field sentence and data
transport S
e Screen
ENTER

PROCESS AFTER INPUT. Painter c Transporte de datos para


MODULE A. u todos los campos a
FIELD X MODULE B. e excepcin de X e Y desde
FIELD Y MODULE C. n el dynpro al rea de
MODULE D. c trabajo ABAP/4
i
a Ejecutar mdulo A

d Transporte de datos para X


e
Ejecutar mdulo B
a
c Transporte de datos para Y
c
i
o Ejecutar el mdulo C
n
e Ejecutar el mdulo D
s
220
Dynamic assign of next
dynpro Screen Screen
Painter Painter
Atributos de dynpro Atributos de dynpro

N de dynpro 100 N de dynpro 200


. .
. .
. .
Dynpro subsig. 100 Dynpro subsig. 200

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).

MODULE USER_COMMAND INPUT.


Screen SAVE_OKCODE = OKCODE.
Painter CLEAR OKCODE.
Lista de campos CASE SAVE_OKCODE.
Nombre campo Lg Form FktCode WHEN
. MORE.
.
.
PUSH_100 MORE
ENDMODULE.
OKCODE 4 OK

222
Ejercicio 8

1. Crear una dynpro que lleve por nombre ZCURSOxx.


2. Declarar los campos de Orden (AUFNR) y Texto Orden
(KTEXT).
3. Crear un Modulo dentro de la dynpro y realizar dentro
de el una busqueda a la tabla AUFK y mostrar el texto
de la orden (KTEXT) en el campo creado como texto.
4. Realizar la llamada a esta dynpro desde el programa.

Time: 25 Min

223
BAPI - Definition
Business Application Programming Interface

A BAPI is an interface to processes and data in a


business application system. It is implemented as
methods of an object in the Business Object
Repository (BOR).

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

Access to methods of objects in the BOR

Stable interface

The interface of a BAPI cannot be changed

Can be used internally and externally

BAPIs can be used both within the R/3 System and from outside

Independent

You can call any BAPI independently of any other

But: They do not have a presentation layer

The caller is responsible for the external visualization of the results

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

Crear una funcion RFC que lleve como parametros de entrada


el Numero de la Orden AUFK.
Realizar las busquedas correspondientes dado una orden.
Mostrar los datos de salida en la estructura creada
anteriormente.
Si no se consigue la orden dar un mensaje de error.
La nomenclatura de la funcion RFC debera ser ZRFCxx,
donde xx varia dependiendo de la cantidad de participantes.

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

You might also like