1. Introduction in ABAP Data fields and tables (SE11)

ABAP Dictionary (SE11) is the elementary tool:

Domain : A domain (technical domain) describes the value range and formal attributes of a field.

The domain is used to define the value range of a field with formal specifications, such as format and length, by defining fixed values or a value table.

Database table : Setting of primary keys leads to a specific access of data of a certain table.

A) Create a domain, e.g. 13-digit numeric field for material number and acitvate with wizard icon.

b) Create Data Element via SE11

In addition create Field Label „Headline“ for data element:

C) Create Database table

Also set „Technical Settings“:

When the activation set via wizard icon following warning pops up:

D) Enter Data

Display data via:

Not all user have SE11 transaction therefore use the Table Maintenance Generator:

Via SM30 Data Entries can be made or displayed.

2. First ABAP Programming (SE38)

First example of a program which does:

  • Read data from a specific table
  • Read data from the specific table with a specific condition
  • Display the result

Normal program for read out data is

SELECT <result>
INTO [table] <target>
FROM <source>
WHERE <condition>

a) SELECT syntax

SELECT * : reads out all columns/ fields and all lines/ data of a table –> normal case

SELECT SINGLE * : reads out all columns/ fields for exact one line/ data from a table

If SELECT * is used the target must be an internal table in the same format of the data table. Herefore another internal table (itab) needs to be created:

data: itab_zgewerk type table of zgewerk.

First result:

data: itab_zgewerk type table of zgewerk.

select *

into table itab_zgewerk

from zgewerk

Now the condition needs to be selected by syntax WHERE <condition in a specific field = Technical name of result table>

WHERE productionsection = ‚2‘.

Excurs: Logical operators:

EQ or = Equals

NQ or <> Not Equal

GT or > Greater than

GE or >= Greater/ Equal than

LT or < Lower than

LE or <= Lower/ Equal than

b) LOOP and WRITE syntax

The data cannot yet being displayed via itab. Hence a work area table needs to be created which can be displayed.

data: itab_zgewerk type table of zgewerk,

wa_zgewerk type zgewerk.

To read out the itab line by line into the work area tabe wa_zgewerk the syntax LOOP is necessary:

loop at itab_zgewerk

into wa_zgewerk.

With syntax WRITE the result can be displayed as list format:

loop at itab_zgewerk

into wa_zgewerk.

write: / ‚Mat-Id:‘, wa_zgewerk-Materialnumber,

/ ‚Gewerk:‘, wa_zgewerk-productionsection,

/ .

ENDLOOP.

c) IF and CASE syntax

To consider conditions the IF and CASE syntax is necessary so called IF and CASE routings (GER Verzweigungen nach entweder-oder). Here the data in the fields must be exact. If data is different e.g. Dipl-Ing or Dipl. Ing. the result can differ. Therefore data entry mistakes should be reduced. Syntax TRANSLATE <text> TO UPPER CASE or LOWER CASE can be useful.

TRANSLATE SYNTAX IF SYNTAX

Example:  Within ITAB_STUDENTEN in our ABAP-Program different information about students, e.g. student course exists.ang. With help of a counting variable (GER „Zählvariable“) ANZ_TECH_INF (Data type i) we like to count the number of students with course „Informatik“.

LOOP AT itab_studenten into wa_studenten.

If wa_studenten-studiengang = ‚Informatik“.

anz_tech_inf = anz_tech_inf +1.

ELSE.

anz_sonstige = anz_sonstige + 1.

ENDIF.

ENDLOOP.

ELSEIF to count not only „Informatik“ but other courses „Wirtschaftsmathematik“ and „Betriebswirtschaftslehre“:

Built in several IF-conditions with „übergeordnete“ und „untergeordnete“ structure:

With syntax CASE only one data object, e.g. field will be checked against a condition.

CASE SYNTAX

First step via LOOP-syntax all student data from ITAB_STUDENTEN will be read into work area wa_studenten. Second step via CASE-syntax the data field / technical name will be named which content should be checked (here field WA_STUDENTEN-STUDIENGANG). This is the single data object wihtin the CASE structure.

Third step via WHEN-syntax different options will be checked, e.g. entry ‚Technische Informatik‘ with counting variable ANZ_TECH_INF.

Finally program goes to ENDCASE-syntax.

Advantages of CASE-syntax (less programming and higher performance) vs. IF-syntax: