You are on page 1of 22

from VIDHAI TECH.

Knowledge Repository

Internal Table

1. What is structure?
 Structure is a data object.
 That is made up of components of any data type.
 Stored one after the other in the memory.
 A structure may have only a single record at run-time.
 But a table can have many records.

2. How to define structure?


 Structured type or structure is created using the additions BEGIN OF…
END OF
 Additions of the statements TYPES, DATA etc.
 They can also be created dynamically using RTTC (run time type creation)
methods.

3. What is global structure (Standard) and Local structure where it can be


defined?
i. Local structure can be created in ABAP programs and only within the
program.
ii. Global structure can be created in the data dictionary and can be
reusable in different objects.

4. Components of structure.
 Structure is a data object that is made up of components of any data type stored
one after the other in the memory.
from VIDHAI TECH. Knowledge Repository

5. About Work area?


 Internal tables are used to obtain data from a fixed structure for dynamic use
in ABAP. Each line in the internal table has the same field structure.
 The main use for internal tables is for storing and formatting data from a
database table within a program.

6. Difference between structure and work area.

Structure Work area


Structure does not contain any data. Work area contains only single record of
that structure.

But structure is defined in the data They should have the same format as any of
dictionary and can be used in both data the internal tables.
dictionary as well as in program.

Work area is also a type of structure.

It is used to process the data in an internal


table one line at a time.

7. Difference between DATA and TYPES.


 TYPES statement defines the structure without allocation of memory,
 DATA statements allocate the memory at runtime.
 Create a structure by using types statement and refer it by using the DATA
statement.
from VIDHAI TECH. Knowledge Repository

8. Difference between TYPE and LIKE.


 The keywords TYPE and LIKE in ABAP are used to refer to a
particular data type,
 TYPE is a keyword used to refer to a data type
 LIKE is a keyword used to copy the properties of already existing data
object.

9. What is Internal Table?


 SAP ABAP internal table is a dynamic sequential dataset
 All records have the same structure and a key. ...
 The data type of an internal table is fully specified by its line type, key,
and table type.
 There are two types of internal table. They are –
i. Indexed table and
ii. hashed table
In indexed table:
1. Standard Tables,
2. Sorted Tables
 Internal table takes data from a fixed structure and stores it in working
memory in ABAP.
 The data is stored line by line in memory.
 And each line has the same structure.
from VIDHAI TECH. Knowledge Repository

10.Attributes of internal table.


 Line type
 Key type
 Table type

11.Types of internal table.


 There are two types of internal table. They are –
1. Indexed table and
2. hashed table
 In indexed table:
i. Standard Tables,
ii. Sorted Tables
12.Advantages of internal table.

 Internal table with header line allows us to pass data directly into body of
internal table.

 No need to create a explicit work area for our table.

 We can directly use same name [table name] for both header n body of that
table.

 Internal table without header line is better compared to performance wise.


from VIDHAI TECH. Knowledge Repository

13.Limitation of internal table.


 Internal tables are used to obtain data from a fixed structure for dynamic
use in ABAP.
 Each line in the internal table has the same field structure. The main use
for internal tables is for storing and formatting data from a
database table within a program.

14.About Database table.


 Types: Transparent table
Pooled table
Cluster table

15. Operations of Internal table.


 Filling the internal table
 Insert and append.
 Sorting the internal table
 Ascending and descending.
 Changing the internal table
 Update and modify.
 Retrieving the internal
 Read.
from VIDHAI TECH. Knowledge Repository

16.Explain With header line and without header line in internal table.

Internal Tables with Header Line Internal Tables without Header Line

 Here the system automatically Here there is no work area associated


creates the work area. with the table.

 The work area has the same data  Work area is to be explicitly
type as internal table. specified when we need to access
such tables.

 This work area is called the  Hence these tables cannot be


HEADER line. accessed directly.

 It is here that all the changes or


any of the action on the contents of
the table is done. As a result of
this, records can be directly
inserted into the table or accessed
from the internal table directly.

17.What is line type, key and table type?

 A Table Type in SAP ABAP is a global reusable object which is used to define
structure and functional attributes of an internal table in ABAP.

A table type is defined by:

 Line Type: It defines the structure and data type.


from VIDHAI TECH. Knowledge Repository

 Access Mode: kind of internal table e.g. Sorted, Hashed, Indexed.


 Keys: Primary & Secondary keys of the table.

Advantages of Table Type in SAP ABAP:


 For an Internal table, you might need to create a local structure using
