• Introduzione
• Tipi di dati
• Variabili
• Costanti
• Istruzioni Base
• Tabelle interne
• Ranges
• Accesso database
• Generalità su Workbench
• Esempi applicativi
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 2
Introduzione
• “Data Type” in ABAP Dictionary è la vista che l’utente ha sui dati, che è
il formato dati nell’interfaccia. Il formato dei dati dipende dal sistema
database usato.
• Quando una tabella è definita in ABAP Dictionary i “data types” definiti
nello stesso sono copiati nei “data types” del sistema database in
utilizzo.
• Se un oggetto ABAP Dictionary è usato in un programma ABAP, i “Data
Dictionary Types” dell’oggetto sono convertiti nel corrispondente ABAP
Data Types.
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 3
Agenda
• Introduzione
• Tipi di dati
• Variabili
• Costanti
• Istruzioni Base
• Tabelle interne
• Ranges
• Accesso database
• Generalità su Workbench
• Esempi applicativi
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 4
Tipi di dati
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 5
Tipi di dati
• Il processore ABAP utilizza ABAP data types nelle aree di lavoro per i
dati.
• Data types ABAP:
• C: carattere • Se un data element o un campo di un oggetto
• D: data, formato YYYYMMDD ABAP Dictionary (struttura, tipo tabella,
• F: floating point tabella, view) è usato in un programma ABAP,
il data type Dictionary è convertito nel data
• I: intero type ABAP
• N: carattere stringa numerico
• P: valore o contatore (packed)
• S: time stamp
YYYYMMDDHHMMSS
• T: ora HHMMSS
• V: stringa di lunghezza variabile, i
primi due byte danno la lunghezza
• X: esadecimale
• STRING: stringa
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 6
Tipi di dati
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 7
Agenda
• Introduzione
• Tipi di dati
• Variabili
• Costanti
• Istruzioni Base
• Tabelle interne
• Ranges
• Accesso database
• Generalità su Workbench
• Esempi applicativi
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 8
Variabili
Variabile integer
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 9
Agenda
• Introduzione
• Tipi di dati
• Variabili
• Costanti
• Istruzioni Base
• Tabelle interne
• Ranges
• Accesso database
• Generalità su Workbench
• Esempi applicativi
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 10
Costanti
Costante di tipo
CHAR di valore
‘X’
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 11
Agenda
• Introduzione
• Tipi di dati
• Variabili
• Costanti
• Istruzioni Base
• Tabelle interne
• Ranges
• Accesso database
• Generalità su Workbench
• Esempi applicativi
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 12
Istruzioni base
• Istruzione IF
- L’istruzione IF è cosi strutturata:
• Istruzione Case
- L’istruzione Case è cosi strutturata:
Con l’utilizzo della case soltanto una delle sequenze di istruzioni verrà
eseguita. L’istruzione when others è opzionale, mentre solo un valore
può essere testato nella when; questo può essere sia un numero che
il nome di una variabile.
Istruzioni base
• Istruzione DO
- L’istruzione DO è cosi strutturata:
DO <n> TIMES.
istruzioni
ENDDO.
• Istruzione WHILE
- L’istruzione WHILE è cosi strutturata:
• Introduzione
• Tipi di dati
• Variabili
• Costanti
• Istruzioni Base
• Tabelle interne
• Ranges
• Accesso database
• Generalità su Workbench
• Esempi applicativi
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 17
Tabelle interne
• Le tabelle interne sono strutture dati che esistono solo nel programma
in cui sono dichiarate; possono contenere righe aventi gli stessi valori
senza problemi di chiave ed avere un header line.
• L’header line è simile ad una struttura e viene utilizzata come work
area della tabella interna. I data types delle righe tabella possono
essere semplici o strutturati.
• Si possono definire anche tabelle interne strutturate, types di tabelle
interne.
• Le tabelle interne vengono valorizzate con i dati provenienti dalla
lettura database o da calcoli eseguiti dal programma.
• L’assegnazione avviene tramite l’istruzione “MOVE” con tutte le sue
varianti (es. “MOVE-CORRESPONDING”).
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 18
Tabelle interne
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 19
Tabelle interne
• Introduzione
• Tipi di dati
• Variabili
• Costanti
• Istruzioni Base
• Tabelle interne
• Ranges
• Accesso database
• Generalità su Workbench
• Esempi applicativi
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 21
Ranges
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 22
Ranges
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 23
Agenda
• Introduzione
• Tipi di dati
• Variabili
• Costanti
• Istruzioni Base
• Tabelle interne
• Ranges
• Accesso database
• Generalità su Workbench
• Esempi applicativi
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 24
Accesso database
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 25
Accesso database
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 26
Accesso database
Comando Funzione
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 27
Accesso database
• Ogni comando Open SQL valorizza due variabili di sistema con return
code:
– SY-SUBRC: ad ogni comando questa variabile contiene il valore 0 se
l’esecuzione ha avuto successo, un valore diverso da 0 se si sono verificati
errori;
– SY-DBNCT: ad ogni comando questa variabile contiene il numero di linee
database processate.
• La struttura di sistema “SYST” contiene una serie di variabili valorizzate
durante l’esecuzione del programma; nell’utilizzo viene abbreviata con
“SY”. Per esempio contiene la data, l’ora di elaborazione, i dati tecnici
di sistema, il nome report, la riga corrispondente sullo schermo ecc.
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 28
Accesso database: lettura dati
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 29
Accesso database: lettura dati
SELECT <risultato> The SELECT clause defines the structure of the data you want to read, that is, whether one
line or several, which columns you want to read, and whether identical entries are
acceptable or not.
INTO <target> The INTO clause determines the target area <target> into which the selected data is to be
read.
FROM <source> The FROM clause specifies the database table or view <source> from which the data is to
be selected. It can also be placed before the INTO clause.
WHERE <cond> The WHERE clause specifies which lines are to be read by specifying conditions for the
selection.
GROUP BY <campo> The GROUP-BY clause produces a single line of results from groups of several lines. A
group is a set of lines with identical values for each column listed in <fields>.
HAVING <cond> The HAVING clause sets logical conditions for the lines combined using GROUP BY.
ORDER BY <cond> The ORDER-BY clause defines a sequence <fields> for the lines resulting from the
selection.
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 30
Agenda
• Introduzione
• Tipi di dati
• Variabili
• Costanti
• Istruzioni Base
• Tabelle interne
• Ranges
• Accesso database
• Generalità su Workbench
• Esempi applicativi
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 31
Generalità su Workbench
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 36
Generalità su Workbench
• Schema generale:
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 38
Agenda
• Introduzione
• Tipi di dati
• Variabili
• Costanti
• Istruzioni Base
• Tabelle interne
• Ranges
• Accesso database
• Generalità su Workbench
• Esempi applicativi
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 39
Esempi applicativi – Domande & risposte
Questo documento non deve essere riprodotto, né reso disponibile a terzi o alterato in ogni modo
This document must not be reproduced, made available to third persons, or misused in any other way PAG 40