Working with Complex Internal Tables Flashcards

1
Q

What are simple internal tables in ABAP?

A

Internal tables with scalar data types as their row type, consisting of one nameless column and each row contains a single piece of information. For example, a table with all integers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you define complex internal tables in ABAP?

A

By using structured data types as their row type, resulting in tables with multiple columns, each with a name and type corresponding to the structured row type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the three access types of internal tables in ABAP?

A
  1. Standard Table: Contents not stored in a particular sort order.
  2. Sorted Table: Contents always sorted according to key fields in ascending order.
  3. Hashed Table: Managed using a hash algorithm for fast retrieval.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the importance of table keys in ABAP internal tables?

A

Table keys are crucial for sorted and hashed tables for efficient data management and access. They determine the way data is managed and accessed within the table.
Key access allows identifying a row in an internal table based on the content of specific fields, not just by its position.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How should you define table types in ABAP for better programming practice?

A

It’s best to define the data type first and then create a variable referring to that type. Use local TYPES statements for method or class-specific usage, or global table types for system-wide usage (these are defined through a dedicated editor).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is index access in ABAP internal tables?

A

Index access involves addressing rows of an internal table by their position or index. It is fast and efficient, even for large internal tables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is key access in ABAP internal tables?

A

Key access involves addressing a row of the internal table by searching for particular values in specific columns, known as keys. It can be slower compared to index access, especially for large internal tables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of a work area in ABAP internal tables?

A

The work area is used as a data object to fill internal tables using the APPEND statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the significance of key uniqueness in ABAP internal tables?

A

Key uniqueness in ABAP internal tables determines whether duplicate entries are allowed, with options for standard tables (always allowed duplicates), hashed tables (no duplicates), and sorted tables (unique or non-unique keys).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can you declare a work area in ABAP?

A

You can declare a work area either by referencing the row type directly or using the LIKE LINE OF <internal_table> syntax.</internal_table>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What advantage does using LIKE LINE OF provide when declaring a work area in ABAP?

A

It ensures that the work area fits the structure of the internal table, even if the definition of the internal table changes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What effect does filling the work area before the APPEND statement have in ABAP?

A

It ensures that the new row added to the internal table contains the desired values instead of type-specific initial values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can you use the VALUE #( ) expression to fill an internal table in ABAP?

A

You can use the VALUE #( ) expression directly in the APPEND statement to add rows to the internal table without needing a work area.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the CORRESPONDING operator do in ABAP?

A

It copies data between identically-named fields of two internal tables, creating new rows in the target table and filling fields with type-specific initial values when necessary.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you handle runtime errors when using key access to retrieve rows from an internal table?

A

You can handle runtime errors, such as CX_SY_ITAB_LINE_NOT_FOUND, using a TRY … CATCH … ENDTRY structure to avoid program termination.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the purpose of the MODIFY TABLE statement in ABAP?

A

The MODIFY TABLE statement is used to write changes from a work area back into the internal table, overwriting the corresponding row based on key fields.
Key fields remain untouched.

Example:

DATA carriers TYPE STANDARD TABLE OF st_carrier
WITH NON-UNIQUE KEY carrier_id.
DATA carrier LIKE LINE OF carriers.

carrier = carriers[ carrier_id = ‘JL’ ].

carrier-currency_code = ‘JPY’.

MODIFY TABLE carriers FROM carrier.

14
Q

What limitation does MODIFY TABLE have regarding key fields?

A

MODIFY TABLE can only change non-key fields in the internal table; it does not support changes to key fields.

15
Q

How can you modify the contents of multiple rows in an internal table in ABAP?

A

You can implement a loop over the table, place each row into a work area, make changes, and then use MODIFY TABLE to write the changes back into the internal table.

Example:

DATA carriers TYPE STANDARD TABLE OF st_carrier
WITH NON-UNIQUE KEY carrier_id.

DATA carrier LIKE LINE OF carriers.

LOOP AT carriers INTO carrier
WHERE currency_code IS INITIAL.

carrier-currency_code = ‘USD’.

MODIFY carriers FROM carrier.

ENDLOOP.

16
Q

What difference does “MODIFY” make when compared to “MODIFY TABLE”?

A

When using only MODIFY, there is no distinguishment between key and non key fields. SO the entire row gets overwritten.

Example:
DATA carriers TYPE STANDARD TABLE OF st_carrier
WITH NON-UNIQUE KEY carrier_id.
DATA carrier LIKE LINE OF carriers.

carrier-carrier_id = ‘LH’.

MODIFY carriers FROM carrier INDEX 1.

17
Q

What is the purpose of using the TABLE addition in the SELECT statement in ABAP?

A

The TABLE addition is used when you want to store multiple records retrieved by the SELECT statement into a complex internal table.

Example:
SELECT
FROM …
FIELDS *
WHERE …
INTO CORRESPONDING FIELDS OF TABLE @”aliasNameInTheFieldList”

18
Q

How is the UNION directive used in ABAP SQL?

A

The UNION directive is used to combine the results of two or more SELECT statements into a single result set.

Example:

SELECT FROM
FIELDS
WHERE
UNION ALL
SELECT FROM
FIELDS
WHERE
INTO TABLE @DATA(Names)

19
Q

How does the SINGLE option affect the behavior of the SELECT statement in ABAP?

A

When using the SINGLE option, exactly one record is read from the database, even if more data exist that meets the conditions in the WHERE clause.

20
Q

What is the difference between UNION and UNION ALL in ABAP SQL?

A

UNION ALL combines the results of SELECT statements including duplicates, while UNION eliminates duplicates from the combined result set.

21
Q

What is the Difference Between TYPE, TYPE TABLE OF, and TYPE REF TO

A

TYPE:
Defines a single data type.

TYPE TABLE OF:
Defines a table type representing a table structure template.

TYPE REF TO:
Defines a reference type holding a reference to an object in memory.

22
Q

You want to read data from two database tables so that the SELECT statement returns a single result set that contains no duplicate entries. Which of the following techniques would you use?

INNER JOIN
UNION
UNION ALL
LEFT OUTER JOIN

A

UNION

23
Q

Which of the following can you use to fill an internal table?

VALUE#( )
APPEND
LOOP ENDLOOP
READ

A

VALUE#()
APPEND

24
Q

The type tt_table is defined as follows: TYPES tt_table TYPE STANDARD TABLE OF st_connection WITH NON-UNIQUE KEY carrier_id connection_id. Which DATA statement would you use to create an internal table with this type?

DATA table TYPE TABLE OF tt_table.
DATA table TYPE tt_table.
DATA table TYPE REF TO tt_table.

A

DATA table TYPE tt_table.

25
Q

Which of the following statements is true for a standard internal table?

The key is always unique

The key is always non-unique

You can choose whether the key should be unique or non-unique

A

The key is always non-unique

26
Q
A