Skip to Content
Personal Insights
Author's profile photo Anuja Kawadiwale

Getting Started with ABAP: How to Create Table Type and Deep Structure

This is the next blog post in this series. Here is the previous blog post Getting Started with ABAP: How to Create Flat and Nested Structure

In the previous blog post, we learned types of structure and how to create flat and nested structure.

In this blog post we will learn how to create table type and deep structure.

What is Table Type?

Table type is a global object which is used to define structure and functional attributes of an internal table in ABAP.

What is Internal Table?

An internal table is a dynamic data object which holds the runtime data in the form of table. It is a temporary table gets created in the memory of application server during program execution and gets destroyed once the program ends.

Data type of Internal Table

Data type of an internal table is specified by its line type, key and table type.

Line Type

The line type of an Internal table can be any data type which can be structure, a table, an internal table or any data type.

Key

Keys are the one which uniquely identifies the row.

Table Type

The table type determines how ABAP will access individual table entries.

There are three types of Internal Table.

1.Standard Internal Table

2.Sorted Internal Table

3.Hashed Internal Table

How to Create Table Type

Step 1: Go to SE11 and enter name of table type. Click on Create.

Step 2: Select Table Type.

Step 3: Enter short description.

Step 4: In Line Type can be structure, table or any data type.

I am using table which is created earlier.

Step 5: Save and Activate it.

Here Table type is created.

How to Create Deep Structure

Step 1: Go to SE11 and click on data type. Enter the name of table type ZAK_TT_Test.

Step 2: Click on Create. Select Structure.

Step 3: Press Enter and give short description. Enter component name, typing method as types and component type as table type which is created earlier.

Step 4: Save and Activate it.

In this way you can add more component as per requirement.

Here we have completed the Table Type and Deep Structure.

Here you can check next blog post Getting Started with ABAP: How to Create Database View Part 1

Follow my profile to be notified of the next blog post. Please feel free to ask any questions you have in the comments section below.

 

 

