SlideShare a Scribd company logo
Data structures and Internal
tables
SAP - ABAP
Topics
2
 Data structures and Internal tables
Objectives
3
The participants will be able to:
Create a Structure in an ABAP Program
Create an Internal Table in an ABAP program
Populate an Internal Table with data
Read Database information into an Internal Table
Data Structures
4
Address List
Structure
Address List
Internal Table
LN FN City ST. LN FN City ST.
LN FN City ST.
LN FN City ST.
Declaring a Structure - Method #1
5
5
1 REPORT YN1C0008.
2
3 TABLES: TABNA.
4 DATA: BEGIN OF ADDRESS,
5 FLAG TYPE C,
6 ID LIKE TABNA-ID,
7 NAME1 LIKE TABNA-NAME1,
8 CITY LIKE TABNA-CITY,
9 END OF ADDRESS.
10 MOVE ‘X’ TO ADDRESS-FLAG.
11 MOVE ‘0001’ TO ADDRESS-ID.
12 MOVE ‘Smith’ TO ADDRESS-NAME1.
13 MOVE ‘Philadelphia’ TO
14 ADDRESS- CITY.
15 WRITE ADDRESS.
16
17
Basic Syntax:
DATA: BEGIN OF <name>
<field1> . . .
<field2> . . .
. . .
END OF <name>.
Flag ID Name1 City
Address Structure
Is this statement
necessary for the
code?
Declaring a Structure - Method #2
6
6 Data Structure & Inter3.07
REPORT Yxxxxxxx.
TYPES: BEGIN OF ADDR,
FLAG,
ID LIKE EMPLOYEE-ID,
NAME1 LIKE EMPLOYEE-NAME1,
CITY LIKE EMPLOYEE-CITY,
END OF ADDR.
DATA: ADDRESS TYPE ADDR.
MOVE: ‘X’ TO ADDRESS-FLAG,
‘00001’ TO ADDRESS-ID,
‘Smith’ TO ADDRESS-NAME1,
‘Philadelphia’ TO ADDRESS-CITY.
WRITE ADDRESS.
Basic Syntax:
TYPES: BEGIN OF <name1>,
<field1> . . . ,
<field2> . . . ,
. . . ,
END OF <name1>.
DATA: <name2> TYPE
<name1>.
Flag ID Name1 City
Address Structure
Populating a Structure with Field-by-Field Transport
7
7 Data Structure & Internal Tables | 3.07
REPORT Y170DM37.
TABLES: EMPLOYEE.
DATA: BEGIN OF ADDRESS,
FLAG,
ID LIKE EMPLOYEE-ID,
NAME LIKE EMPLOYEE-NAME1,
CITY LIKE EMPLOYEE-CITY,
END OF ADDRESS.
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE
TO ADDRESS.
WRITE: / ADDRESS-FLAG,
ADDRESS-ID, ADDRESS-NAME,
ADDRESS-CITY.
CLEAR ADDRESS.
ENDSELECT.
EMPLOYEE
Address
ID Name1 City
000000001 Electronics Inc. Waldorf
MOVE-CORRESPONDING EMPLOYEE
TO ADDRESS.
Flag ID Name City
000000001 Waldorf
Clear <f1>.
Demonstration
8
8 Data Structure & Internal Tables | 3.07
 Declaring a structure and populating the structure with values inside a program.
Practice
9
9 Data Structure & Internal Tables | 3.07
 Declaring a structure and populating the structure with values inside a program.
Internal Table Types
10
10 Data Structure & Internal Tables | 3.07
 Standard
 Sorted
 Hashed
Creating an Internal Table with Header Line
11
11 Data Structure & Internal Tables | 3.07
REPORT Y170DM38.
TABLES: EMPLOYEE.
TYPES: BEGIN OF EMP,
ID LIKE EMPLOYEE-ID,NAME1
LIKE EMPLOYEE-NAME1,
COUNTRY LIKE
EMPLOYEE-COUNTRY,
END OF EMP.
DATA: EMPTAB TYPE STANDARD TABLE
OF EMP INITIAL SIZE 10 WITH
HEADER LINE.
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE TO
EMPTAB.
APPEND EMPTAB.
ENDSELECT.
The TYPES statement defines the
structure and data type for the
internal table.
The DATA statement with an
INITIAL SIZE creates the actual
internal table capable of storing
data. Because of the WITH
HEADER LINE addition, this
internal table is created with a
header line.
Header Line
ID NAME1 COUNTRY
Size of an Internal Table
12
12 Data Structure & Internal Tables | 3.07
Loading an Internal Table with a Header Line
13
13 Data Structure & Internal Tables | 3.07
APPEND <int. table>
SORTED BY <field>.
APPEND <int. table>.
Department Salary
1
2
3
4
5
6
Department Salary
Header
R&D 400,000
PROD 7,800,000
MKTG 1,000,000
SALES 500,000
HR 140,000
IT 50,000
R&D 400,000
MKTG 1,000,000
SALES 500,000
PROD 7,800,000
IT 50,000
HR 140,000
Loading an Internal Table with a Header Line
14
14 Data Structure & Internal Tables | 3.07
REPORT Y170DM42.
TABLES: EMPLOYEE.
TYPES: BEGIN OF EMP,
COUNTRY LIKE EMPLOYEE-COUNTRY,
ID LIKE EMPLOYEE-ID,
SALARY LIKE EMPLOYEE-SALARY,
END OF EMP.
DATA: EMPTAB TYPE STANDARD TABLE
OF EMP INITIAL SIZE 10 WITH HEADER LINE.
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB.
APPEND EMPTAB.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB.
APPEND EMPTAB SORTED BY SALARY.
ENDSELECT.
More than ten entries can be
saved in the internal table.
A maximum of ten entries
can be saved in the internal
table. Any entries that
exceed the top ten will
be deleted.
With both versions of the
APPEND statement, memory
space for ten records is
allocated when the first record
is written to the internal table.
Example 1
Example 2
OR
Loading an Internal Table with a Header Line
15
15 Data Structure & Internal Tables | 3.07
REPORT Y170DM42.
TABLES: EMPLOYEE.
TYPES: BEGIN OF EMP,
COUNTRY LIKE EMPLOYEE-COUNTRY,
ID LIKE EMPLOYEE-ID,
SALARY LIKE EMPLOYEE-SALARY,
END OF EMP.
DATA: EMPTAB TYPE STANDARD TABLE
OF EMP INITIAL SIZE 10 WITH HEADER LINE.
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB.
APPEND EMPTAB.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB.
APPEND EMPTAB SORTED BY SALARY.
ENDSELECT.
More than ten entries can be
saved in the internal table.
A maximum of ten entries
can be saved in the internal
table. Any entries that
exceed the top ten will
be deleted.
With both versions of the
APPEND statement, memory
space for ten records is
allocated when the first record
is written to the internal table.
Example 1
Example 2
OR
Internal Table with Header Line
16
16 Data Structure & Internal Tables | 3.07
EMPLOYEE
COUNTRY ID FORMA NAME1 SORTL . . .
ID NAME1 COUNTRY
Header Line
A
B
Internal Table with Header Line
17
17 Data Structure & Internal Tables | 3.07
ID NAME1 COUNTRY
EMPLOYEE
USA 00000001 Company Baker Distributors BAKER . . .
COUNTRY ID FORMA NAME1 SORTL . . .
Header Line
1
Internal Table with Header Line
18
18 Data Structure & Internal Tables | 3.07
ID NAME1 COUNTRY
00000001 Baker Distributors USA
EMPLOYEE
Header Line
2
1
USA 00000001 Company Baker Distributors BAKER . . .
COUNTRY ID FORMA NAME1 SORTL . . .
Internal Table with Header Line
19
19 Data Structure & Internal Tables | 3.07
USA 00000001 Company Baker Distributors BAKER . . .
ID NAME1 COUNTRY
00000001 Baker Distributors USA
00000001 Baker Distributors USA
EMPLOYEE
COUNTRY ID FORMA NAME1 SORTL . . .
Header Line
2
3
1
2
3
10
.
.
.
.
.
.
This header line is
attached to the
body of the
internal table.
1
Internal Table with Header Line
20
20 Data Structure & Internal Tables | 3.07
ID NAME1 COUNTRY
00000001 Baker Distributors USA
00000002 Diversified Indust... USA
00000002 Diversified Indust... USA
USA 00000002 Company Diversified Indust.. DIVERS . . .
EMPLOYEE
COUNTRY ID FORMA NAME1 SORTL . . .
Header Line
5
6
1
2
3
10
.
.
.
.
.
.
4
Creating an Internal Table without a Header Line
REPORT Y170DM40.
TABLES: EMPLOYEE.
TYPES: BEGIN OF EMP,
ID LIKE EMPLOYEE-ID,
NAME1 LIKE EMPLOYEE-NAME1,
COUNTRY LIKE EMPLOYEE-COUNTRY,
END OF EMP.
DATA: EMPTAB TYPE STANDARD TABLE
OF EMP INITIAL SIZE 10,
EMPTAB_WA TYPE EMP.
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB_WA.
APPEND EMPTAB_WA TO EMPTAB.
ENDSELECT.
ID NAME1 COUNTRY
APPEND <work area> to <EMPTAB>.
The TYPES statement defines the
structure and data type for the
internal table and its work area
Work Area
The DATA statement with an INITIAL
SIZE creates the actual internal table
without a header line. The DATA
statement without the INITIAL SIZE
creates the work area for the internal
table.
Internal Table without a Header Line WHY???
22
22 Data Structure & Internal Tables | 3.07
Separate Internal Table Work Area
Performance Issues
Nested Internal Tables
Internal Table without a Header Line
23
23 Data Structure & Internal Tables | 3.07
EMPLOYEE
COUNTRY ID FORMA NAME1 SORTL . . .
Work Area
A
B
ID NAME1 COUNTRY
Internal Table without a Header Line
24
24 Data Structure & Internal Tables | 3.07
ID NAME1 COUNTRY
ID NAME1 COUNTRY
00000001 Baker Distributors USA
00000001 Baker Distributors USA
USA 00000001 Company Baker Distributors BAKER . . .
EMPLOYEE
COUNTRY ID FORMA NAME1 SORT . . .
Work Area
1
2
3
1
2
3
10
.
.
.
This work area is
not attached to
the body of the
internal table.
Automatic Field Conversion
25
25 Data Structure & Internal Tables | 3.07
 MOVE-CORRESPONDING or MOVE field to field
– Individual field type conversion
 MOVE
– Structure to structure
– Field to structure
– Structure to field
• Intermediate C type
• Followed by adoption of new types
Mass Reading from Database Tables into Internal Tables
26
26 Data Structure & Internal Tables | 3.07
REPORT Y170DM69.
TABLES: EMPLOYEE.
DATA: EMPTAB LIKE STANDARD TABLE EMPLOYEE INITIAL
SIZE 10 WITH HEADER LINE.
SELECT * FROM EMPLOYEE INTO TABLE EMPTAB
WHERE COUNTRY = ‘USA’.
SELECT * FROM <table> . . .
1. INTO TABLE <EMPTAB>.
2. APPENDING TABLE <EMPTAB>.
Notice no ENDSELECT is
needed here because no loop
processing occurs.
Processing an Internal Table
27
27 Data Structure & Internal Tables | 3.07
REPORT Y170DM45.
TABLES: EMPLOYEE.
TYPES: BEGIN OF EMP,
COUNTRY LIKE EMPLOYEE-COUNTRY,
NAME1 LIKE EMPLOYEE-NAME1,
SALES LIKE EMPLOYEE-SALES,
END OF EMP.
DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH HEADER
LINE.
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB.
APPEND EMPTAB.
ENDSELECT.
LOOP AT EMPTAB WHERE COUNTRY BETWEEN ‘A’ AND ‘D’.
WRITE: / EMPTAB-COUNTRY, EMPTAB-NAME1,
EMPTAB-SALES.
ENDLOOP.
IF SY-SUBRC NE 0.
WRITE: / ‘NO ENTRIES’.
ENDIF.
This LOOP AT <EMPTAB>
statement allows for a logical
expression in a WHERE clause to
limit the processing of the internal
table.
If no internal table entries
qualify under the logical
expression, the statement
within the loop is not executed
and SY-SUBRC is set to 4.
System Field SY-TABIX
28
28 Data Structure & Internal Tables | 3.07
REPORT Y170DM46.
TABLES: EMPLOYEE.
TYPES: BEGIN OF EMP,
COUNTRY LIKE EMPLOYEE-COUNTRY,
NAME1 LIKE EMPLOYEE-NAME1,
END OF EMP.
DATA: EMPTAB TYPE STANDARD TABLE OF EMP
INITIAL SIZE 10 WITH HEADER LINE.
PARAMETERS: START LIKE SY-TABIX DEFAULT 10,
END LIKE SY-TABIX DEFAULT 20.
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB.
APPEND EMPTAB.
ENDSELECT.
LOOP AT EMPTAB FROM START TO END.
WRITE: / SY-TABIX, EMPTAB-COUNTRY, EMPTAB-NAME1.
ENDLOOP.
Screen output
SY-TABIX
Accumulating Data within an Internal Table
29
29 Data Structure & Internal Tables | 3.07
REPORT Y170DM43.
TABLES: EMPLOYEE.
TYPES: BEGIN OF EMP,
COUNTRY LIKE EMPLOYEE-COUNTRY,
SALES LIKE EMPLOYEE-SALES,
END OF EMP.
DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL
SIZE 10 WITH HEADER LINE.
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB.
COLLECT EMPTAB.
ENDSELECT.
LOOP AT EMPTAB.
WRITE: / EMPTAB-COUNTRY, EMPTAB-SALES.
ENDLOOP.
COLLECT <EMPTAB>.
Country Sales
D 400,000
USA 1,000,000
GB 500,000
D 7,800,000
Header Line
A 371,065.00
CH 45,305.00
D 8,200,000.00
F 0.00
GB 500,000.00
NL 577,000.00
NO 234.00
USA 1,000,000.00
HK 0.00
Screen output
Sorting an Internal Table
30
30 Data Structure & Internal Tables | 3.07
REPORT Y170DM44.
TABLES: EMPLOYEE.
TYPES: BEGIN OF EMP,
COUNTRY LIKE EMPLOYEE-COUNTRY,
NAME1 LIKE EMPLOYEE-NAME1,
SALES LIKE EMPLOYEE-SALES,
END OF EMP.
DATA: EMPTAB TYPE STANDARD TABLE OF EMP
INITIAL SIZE 10 WITH HEADER LINE.
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB.
APPEND EMPTAB.
ENDSELECT.
SORT EMPTAB BY SALES DESCENDING.
LOOP AT EMPTAB.
WRITE: / ITAB-COUNTRY, ITAB-NAME1, ITAB-SALES.
ENDLOOP.
Sorting options:
1) SORT <EMPTAB> - sorts the
entries of the internal table
<EMPTAB> in ascending order.
2) SORT <EMPTAB> BY <field> - sorts
the table on one or more fields
within the table.
screen output
Control Level Processing
31
31 Data Structure & Internal Tables | 3.07
 AT FIRST
 AT NEW < field >
 AT END < field >
 AT LAST
