Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP internal table

Former Member
0 Kudos


Is it possible to use MODIFY statement on an internal table with no entries?

Modify itab index 1 from wa1.

Above statement is not populating itab even though entries r there in wa1.

Thanks,

Tanvi

4 REPLIES 4

former_member191806
Active Participant
0 Kudos

The MODIFY statement changes an existing row in the internal table (like an UPDATE SQL statement). Please check the ABAP help.

http://help.sap.com/saphelp_erp60_sp/helpdata/en/fc/eb35eb358411d1829f0000e829fbfe/content.htm

https://help.sap.com/saphelp_45b/helpdata/en/34/8e72f96df74873e10000009b38f9b8/content.htm

In order to insert a new row in your table, use INSERT or APPEND statements.

J_OWENS
Explorer
0 Kudos

Hi,

The given statement will not work because the index 1 doesn't exist in an empty internal table.

And I'm wondering why this statement didn't cause any dump, as you are trying to access/modify a location that does not exist.

And we can modify an internal table with respect to a key or index. But in an empty internal table there is  no key/index available to compare and modify.

If we want to know the internal table is empty or not, we can read the table with index 1 or key( if you want to check the existence of a particular entry .) Then perform the further processing according to the value of sy-subrc.

Regards

Jesse Owens K

0 Kudos

It does not create a dump because it simply sets sy-subrc to 4 if it cannot find the specified table line. To better test if the table is empty, we can either use:

itab[] IS INITIAL

or

lines( itab ) = 0

BR,

Serban

former_member210621
Participant
0 Kudos

Hi,

You internal table is empty and you are trying to modify internal table with work area. As the table is empty, it should add records to internal table from work area. It is not populating any record to internal table because you are using 'Index' clasue in modify statement. Here, there is no index as internal table is initial. Try to remove 'Index' from that statement.