Assigned Tags

      13 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Matthew Billingham
      Matthew Billingham

      Key

      Keys are the one which uniquely identifies the row.

      Wrong. E.g. DATA stuff TYPE SORTED TABLE OF some_type WITH NON-UNIQUE KEY a b c. It has keys a, b and c, but they are not required to be unique. More than one record can have the same key.

      Also your understanding of the enhancement category is not quite correct. You can create a deep structure quite happily with, for example, "Cannot be enhanced", and modify the structure (add components) to the structure via SE11 at any time.

      https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenddic_structures_enh_cat.htm

       

      Author's profile photo Anuja Kawadiwale
      Anuja Kawadiwale
      Blog Post Author

      Hi Matthew,

      As you mentioned a,b,c not unique but the a,b,c here we can say that it is composite key that means combination of a b c uniquely identifies the row.

      Regarding enhancement category, i have not mentioned that you can not create a structure with cannot be enhanced. You can create it. Where did i mentioned you cannot create ?. I want my structure to be enhance hence i selected it.

      And it shows warning message if you dont select enhancement category can be enhance.

      Author's profile photo Matthew Billingham
      Matthew Billingham

      As you mentioned a,b,c not unique but the a,b,c here we can say that it is composite key that means combination of a b c uniquely identifies the row.

      No, it doesn't. Here's a sorted table with a non-unique key a b c

      a b c data
      some else thing a bit of data
      something something else and another thing some data
      something something else and another thing more data
      somewhat somehow say whut yet more

      Rows 2 and 3 have identical keys.

      data(a_row) = my_table[ a = 'something' b = 'something else' c = 'and another thing' ].

      may return row 2 or 3. This is because the key manifestly does not uniquely identify the row.

      Concerning enhancement, your step 4 chooses "Can be enahanced (deep)". For a newbie i would find this implies I must use that category for a deep structure. So maybe you do understand it, but your example misleads, exactly has https://people.sap.com/sandra.rossi pointed out for your last blog.

      I understand that your series is to take people from begin to end to start ABAP, but people might also later read only one blog post to answer their question how to create a structure, and they might be mislead because they could think it's the only way to create a structure

      It's admirable to produce a series of blogs for newbies like this, if it misleads or confuses, then it rather defeats the point, I'm afraid.

      By the way, if you click on reply rather than add comment, I'll be notified that you've responded. Otherwise I'm not.

      Author's profile photo Anuja Kawadiwale
      Anuja Kawadiwale
      Blog Post Author

      Hi Matthew,

      Regarding Key, We can say that it is a duplicate data and internal table can have it but the database data with key can not have duplicate data. In case of Non Unique Key, meaning of key will remain same but non unique make it difference. Yesterday, I read SAP document and confident with the definition of Key and non unique key.

      Regarding my blogs, is it misleading ? Tell me where it is except Key.

      Comment on that particular blog where I have mentioned misleading or wrong information.

      For your information, where Sandra mentioned some changes in my blog and even i felt that changes should be done. Immediately I update my blog post. Still you are referring the same thing.

      You just mentioned the previous comment. Did you read my comment ? I don't think so.

      Also, the way you find wrong things also try to find good things from the blog post.

      Author's profile photo Matthew Billingham
      Matthew Billingham

      I have read your comment. There are two issues with your blog.

      1. Keys are the one which uniquely identifies the row.

      This is not correct. In my example, the same key identifies two different rows. That fact that you can't do this in a database table is irrelevant since we're talking about internal table definition.

      In my example, the key does not uniquely identify the row.

       

      2. I think step 4 is misleading. It certainly gave me the initial impression that you don't understand enhancement categories quite right.

      You chose an enhancement category of "Can be enhanced (deep)". But you do not mention that other enhancement categories could be used. To my mind this could mislead a newbie into thinking that for a deep structure (which is what your blog is about), you must use this enhancement category.

      Of course you could choose "Cannot be enhanced".

      Your blog would be improved if you had a little explanation of what enhancement category is about. The same applies to your previous blog on the same subject.

      I'm sorry you don't like my criticism. I'm not trying to tear you down, I'm trying to be constructive. If you make factual errors, or part of your blog is misleading or confusing, I'm going to tell you. If you check out some of my blogs you'll see people disagree with me, and have pointed out errors. Which I then humbly fix.

      Author's profile photo Anuja Kawadiwale
      Anuja Kawadiwale
      Blog Post Author

      Hi Matthew,

      Regarding Key, I already said in internal table having data with same key that is duplicate data.

      Regarding enhancement category, enhancement itself different topic I don't want to start that topic right now. That's why I didn't write about it. But sure once I started write on enhancement topic I will cover it.

      On criticism, I didn't say don't criticize or don't say anything. If i have written anything wrong you can say that it is wrong but sorry on the keys I am not agree with you.

      I  am saying the way you take efforts to correct the post that way take efforts to find good things from the blog post.

      Author's profile photo Matthew Billingham
      Matthew Billingham

      Clearly unique has a unique meaning to you then, if it allows for two things that are the same to be unique.

      If I find something good to say about your blogs, I will.

      Author's profile photo Anuja Kawadiwale
      Anuja Kawadiwale
      Blog Post Author

      Till now if you did not find anything good then you should have found wrong things. Then go ahead there are 7 blogs more to comment.

      Author's profile photo Matthew Billingham
      Matthew Billingham

      I've read them. They've been fine.

      Author's profile photo Matthew Billingham
      Matthew Billingham

      One more thing that you could mention. Enhancement category only has an effect on objects that you can't change yourself (without repairing the object), but you might enhance using the enhancement framework.

      So that's SAP structures and database tables, also third party structures and database tables with their own namespace.

      For Z/Y objects, there's no real purpose to setting the enhancement category, except to get rid of the warning if it isn't set.  This is because (authorisations notwithstanding) you can edit any Z/Y structure or table directly. You never need to enhance it.

      Enhancement is for SAP and Third Party sturctures and tables.

       

      Author's profile photo Anuja Kawadiwale
      Anuja Kawadiwale
      Blog Post Author

      Hi Matthew,

      I agree what you have mentioned on enhancement category. I have done the changes.

      Thanks.

       

      Author's profile photo Sandra Rossi
      Sandra Rossi

      You talked about 3 types of table types, standard, sorted and hashed, but there's nothing in your blog post, how to define this type. Is it something you will talk in another blog post? Could you explain what it means and how to choose one? Note that this is explained in the ABAP documentation, so you might add a link.

      Also, here, you're talking only about the ABAP Dictionary, but most of the time I declare table types and structures in classes and interfaces. The people could think that the ABAP Dictionary is the only way.

      Author's profile photo Anuja Kawadiwale
      Anuja Kawadiwale
      Blog Post Author

      Hi Sandra,

      I just mentioned the types of internal table. But i want to explain it when we actually use it in program. I think people understand this types when they actually use it in program.

      They will get know why we are using it. If I explain it in just words I don't think they will understand it.

      Regarding the structure at starting of the blog post on structures I have mentioned that we can create structure through ABAP programming also and that part will cover once programming is started.