Reading a Single Table Entry
32
32 Data Structure & Internal Tables | 3.07
REPORT Y170DM47.
TABLES: EMPLOYEE.
TYPES: BEGIN OF EMP,
COUNTRY LIKE EMPLOYEE-COUNTRY,
NAME1 LIKE EMPLOYEE-NAME1,
END OF EMPTAB.
DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH
HEADER LINE.
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB.
APPEND EMPTAB.
ENDSELECT.
READ TABLE ….
Reading a Single Table Entry - Options
33
33 Data Structure & Internal Tables | 3.07
READ TABLE <EMPTAB> options:
1) READ TABLE <EMPTAB>.
2) READ TABLE <EMPTAB> WITH KEY <k1> = <v1>…
<kn> = <vn>.
3) READ TABLE <EMPTAB> WITH TABLE KEY <k1> = <v1> ...
<kn> = <vn>.
4) READ TABLE <EMPTAB> WITH KEY = <value>.
5) READ TABLE <EMPTAB> WITH KEY . . . BINARY SEARCH.
6) READ TABLE <EMPTAB> INDEX <i>.
7) READ TABLE <EMPTAB> COMPARING <f1> <f2> . . . .
8) READ TABLE <EMPTAB> COMPARING ALL FIELDS.
9) READ TABLE <EMPTAB> TRANSPORTING <f1> <f2> . . . .
10) READ TABLE <EMPTAB> TRANSPORTING NO FIELDS.
Maintaining Internal Tables
34
34 Data Structure & Internal Tables | 3.07
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB.
APPEND EMPTAB.
ENDSELECT.
READ TABLE EMPTAB INDEX 1.
MOVE ‘ABC’ TO EMPTAB-NAME1.
MODIFY EMPTAB INDEX SY-TABIX.
IF SY-SUBRC NE 0.
WRITE / ‘Attempt to modify failed.’.
ELSE.
WRITE: / EMPTAB-COUNTRY,
EMPTAB-NAME1.
ENDIF.
INSERT EMPTAB INDEX 1.
DELETE EMPTAB INDEX SY-TABIX.
INSERT <EMPTAB> INDEX <i>.
MODIFY <EMPTAB> INDEX <i>.
DELETE <EMPTAB> INDEX <i>.
Check SY-SUBRC after
every attempt to change
an internal table entry.
Working with an Internal Table without a Header Line
35
35 Data Structure & Internal Tables | 3.07
APPEND <work area> TO <internal table>.
COLLECT <work area> INTO <internal table>.
INSERT <work area> INTO <internal table>.
MODIFY <internal table> FROM <work area>.
READ TABLE <internal table> INTO <work area>.
LOOP AT <internal table> INTO <work area>.
Deleting an Internal Table
36
36 Data Structure & Internal Tables | 3.07
CLEAR <internal table>
 Initialises the header line.
 Internal table lines remain
unchanged.
REFRESH <internal table>
 Deletes all table lines.
 Storage space is not released.
 Paging is released.
 Header line remains unchanged.
FREE <internal table>
 Deletes all table lines.
 Storage space is released.
 Header line remains
unchanged
Information about an Internal Table
37
37 Data Structure & Internal Tables | 3.07
REPORT Y170DM49.
TABLES: EMPLOYEE.
TYPES: BEGIN OF EMP,
COUNTRY LIKE EMPLOYEE-COUNTRY,
NAME1 LIKE EMPLOYEE-NAME1,
END OF EMP.
DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH
HEADER LINE,
LINE_COUNT TYPE I,
INITIAL_COUNT TYPE I.
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB.
APPEND EMPTAB.
ENDSELECT.
DESCRIBE TABLE EMPTAB
LINES LINE_COUNT
OCCURS INITIAL_COUNT.
WRITE: / ‘ lines:’, LINE_COUNT,
/ ‘occurs:’, INITIAL SIZE_COUNT.
DESCRIBE TABLE <internal table>
LINES <var1>
OCCURS <var2>.
screen output
Calling the SAP Table Editor
38
38 Data Structure & Internal Tables | 3.07
REPORT Y170DM50.
TABLES: EMPLOYEE.
TYPES: BEGIN OF EMP,
COUNTRY LIKE EMPLOYEE-COUNTRY,
NAME1 LIKE EMPLOYEE-NAME1,
END OF EMP,
DATA:EMPTAB TYPE STANDARD TABLE OF EMP
INITIAL SIZE 10 WITH HEADER LINE,
SELECT * FROM EMPLOYEE.
MOVE-CORRESPONDING EMPLOYEE TO EMPTAB.
APPEND EMPTAB.
ENDSELECT.
EDITOR-CALL FOR EMPTAB.
CHECK SY-SUBRC EQ 0.
LOOP AT EMPTAB WHERE NAME1 EQ ‘Maurice Cheeks’.
WRITE: / EMPTAB-COUNTRY, EMPTAB-NAME1.
ENDLOOP.
IF SY-SUBRC NE 0. WRITE: / ‘No records.’. ENDIF.
screen output
Demonstration
39
39 Data Structure & Internal Tables | 3.07
 Declaring an internal table, populating it by selecting data from the table and then