types, state its type, and state its other properties.
 By using table types, we need to just declare the internal table of type
Table Types, rest will be taken care by the table types.
 Being a global object, it can be reused.

18.What are the types of KEY in internal table?

 Unique key
 Non-unique key.
from VIDHAI TECH. Knowledge Repository

19.Difference on unique and non-unique key.

UNIQUE KEY NON-UNIQUE KEY


 A unique key would be helpful in  Whereas, a non-unique key would
determining a single record from the not be able to distinctly find out a
internal table while performing a specific single record for the search
search using that key. that is made using that key.

 In a table which uses a non-unique


key Read statement would pick the
first record which shall validate the
search criteria.

20.STANDARD and SORTED tables are Indexed table.

21.How to add new records in sorted internal table?


By using the INSERT statement records can be added in sorted table.

22.Difference between APPEND and INSERT statement.

APPEND INSERT

 Append is statement which is used  Insert is a statement which is


to add a record at bottom of used to insert a record at a
internal table from work area. specified position of an
internal table from work area.
from VIDHAI TECH. Knowledge Repository

23. How to read records from internal table?

 Two statements are commonly used to read the data from an internal table.
Loop at
 Loop at is used to read multiple rows from the internal table.

Read table
 Read table is used to read a single row.

To read some or all rows from an internal table, you can use the loop at statement. loop at
reads the contents of the internal table, placing them once at a time into a work area.

24. Additions in WRITE statement.


 Quick info
 No-gap
 Under
25.What are the formatting statements?

The WRITE statement is a formatting statement used to display data on a screen.


There are different formatting options for the WRITE statement. The syntax of the
WRITE statement is -
WRITE <format> <f> <options>.

26.Difference between SKIP and SY-VLINE.

 SKIP positions the list cursor in a line of the current list.


from VIDHAI TECH. Knowledge Repository

 It is used to insert blank lines in between the output lines.

 SYVLINE is a standard DATA Element within the SAP ABAP dictionary and is
associated with fields that store Vertical Line information.

27.Difference between SKIP and ULINE.

SKIP
 Positions the list cursor in a line of the current list.
Uline:
 Uline is used to draw a horizontal line on the screen.
 Uline can be used with length & position specification.
 Uline cannot be used inside write statement.
 Uline is itself a statement.

28.What are the various SYSTEM FIELDS in ABAP?


 sy-datum : current system date will appear.
 sy-tabix : current line of the internal table.
 sy-uline : Horizontal line
 sy-vline :Vertical line
 sy-uzeit : system time will appear.

29.How will you check whether ITAB has records?


Using Is initial we can check whether itab has records or not.
from VIDHAI TECH. Knowledge Repository

30.How to order records in internal table?

Records in internal table can be ordered using SORT (Ascending or Descending).

31.How to delete records and internal table?

 The DELETE statement is used to delete one or more records from


an internal table. The records of an internal table are deleted either by
specifying a table key or condition or by finding duplicate entries.

32.How many WRITE statement can be used in an internal table?


There is no limit for write statement in the program.

33.What is SY-DATUM and SY-UZEIT?


sy-datum : it declare the current system date
sy-uzeit : it declare the current system time.

34.Difference between SY-INDEX and SY-TABIX.

Sy-TABIX SY-INDX
SY-TABIX is a system variable which SY-INDEX is a system variable which acts
stores the index current processing as a loop iteration counter, it stores loop
record of an internal table. iteration number.

So when you are looping over an internal table, you use SY-TABIX.
from VIDHAI TECH. Knowledge Repository

35.How to print in new line?

 The statement NEW-LINE is executed implicitly at the end of an event


block.
 The addition NO-SCROLLING has the effect that the first line of the current
list level written after the statement NEW-LINE using an output statement
( WRITE or ULINE) cannot be moved horizontally.
36.About MODIFY statement in internal table.

 Change the value of a specific field within that internal table with and without a
header line.

 With and without specifying the index of the record being updated and do you
need to use the INDEX addition.

37.CLEAR, REFRESH and FREE in internal table.

 Use CLEAR and FREE for workarea, and REFRESH and FREE for internal
table.

 Clear deletes the content of a work area, REFRESH deletes the lines of an
internal table.

 Now, the difference between FREE and the others, is in the fact that FREE
liberts memory that was allocated for the internal table or workarea also.

 Instead, CLEAR and REFRESH only clear/delete it's contents.

 Use FREE if you won't need an internal table/work area more in the program.