looping into it and displaying the data fetched.
Practice
40
40 Data Structure & Internal Tables | 3.07
 Declaring an internal table, populating it by selecting data from the table and then
looping into it and displaying the data fetched.
Summary
41
41 Data Structure & Internal Tables | 3.07
 Structures in code are temporary objects in program memory.
 A structure can be defined using a combination of the TYPES and DATA
statements.
 The statement MOVE-CORRESPONDING transports values field by field between
the ABAP data structures.
 Internal table, that can store records of data temporarily during the processing
of a program.
 3 different types of internal tables: Standard, Sorted, and Hashed.
 An internal table object is created with the DATA statement by referring to an
internal table type using the TYPE parameter
 APPEND statement adds the contents of the header line to the end of the
internal table.
 the system field SY-TABIX is set to the line number of the entry read.
Summary (Contd.)
42
42 Data Structure & Internal Tables | 3.07
 The CLEAR statement resets all fields to their initial value.
 The REFRESH statement deletes all table lines.
 The FREE statement releases the storage space required for a table.
Questions
43
43 Data Structure & Internal Tables | 3.07
 What is a Structure?
 What is an internal table?
 What are the different types of internal tables are there?
 Explain the following statements :
 Move corresponding
 Append
 Clear
 Refresh
 Free.
44
Thanks
Ad

More Related Content

What's hot (20)

SAP Adobe forms
SAP Adobe formsSAP Adobe forms
SAP Adobe forms
Jugul Crasta
 
Call transaction method
Call transaction methodCall transaction method
Call transaction method
Kranthi Kumar
 
Internal tables
Internal tablesInternal tables
Internal tables
waseem27
 
Reports
ReportsReports
Reports
Jugul Crasta
 
ABAP Event-driven Programming &Selection Screen
ABAP Event-driven Programming &Selection ScreenABAP Event-driven Programming &Selection Screen
ABAP Event-driven Programming &Selection Screen
sapdocs. info
 
Pm tables
Pm tablesPm tables
Pm tables
vbpc
 
Sap abap
Sap abapSap abap
Sap abap
SVRTechnologies
 
abap list viewer (alv)
abap list viewer (alv)abap list viewer (alv)
abap list viewer (alv)
Kranthi Kumar
 
ABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.infoABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.info
sapdocs. info
 
SAP ABAP - Needed Notes
SAP   ABAP - Needed NotesSAP   ABAP - Needed Notes
SAP ABAP - Needed Notes
Akash Bhavsar
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
sapdocs. info
 
Edit idoc , reprocess and test idoc
Edit idoc , reprocess and test idocEdit idoc , reprocess and test idoc
Edit idoc , reprocess and test idoc
lakshmi rajkumar
 
Introducing enhancement framework.doc
Introducing enhancement framework.docIntroducing enhancement framework.doc
Introducing enhancement framework.doc
Kranthi Kumar
 
Technical specification : SD(Logistics)_Order_Processing
Technical specification : SD(Logistics)_Order_ProcessingTechnical specification : SD(Logistics)_Order_Processing
Technical specification : SD(Logistics)_Order_Processing
JoshiRavin
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
Kranthi Kumar
 
Oracle apps-technical-tutorial
Oracle apps-technical-tutorialOracle apps-technical-tutorial
Oracle apps-technical-tutorial
Cheikh Ahmadou Bamba DIOP
 
Introduction to ABAP
Introduction to ABAPIntroduction to ABAP
Introduction to ABAP
sapdocs. info
 
Object oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAPObject oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAP
Noman Mohamed Hanif
 
Oracle R12 inventory Table name details with description
Oracle R12 inventory Table name details with descriptionOracle R12 inventory Table name details with description
Oracle R12 inventory Table name details with description
Boopathy CS
 
Call transaction method
Call transaction methodCall transaction method
Call transaction method
Kranthi Kumar
 
Internal tables
Internal tablesInternal tables
Internal tables
waseem27
 
ABAP Event-driven Programming &Selection Screen
ABAP Event-driven Programming &Selection ScreenABAP Event-driven Programming &Selection Screen
ABAP Event-driven Programming &Selection Screen
sapdocs. info
 
Pm tables
Pm tablesPm tables
Pm tables
vbpc
 
abap list viewer (alv)
abap list viewer (alv)abap list viewer (alv)
abap list viewer (alv)
Kranthi Kumar
 
ABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.infoABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.info
sapdocs. info
 
SAP ABAP - Needed Notes
SAP   ABAP - Needed NotesSAP   ABAP - Needed Notes
SAP ABAP - Needed Notes
Akash Bhavsar
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
sapdocs. info
 
Edit idoc , reprocess and test idoc
Edit idoc , reprocess and test idocEdit idoc , reprocess and test idoc
Edit idoc , reprocess and test idoc
lakshmi rajkumar
 
Introducing enhancement framework.doc
Introducing enhancement framework.docIntroducing enhancement framework.doc
Introducing enhancement framework.doc
Kranthi Kumar
 
Technical specification : SD(Logistics)_Order_Processing
Technical specification : SD(Logistics)_Order_ProcessingTechnical specification : SD(Logistics)_Order_Processing
Technical specification : SD(Logistics)_Order_Processing
JoshiRavin
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
Kranthi Kumar
 
Introduction to ABAP
Introduction to ABAPIntroduction to ABAP
Introduction to ABAP
sapdocs. info
 
Object oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAPObject oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAP
Noman Mohamed Hanif
 
Oracle R12 inventory Table name details with description
Oracle R12 inventory Table name details with descriptionOracle R12 inventory Table name details with description
Oracle R12 inventory Table name details with description
Boopathy CS
 

Viewers also liked (9)

Chapter 08 abap dictionary objects views1
Chapter 08 abap dictionary objects views1Chapter 08 abap dictionary objects views1
Chapter 08 abap dictionary objects views1
Kranthi Kumar
 
Creating messages
Creating messagesCreating messages
Creating messages
Kranthi Kumar
 
Creating simple comp
Creating simple compCreating simple comp
Creating simple comp
Kranthi Kumar
 
Dynamic binding
Dynamic bindingDynamic binding
Dynamic binding
Kranthi Kumar
 
SAP Modularization techniques
SAP Modularization techniquesSAP Modularization techniques
SAP Modularization techniques
Jugul Crasta
 
Exercise in alv
Exercise in alvExercise in alv
Exercise in alv
Kranthi Kumar
 
Open SQL & Internal Table
Open SQL & Internal TableOpen SQL & Internal Table
Open SQL & Internal Table
sapdocs. info
 
ABAP Open SQL & Internal Table
ABAP Open SQL & Internal TableABAP Open SQL & Internal Table
ABAP Open SQL & Internal Table
sapdocs. info
 
SAP FICO BBP Sample Document PDF NEW!
SAP FICO BBP Sample Document PDF NEW!SAP FICO BBP Sample Document PDF NEW!
SAP FICO BBP Sample Document PDF NEW!
sapdocs. info
 
Chapter 08 abap dictionary objects views1
Chapter 08 abap dictionary objects views1Chapter 08 abap dictionary objects views1
Chapter 08 abap dictionary objects views1
Kranthi Kumar
 
Creating simple comp
Creating simple compCreating simple comp
Creating simple comp
Kranthi Kumar
 
SAP Modularization techniques
SAP Modularization techniquesSAP Modularization techniques
SAP Modularization techniques
Jugul Crasta
 
Open SQL & Internal Table
Open SQL & Internal TableOpen SQL & Internal Table
Open SQL & Internal Table
sapdocs. info
 
ABAP Open SQL & Internal Table
ABAP Open SQL & Internal TableABAP Open SQL & Internal Table
ABAP Open SQL & Internal Table
sapdocs. info
 
SAP FICO BBP Sample Document PDF NEW!
SAP FICO BBP Sample Document PDF NEW!SAP FICO BBP Sample Document PDF NEW!
SAP FICO BBP Sample Document PDF NEW!
sapdocs. info
 
Ad

Similar to Sap abap-data structures and internal tables (20)

Internal tables in sap
Internal tables in sapInternal tables in sap
Internal tables in sap
Dharma Raju
 
Lecture06 abap on line
Lecture06 abap on lineLecture06 abap on line
Lecture06 abap on line
Milind Patil
 
Sq lite module7
Sq lite module7Sq lite module7
Sq lite module7
Highervista
 
Basic programming
Basic programmingBasic programming
Basic programming
Jugul Crasta
 
Data_Dictionary of sap abap known as DDIC.ppt
Data_Dictionary of sap abap known as DDIC.pptData_Dictionary of sap abap known as DDIC.ppt
Data_Dictionary of sap abap known as DDIC.ppt
pagajal493
 
05 internal tables
05 internal tables05 internal tables
05 internal tables
Brahmaiah Punati
 
07 sap scripts
07 sap scripts07 sap scripts
07 sap scripts
Kranthi Kumar
 
Part 1 - Microsoft AccessView GlossaryUse Access to create a.docx
Part 1 - Microsoft AccessView GlossaryUse Access to create a.docxPart 1 - Microsoft AccessView GlossaryUse Access to create a.docx
Part 1 - Microsoft AccessView GlossaryUse Access to create a.docx
honey690131
 
Sql Document in Testing
Sql Document in TestingSql Document in Testing
Sql Document in Testing
Saurabh Bhardwaj
 
HALL OF FAME INDUCTIONS
HALL OF FAME INDUCTIONSHALL OF FAME INDUCTIONS
HALL OF FAME INDUCTIONS
Talia Strnad
 
Normalization
NormalizationNormalization
Normalization
Shakila Mahjabin
 
Sql Server 2000
Sql Server 2000Sql Server 2000
Sql Server 2000
Om Vikram Thapa
 
0104 abap dictionary
0104 abap dictionary0104 abap dictionary
0104 abap dictionary
vkyecc1
 
53 SQL Questions-Answers=53 SQL Questions-Answers
53 SQL Questions-Answers=53 SQL Questions-Answers53 SQL Questions-Answers=53 SQL Questions-Answers
53 SQL Questions-Answers=53 SQL Questions-Answers
marukochan23
 
Abap report
Abap reportAbap report
Abap report
Ducat
 
Aspire it sap abap training
Aspire it   sap abap trainingAspire it   sap abap training
Aspire it sap abap training
Aspire Techsoft Academy
 
Best SAP ABAP Training Institute with Placement in Pune | Aspire
Best SAP ABAP Training Institute with Placement in Pune | AspireBest SAP ABAP Training Institute with Placement in Pune | Aspire
Best SAP ABAP Training Institute with Placement in Pune | Aspire
Aspire Techsoft Academy
 
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQLSql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Prashant Kumar
 
What is Database NormalizationExplain the guidelines for ensuring t.pdf
What is Database NormalizationExplain the guidelines for ensuring t.pdfWhat is Database NormalizationExplain the guidelines for ensuring t.pdf
What is Database NormalizationExplain the guidelines for ensuring t.pdf
arjunstores123
 
Database normalization
Database normalizationDatabase normalization
Database normalization
Vaibhav Kathuria
 
Internal tables in sap
Internal tables in sapInternal tables in sap
Internal tables in sap
Dharma Raju
 
Lecture06 abap on line
Lecture06 abap on lineLecture06 abap on line
Lecture06 abap on line
Milind Patil
 
Data_Dictionary of sap abap known as DDIC.ppt
Data_Dictionary of sap abap known as DDIC.pptData_Dictionary of sap abap known as DDIC.ppt
Data_Dictionary of sap abap known as DDIC.ppt
pagajal493
 
Part 1 - Microsoft AccessView GlossaryUse Access to create a.docx
Part 1 - Microsoft AccessView GlossaryUse Access to create a.docxPart 1 - Microsoft AccessView GlossaryUse Access to create a.docx
Part 1 - Microsoft AccessView GlossaryUse Access to create a.docx
honey690131
 
HALL OF FAME INDUCTIONS
HALL OF FAME INDUCTIONSHALL OF FAME INDUCTIONS
HALL OF FAME INDUCTIONS
Talia Strnad
 
0104 abap dictionary
0104 abap dictionary0104 abap dictionary
0104 abap dictionary
vkyecc1
 
53 SQL Questions-Answers=53 SQL Questions-Answers
53 SQL Questions-Answers=53 SQL Questions-Answers53 SQL Questions-Answers=53 SQL Questions-Answers
53 SQL Questions-Answers=53 SQL Questions-Answers
marukochan23
 
Abap report
Abap reportAbap report
Abap report
Ducat
 
Best SAP ABAP Training Institute with Placement in Pune | Aspire
Best SAP ABAP Training Institute with Placement in Pune | AspireBest SAP ABAP Training Institute with Placement in Pune | Aspire
Best SAP ABAP Training Institute with Placement in Pune | Aspire
Aspire Techsoft Academy
 
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQLSql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Sql notes, sql server,sql queries,introduction of SQL, Beginner in SQL
Prashant Kumar
 
What is Database NormalizationExplain the guidelines for ensuring t.pdf
What is Database NormalizationExplain the guidelines for ensuring t.pdfWhat is Database NormalizationExplain the guidelines for ensuring t.pdf
What is Database NormalizationExplain the guidelines for ensuring t.pdf
arjunstores123
 
Ad

Recently uploaded (20)

Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Agentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community MeetupAgentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community Meetup
Manoj Batra (1600 + Connections)
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 