from VIDHAI TECH. Knowledge Repository

38.ITAB [] denotes.

 Body structure of the internal table.

39.How to read single record in internal table?

 Select Single is used to read a single first matching line from the
database table and not from the internal table.
Ex: SELECT SINGLE * FROM MARA INTO WA_MARA WHERE MATNR =
'000001'.

40.How to insert records in certain position of the internal table?

INSERT line INTO itab [INDEX idx].

41.Whether duplicate records can be accepted in STANDARD internal table.

Yes, duplicate records can be accepted in STANDARD internal table because it is a


NON-UNIQUE key.

42.Whether duplicate records can be accepted in SORTED internal table.

No, duplicate records cannot be accepted in SORTED internal table.

43.What are the coding standards to be followed while writing ABAP program?
Follow the Naming Conventions as per the requirement and standards.
44.What is control level statement?
 At first
 At new
 At end of
 At last
from VIDHAI TECH. Knowledge Repository

45.What AT FIRST and AT NEW will do?

 AT FIRST - This statement is executed/triggered for the first iteration


of loop (SY-TABIX = 1).
 AT NEW - This is executed whenever there is a new value on
specified field.

46.What AT LAST and AT END OF will do?

 AT LAST - This statement is executed / triggered for the last iteration of loop.
 AT END OF - This statement is executed whenever the new value ends on
specific field.

47.What COLLECT statement will do?


Syntax: COLLECT wa INTO itab [result].
 This statement inserts the content of a work area either as a single row
in an internal table or adds the values of its numeric components to the
corresponding values of existing rows with the same primary table key.

48.What SUM will do?


 The statement SUM can only be specified within a loop starting
with LOOP, and is only respected within a AT-ENDAT control
structure.
from VIDHAI TECH. Knowledge Repository

 Prerequisites for using the statement SUM include using the


addition INTO in the LOOP statement, and that the specified work
area is compatible with the row type of the internal table.
 In addition, SUM cannot be used when the row type of the internal
table contains components that are tables.

49.Explain about CHECK, CONTINUE, EXIT and RETURN.

 EXIT: The behavior of EXIT keyword is depends on where you use it.

 If you use EXIT keyword inside IF .. ENDIF., it will comes out of the program.
 If you use EXIT inside LOOP .. ENDLOOP., it will come out of loop.
 If you use EXIT inside FORM .. ENDFORM., it will comes out of form (

 CONTINUE is a statement, which is used to skip execution of a record


inside loop..endloop, do..endo, while..endwhile etc. This keyword will only
be used in loops.
 RETURN is a statement which is used to stop processing of current block
immediately.
 CHECK statement terminates a loop pass based on a condition.
If the condition in the CHECK statement is evaluated to false then all the
remaining statements in the statement block after the CHECK statement are
ignored, and the next loop pass starts.
The condition in the CHECK statement can be any logical expression.

50.Where the outputs are printed/displayed?

Outputs are printed using WRITE statements.


from VIDHAI TECH. Knowledge Repository

51.How many LOOPs can be used in a program?

Loop can be used maximum number of times in a program.

52.How will you apply conditions to the program?

Conditions can be applied using WHERE condition in query.


53.What PRETTY PRINT will do?

 Pretty Printer helps to standardize the layout of the program.

54.What is the first statement of the ABAP Program?


Report <program name>.
55.What is the prerequisite of using AT LEVEL statements?

 Should be used within loop statement


 Is initial
56.What is the prerequisite of using READ statement?
 Sort the record.
 And apply sy-subrc, whether the record is found or not.

57.What APPEND LINES OF will do?


 This method of appending lines of one table to another is about 3 to 4 times faster
than appending them line by line in a loop.
 After the APPEND statement, the system field sy-tabix contains the index of the
last line appended.
 When you append several lines to a sorted table, you must respect the unique key (if
defined), and not violate the sort order. Otherwise, a runtime error will occur.
from VIDHAI TECH. Knowledge Repository

58.What is INSERT LINES OF?

 The INSERT statement allows you not only to insert lines in any type of internal
table, but also to change them using a line index. You can insert either a single line
or a group of lines into index tables using the index.

59.Explain on CORRESPONDING FIELDS OF.

 Select into corresponding is used to get data from a database table into a user
defined internal table or work area without specifying the list of fields.

 Syntax: SELECT * FROM <DATABASE TABLE>INTO CORRESPONDING


FIELDS OF TABLE <INTERNAL TABLE>

60.Additions in READ Statement.

 The addition INTO assigns the content of the found row to a work area. This
addition can be used regardless of which way itab is specified.

 The addition ASSIGNING assigns the found row to a field symbol <fs>. This
addition is possibly only if an existing internal table is specified for itab.

 The addition REFERENCE INTO creates a reference to the found row in a


reference table. This addition is possibly only if an existing internal table is
specified for itab.

 The addition TRANSPORTING NO FIELDS specifies that only the relevant


system fields are filled. This addition can be used regardless of which way itab is
specified.
from VIDHAI TECH. Knowledge Repository

61.How will you assign fields or values in program?

 To assign fields or values in a program by using this syntax.

DATA: BEGIN OF ty_struc,


a TYPE i VALUE 3,
c TYPE c VALUE ‘S’,
END OF ty_struc.

62.What MOVE statement will do?

 Obsolete form of the assignment of data objects and reference variables source to
target variables destination.
 If EXACT is specified, only data objects can be specified for source.
 MOVE is used to store the values from one structure/variable to another
structure/variable.

63.How to find the total no. of records present in an internal table?

DATA : V_LINES TYPE I. "declare variable

DESCRIBE TABLE <ITAB> LINES V_LINES. "get no of rows

WRITE:/ V_LINES. "display no of rows

64.How to find the type of an internal table?

 ‘Describe’ keyword is used to describe the internal table.


 In describe one of the type is KIND, to identify the type of the internal table
such as (Standard, Sorted or Hashed ) table.
from VIDHAI TECH. Knowledge Repository

65.How do you delete duplicate records in internal table?

 Delete adjacent duplicates from itab comparing <field list>.

 You can do away with the comparing addition if you want to compare all the
fields for duplicate values...this way the duplicates for exactly same rows will be
deleted.

66.Every Statement in ABAP program will starts with REPORT KEYWORD

67.ON CHANGE / END ON Statement.

 ON CHANGE OF <field>' is the similar as 'AT NEW <field>'.

 We should use 'AT NEW' within the loop and for single field only.

 But we can use ON CHANGE OF outside of the loop and it allows multiple fields
also.

 After ON CHANGE OF, any number of data objects dobj1, dobj2... of any data
type can be added, linked by OR.

68.How will you read particular records in the internal table?

 Data can be read from an internal table using the following 2 statements.
READ TABLE Used to read single row.
LOOP AT / ENDLOOP Used to read multiple rows.

 READ TABLE [INTO Workarea] [INDEX |WITH KEY]


from VIDHAI TECH. Knowledge Repository

 loop at itab where sy-tabix < 3.


write:/ itab-field1, itab-field2.
endloop.

69.How to display first 2 records from the internal table?

Data: itab type mard occurs 1 with HEADER LINE.


select * from mard into table itab UP TO 2 ROWS.
DESCRIBE TABLE ITAB LINES N.
loop at itab .
WRITE SY-TABIX.

70.What SY-SUBRC will do?


 SY-SUBRC is a system component which contains return value which is set
by ABAP statements.
 Generally, when the SY-SUBRC equals to '0' means that the
ABAP statement has been executed successfully.
 If the value is other than '0' means that the statement has raised an error or
warning.

71.Purpose of COMMENT statement and its type.

 Comments are texts that you can write between the statements of your ABAP
program to explain their purpose to a reader. Comments are distinguished by the
preceding signs * (at the beginning of a line) and " (at any position in a line).
from VIDHAI TECH. Knowledge Repository

72.How to suppress zero’s in the output?

Data : number(8) type n,


ch(12) type c.
ch = number.
condense ch.
SHIFT ch LEFT DELETING LEADING '0'.

73.Difference between SKIP and SKIP to <n>.

74.READ TABLE itab { table_key


| free_key
| index } result.
Explain.

READ TABLE <ITAB> WITH KEY


This statement always search in linear fashion.
You can use this syntax for any type of table(standard, sorted, hased).

READ TABLE WITH INDEX


from VIDHAI TECH. Knowledge Repository

 If the addition INDEX is used, the statement READ reads the row of the row
number specified in index with respect to a table index.

 The addition INDEX can only be specified for index tables and determines the row
to be read from the primary table index.

READ TABLE <ITAB> WITH TABLE KEY


Use this syntax only for internal table with primary keys defined.
For standard table - Linear search will be used.
For sorted table - Binary search will be used.
For Hashed table - Hashing algorithm will be used.

You might also like