Sap abap-data structures and internal tables

  • 1. Data structures and Internal tables SAP - ABAP
  • 2. Topics 2  Data structures and Internal tables
  • 3. Objectives 3 The participants will be able to: Create a Structure in an ABAP Program Create an Internal Table in an ABAP program Populate an Internal Table with data Read Database information into an Internal Table
  • 4. Data Structures 4 Address List Structure Address List Internal Table LN FN City ST. LN FN City ST. LN FN City ST. LN FN City ST.
  • 5. Declaring a Structure - Method #1 5 5 1 REPORT YN1C0008. 2 3 TABLES: TABNA. 4 DATA: BEGIN OF ADDRESS, 5 FLAG TYPE C, 6 ID LIKE TABNA-ID, 7 NAME1 LIKE TABNA-NAME1, 8 CITY LIKE TABNA-CITY, 9 END OF ADDRESS. 10 MOVE ‘X’ TO ADDRESS-FLAG. 11 MOVE ‘0001’ TO ADDRESS-ID. 12 MOVE ‘Smith’ TO ADDRESS-NAME1. 13 MOVE ‘Philadelphia’ TO 14 ADDRESS- CITY. 15 WRITE ADDRESS. 16 17 Basic Syntax: DATA: BEGIN OF <name> <field1> . . . <field2> . . . . . . END OF <name>. Flag ID Name1 City Address Structure Is this statement necessary for the code?
  • 6. Declaring a Structure - Method #2 6 6 Data Structure & Inter3.07 REPORT Yxxxxxxx. TYPES: BEGIN OF ADDR, FLAG, ID LIKE EMPLOYEE-ID, NAME1 LIKE EMPLOYEE-NAME1, CITY LIKE EMPLOYEE-CITY, END OF ADDR. DATA: ADDRESS TYPE ADDR. MOVE: ‘X’ TO ADDRESS-FLAG, ‘00001’ TO ADDRESS-ID, ‘Smith’ TO ADDRESS-NAME1, ‘Philadelphia’ TO ADDRESS-CITY. WRITE ADDRESS. Basic Syntax: TYPES: BEGIN OF <name1>, <field1> . . . , <field2> . . . , . . . , END OF <name1>. DATA: <name2> TYPE <name1>. Flag ID Name1 City Address Structure
  • 7. Populating a Structure with Field-by-Field Transport 7 7 Data Structure & Internal Tables | 3.07 REPORT Y170DM37. TABLES: EMPLOYEE. DATA: BEGIN OF ADDRESS, FLAG, ID LIKE EMPLOYEE-ID, NAME LIKE EMPLOYEE-NAME1, CITY LIKE EMPLOYEE-CITY, END OF ADDRESS. SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO ADDRESS. WRITE: / ADDRESS-FLAG, ADDRESS-ID, ADDRESS-NAME, ADDRESS-CITY. CLEAR ADDRESS. ENDSELECT. EMPLOYEE Address ID Name1 City 000000001 Electronics Inc. Waldorf MOVE-CORRESPONDING EMPLOYEE TO ADDRESS. Flag ID Name City 000000001 Waldorf Clear <f1>.
  • 8. Demonstration 8 8 Data Structure & Internal Tables | 3.07  Declaring a structure and populating the structure with values inside a program.
  • 9. Practice 9 9 Data Structure & Internal Tables | 3.07  Declaring a structure and populating the structure with values inside a program.
  • 10. Internal Table Types 10 10 Data Structure & Internal Tables | 3.07  Standard  Sorted  Hashed
  • 11. Creating an Internal Table with Header Line 11 11 Data Structure & Internal Tables | 3.07 REPORT Y170DM38. TABLES: EMPLOYEE. TYPES: BEGIN OF EMP, ID LIKE EMPLOYEE-ID,NAME1 LIKE EMPLOYEE-NAME1, COUNTRY LIKE EMPLOYEE-COUNTRY, END OF EMP. DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH HEADER LINE. SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. APPEND EMPTAB. ENDSELECT. The TYPES statement defines the structure and data type for the internal table. The DATA statement with an INITIAL SIZE creates the actual internal table capable of storing data. Because of the WITH HEADER LINE addition, this internal table is created with a header line. Header Line ID NAME1 COUNTRY
  • 12. Size of an Internal Table 12 12 Data Structure & Internal Tables | 3.07
  • 13. Loading an Internal Table with a Header Line 13 13 Data Structure & Internal Tables | 3.07 APPEND <int. table> SORTED BY <field>. APPEND <int. table>. Department Salary 1 2 3 4 5 6 Department Salary Header R&D 400,000 PROD 7,800,000 MKTG 1,000,000 SALES 500,000 HR 140,000 IT 50,000 R&D 400,000 MKTG 1,000,000 SALES 500,000 PROD 7,800,000 IT 50,000 HR 140,000
  • 14. Loading an Internal Table with a Header Line 14 14 Data Structure & Internal Tables | 3.07 REPORT Y170DM42. TABLES: EMPLOYEE. TYPES: BEGIN OF EMP, COUNTRY LIKE EMPLOYEE-COUNTRY, ID LIKE EMPLOYEE-ID, SALARY LIKE EMPLOYEE-SALARY, END OF EMP. DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH HEADER LINE. SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. APPEND EMPTAB. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. APPEND EMPTAB SORTED BY SALARY. ENDSELECT. More than ten entries can be saved in the internal table. A maximum of ten entries can be saved in the internal table. Any entries that exceed the top ten will be deleted. With both versions of the APPEND statement, memory space for ten records is allocated when the first record is written to the internal table. Example 1 Example 2 OR
  • 15. Loading an Internal Table with a Header Line 15 15 Data Structure & Internal Tables | 3.07 REPORT Y170DM42. TABLES: EMPLOYEE. TYPES: BEGIN OF EMP, COUNTRY LIKE EMPLOYEE-COUNTRY, ID LIKE EMPLOYEE-ID, SALARY LIKE EMPLOYEE-SALARY, END OF EMP. DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH HEADER LINE. SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. APPEND EMPTAB. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. APPEND EMPTAB SORTED BY SALARY. ENDSELECT. More than ten entries can be saved in the internal table. A maximum of ten entries can be saved in the internal table. Any entries that exceed the top ten will be deleted. With both versions of the APPEND statement, memory space for ten records is allocated when the first record is written to the internal table. Example 1 Example 2 OR
  • 16. Internal Table with Header Line 16 16 Data Structure & Internal Tables | 3.07 EMPLOYEE COUNTRY ID FORMA NAME1 SORTL . . . ID NAME1 COUNTRY Header Line A B
  • 17. Internal Table with Header Line 17 17 Data Structure & Internal Tables | 3.07 ID NAME1 COUNTRY EMPLOYEE USA 00000001 Company Baker Distributors BAKER . . . COUNTRY ID FORMA NAME1 SORTL . . . Header Line 1
  • 18. Internal Table with Header Line 18 18 Data Structure & Internal Tables | 3.07 ID NAME1 COUNTRY 00000001 Baker Distributors USA EMPLOYEE Header Line 2 1 USA 00000001 Company Baker Distributors BAKER . . . COUNTRY ID FORMA NAME1 SORTL . . .
  • 19. Internal Table with Header Line 19 19 Data Structure & Internal Tables | 3.07 USA 00000001 Company Baker Distributors BAKER . . . ID NAME1 COUNTRY 00000001 Baker Distributors USA 00000001 Baker Distributors USA EMPLOYEE COUNTRY ID FORMA NAME1 SORTL . . . Header Line 2 3 1 2 3 10 . . . . . . This header line is attached to the body of the internal table. 1
  • 20. Internal Table with Header Line 20 20 Data Structure & Internal Tables | 3.07 ID NAME1 COUNTRY 00000001 Baker Distributors USA 00000002 Diversified Indust... USA 00000002 Diversified Indust... USA USA 00000002 Company Diversified Indust.. DIVERS . . . EMPLOYEE COUNTRY ID FORMA NAME1 SORTL . . . Header Line 5 6 1 2 3 10 . . . . . . 4
  • 21. Creating an Internal Table without a Header Line REPORT Y170DM40. TABLES: EMPLOYEE. TYPES: BEGIN OF EMP, ID LIKE EMPLOYEE-ID, NAME1 LIKE EMPLOYEE-NAME1, COUNTRY LIKE EMPLOYEE-COUNTRY, END OF EMP. DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10, EMPTAB_WA TYPE EMP. SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB_WA. APPEND EMPTAB_WA TO EMPTAB. ENDSELECT. ID NAME1 COUNTRY APPEND <work area> to <EMPTAB>. The TYPES statement defines the structure and data type for the internal table and its work area Work Area The DATA statement with an INITIAL SIZE creates the actual internal table without a header line. The DATA statement without the INITIAL SIZE creates the work area for the internal table.
  • 22. Internal Table without a Header Line WHY??? 22 22 Data Structure & Internal Tables | 3.07 Separate Internal Table Work Area Performance Issues Nested Internal Tables
  • 23. Internal Table without a Header Line 23 23 Data Structure & Internal Tables | 3.07 EMPLOYEE COUNTRY ID FORMA NAME1 SORTL . . . Work Area A B ID NAME1 COUNTRY
  • 24. Internal Table without a Header Line 24 24 Data Structure & Internal Tables | 3.07 ID NAME1 COUNTRY ID NAME1 COUNTRY 00000001 Baker Distributors USA 00000001 Baker Distributors USA USA 00000001 Company Baker Distributors BAKER . . . EMPLOYEE COUNTRY ID FORMA NAME1 SORT . . . Work Area 1 2 3 1 2 3 10 . . . This work area is not attached to the body of the internal table.
  • 25. Automatic Field Conversion 25 25 Data Structure & Internal Tables | 3.07  MOVE-CORRESPONDING or MOVE field to field – Individual field type conversion  MOVE – Structure to structure – Field to structure – Structure to field • Intermediate C type • Followed by adoption of new types
  • 26. Mass Reading from Database Tables into Internal Tables 26 26 Data Structure & Internal Tables | 3.07 REPORT Y170DM69. TABLES: EMPLOYEE. DATA: EMPTAB LIKE STANDARD TABLE EMPLOYEE INITIAL SIZE 10 WITH HEADER LINE. SELECT * FROM EMPLOYEE INTO TABLE EMPTAB WHERE COUNTRY = ‘USA’. SELECT * FROM <table> . . . 1. INTO TABLE <EMPTAB>. 2. APPENDING TABLE <EMPTAB>. Notice no ENDSELECT is needed here because no loop processing occurs.
  • 27. Processing an Internal Table 27 27 Data Structure & Internal Tables | 3.07 REPORT Y170DM45. TABLES: EMPLOYEE. TYPES: BEGIN OF EMP, COUNTRY LIKE EMPLOYEE-COUNTRY, NAME1 LIKE EMPLOYEE-NAME1, SALES LIKE EMPLOYEE-SALES, END OF EMP. DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH HEADER LINE. SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. APPEND EMPTAB. ENDSELECT. LOOP AT EMPTAB WHERE COUNTRY BETWEEN ‘A’ AND ‘D’. WRITE: / EMPTAB-COUNTRY, EMPTAB-NAME1, EMPTAB-SALES. ENDLOOP. IF SY-SUBRC NE 0. WRITE: / ‘NO ENTRIES’. ENDIF. This LOOP AT <EMPTAB> statement allows for a logical expression in a WHERE clause to limit the processing of the internal table. If no internal table entries qualify under the logical expression, the statement within the loop is not executed and SY-SUBRC is set to 4.
  • 28. System Field SY-TABIX 28 28 Data Structure & Internal Tables | 3.07 REPORT Y170DM46. TABLES: EMPLOYEE. TYPES: BEGIN OF EMP, COUNTRY LIKE EMPLOYEE-COUNTRY, NAME1 LIKE EMPLOYEE-NAME1, END OF EMP. DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH HEADER LINE. PARAMETERS: START LIKE SY-TABIX DEFAULT 10, END LIKE SY-TABIX DEFAULT 20. SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. APPEND EMPTAB. ENDSELECT. LOOP AT EMPTAB FROM START TO END. WRITE: / SY-TABIX, EMPTAB-COUNTRY, EMPTAB-NAME1. ENDLOOP. Screen output SY-TABIX
  • 29. Accumulating Data within an Internal Table 29 29 Data Structure & Internal Tables | 3.07 REPORT Y170DM43. TABLES: EMPLOYEE. TYPES: BEGIN OF EMP, COUNTRY LIKE EMPLOYEE-COUNTRY, SALES LIKE EMPLOYEE-SALES, END OF EMP. DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH HEADER LINE. SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. COLLECT EMPTAB. ENDSELECT. LOOP AT EMPTAB. WRITE: / EMPTAB-COUNTRY, EMPTAB-SALES. ENDLOOP. COLLECT <EMPTAB>. Country Sales D 400,000 USA 1,000,000 GB 500,000 D 7,800,000 Header Line A 371,065.00 CH 45,305.00 D 8,200,000.00 F 0.00 GB 500,000.00 NL 577,000.00 NO 234.00 USA 1,000,000.00 HK 0.00 Screen output
  • 30. Sorting an Internal Table 30 30 Data Structure & Internal Tables | 3.07 REPORT Y170DM44. TABLES: EMPLOYEE. TYPES: BEGIN OF EMP, COUNTRY LIKE EMPLOYEE-COUNTRY, NAME1 LIKE EMPLOYEE-NAME1, SALES LIKE EMPLOYEE-SALES, END OF EMP. DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH HEADER LINE. SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. APPEND EMPTAB. ENDSELECT. SORT EMPTAB BY SALES DESCENDING. LOOP AT EMPTAB. WRITE: / ITAB-COUNTRY, ITAB-NAME1, ITAB-SALES. ENDLOOP. Sorting options: 1) SORT <EMPTAB> - sorts the entries of the internal table <EMPTAB> in ascending order. 2) SORT <EMPTAB> BY <field> - sorts the table on one or more fields within the table. screen output
  • 31. Control Level Processing 31 31 Data Structure & Internal Tables | 3.07  AT FIRST  AT NEW < field >  AT END < field >  AT LAST
  • 32. Reading a Single Table Entry 32 32 Data Structure & Internal Tables | 3.07 REPORT Y170DM47. TABLES: EMPLOYEE. TYPES: BEGIN OF EMP, COUNTRY LIKE EMPLOYEE-COUNTRY, NAME1 LIKE EMPLOYEE-NAME1, END OF EMPTAB. DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH HEADER LINE. SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. APPEND EMPTAB. ENDSELECT. READ TABLE ….
  • 33. Reading a Single Table Entry - Options 33 33 Data Structure & Internal Tables | 3.07 READ TABLE <EMPTAB> options: 1) READ TABLE <EMPTAB>. 2) READ TABLE <EMPTAB> WITH KEY <k1> = <v1>… <kn> = <vn>. 3) READ TABLE <EMPTAB> WITH TABLE KEY <k1> = <v1> ... <kn> = <vn>. 4) READ TABLE <EMPTAB> WITH KEY = <value>. 5) READ TABLE <EMPTAB> WITH KEY . . . BINARY SEARCH. 6) READ TABLE <EMPTAB> INDEX <i>. 7) READ TABLE <EMPTAB> COMPARING <f1> <f2> . . . . 8) READ TABLE <EMPTAB> COMPARING ALL FIELDS. 9) READ TABLE <EMPTAB> TRANSPORTING <f1> <f2> . . . . 10) READ TABLE <EMPTAB> TRANSPORTING NO FIELDS.
  • 34. Maintaining Internal Tables 34 34 Data Structure & Internal Tables | 3.07 SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. APPEND EMPTAB. ENDSELECT. READ TABLE EMPTAB INDEX 1. MOVE ‘ABC’ TO EMPTAB-NAME1. MODIFY EMPTAB INDEX SY-TABIX. IF SY-SUBRC NE 0. WRITE / ‘Attempt to modify failed.’. ELSE. WRITE: / EMPTAB-COUNTRY, EMPTAB-NAME1. ENDIF. INSERT EMPTAB INDEX 1. DELETE EMPTAB INDEX SY-TABIX. INSERT <EMPTAB> INDEX <i>. MODIFY <EMPTAB> INDEX <i>. DELETE <EMPTAB> INDEX <i>. Check SY-SUBRC after every attempt to change an internal table entry.
  • 35. Working with an Internal Table without a Header Line 35 35 Data Structure & Internal Tables | 3.07 APPEND <work area> TO <internal table>. COLLECT <work area> INTO <internal table>. INSERT <work area> INTO <internal table>. MODIFY <internal table> FROM <work area>. READ TABLE <internal table> INTO <work area>. LOOP AT <internal table> INTO <work area>.
  • 36. Deleting an Internal Table 36 36 Data Structure & Internal Tables | 3.07 CLEAR <internal table>  Initialises the header line.  Internal table lines remain unchanged. REFRESH <internal table>  Deletes all table lines.  Storage space is not released.  Paging is released.  Header line remains unchanged. FREE <internal table>  Deletes all table lines.  Storage space is released.  Header line remains unchanged
  • 37. Information about an Internal Table 37 37 Data Structure & Internal Tables | 3.07 REPORT Y170DM49. TABLES: EMPLOYEE. TYPES: BEGIN OF EMP, COUNTRY LIKE EMPLOYEE-COUNTRY, NAME1 LIKE EMPLOYEE-NAME1, END OF EMP. DATA: EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH HEADER LINE, LINE_COUNT TYPE I, INITIAL_COUNT TYPE I. SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. APPEND EMPTAB. ENDSELECT. DESCRIBE TABLE EMPTAB LINES LINE_COUNT OCCURS INITIAL_COUNT. WRITE: / ‘ lines:’, LINE_COUNT, / ‘occurs:’, INITIAL SIZE_COUNT. DESCRIBE TABLE <internal table> LINES <var1> OCCURS <var2>. screen output
  • 38. Calling the SAP Table Editor 38 38 Data Structure & Internal Tables | 3.07 REPORT Y170DM50. TABLES: EMPLOYEE. TYPES: BEGIN OF EMP, COUNTRY LIKE EMPLOYEE-COUNTRY, NAME1 LIKE EMPLOYEE-NAME1, END OF EMP, DATA:EMPTAB TYPE STANDARD TABLE OF EMP INITIAL SIZE 10 WITH HEADER LINE, SELECT * FROM EMPLOYEE. MOVE-CORRESPONDING EMPLOYEE TO EMPTAB. APPEND EMPTAB. ENDSELECT. EDITOR-CALL FOR EMPTAB. CHECK SY-SUBRC EQ 0. LOOP AT EMPTAB WHERE NAME1 EQ ‘Maurice Cheeks’. WRITE: / EMPTAB-COUNTRY, EMPTAB-NAME1. ENDLOOP. IF SY-SUBRC NE 0. WRITE: / ‘No records.’. ENDIF. screen output
  • 39. Demonstration 39 39 Data Structure & Internal Tables | 3.07  Declaring an internal table, populating it by selecting data from the table and then looping into it and displaying the data fetched.
  • 40. Practice 40 40 Data Structure & Internal Tables | 3.07  Declaring an internal table, populating it by selecting data from the table and then looping into it and displaying the data fetched.
  • 41. Summary 41 41 Data Structure & Internal Tables | 3.07  Structures in code are temporary objects in program memory.  A structure can be defined using a combination of the TYPES and DATA statements.  The statement MOVE-CORRESPONDING transports values field by field between the ABAP data structures.  Internal table, that can store records of data temporarily during the processing of a program.  3 different types of internal tables: Standard, Sorted, and Hashed.  An internal table object is created with the DATA statement by referring to an internal table type using the TYPE parameter  APPEND statement adds the contents of the header line to the end of the internal table.  the system field SY-TABIX is set to the line number of the entry read.
  • 42. Summary (Contd.) 42 42 Data Structure & Internal Tables | 3.07  The CLEAR statement resets all fields to their initial value.  The REFRESH statement deletes all table lines.  The FREE statement releases the storage space required for a table.
  • 43. Questions 43 43 Data Structure & Internal Tables | 3.07  What is a Structure?  What is an internal table?  What are the different types of internal tables are there?  Explain the following statements :  Move corresponding  Append  Clear  Refresh  Free.
  翻译: