Application Development and Automation 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: 
Read only

A type table as a row in a table

Former Member
0 Likes
4,049

The question is simple. Can I use a type table into a Z table ?? Any way to do this ??

Thanks in advance.

The question is simple. Can I use a type table into a Z table ?? Any way to do this ??

Thanks in advance.

12 REPLIES 12
Read only

Former Member
0 Likes
2,393

hi,

type table means structure?

if it is structure then u can add this to ztable in append structure.

regards,

Swamy

Read only

Former Member
0 Likes
2,393

hi maraia,

Structures

A structure is a sequence of any other data types from the ABAP Dictionary, that is, data elements, structures, table types, or database tables. When you create a structure in the ABAP Dictionary, each component must have a name and a data type.

In an ABAP program, you can use the TYPEaddition to refer directly to a structure.

If you define a local data type in a program by referring to a structure as follows:

TYPES dtype TYPE structure.

the construction blueprint of the structure is used to create a local structure dtype in the program. The predefined Dictionary data types of the domains used by the data elements in the structure are converted into the corresponding ABAP types. The semantic attributes of the data elements are used for the corresponding components of the structure in the program. The components of the local structure dtype have the same names as those of the structure in the ABAP Dictionary.

To ensure compatibility with previous releases, it is still possible to use the LIKE addition in an ABAP program to refer to a structure in the ABAP Dictionary (except in classes).

Suppose the structure STRUCT is defined as follows in the ABAP Dictionary:

Field name

Type name

Short Description

COL1

CHAR01

Character field with length 1

COL2

CHAR08

Character field with length 8

COL3

CHAR10

Character field with length 10

The types CHAR01 to CHAR10 are data elements with corresponding domains. We can refer to this structure in ABAP:

TYPES struct_type TYPE struct.

DATA wa TYPE struct_type.

wa-col1 = '1'.

wa-col2 = '12345678'.

wa-col3 = '1234567890'.

This program creates a local structure in the program - struct_type - and a corresponding data object wa. We can address the components using the component names from the original structure.

Table types

Table types are construction blueprints for internal tables that are stored in the ABAP Dictionary. When you create a table type in the ABAP Dictionary, you specify the line type, access type, and key. The line type can be any data type from the ABAP Dictionary, that is, a data element, a structure, a table type, or the type of a database table. You can also enter a predefined Dictionary type directly as the line type, in the same way that you can with a domain.

In an ABAP program, you can use the TYPEaddition to refer directly to a table type.

If you define a local data type in a program by referring to a table type as follows:

TYPES dtype TYPE table.

the construction blueprint of the table type is used to create a local internal table dtype in the program. The predefined Dictionary data types of the domains used by the data elements in the structure are converted into the corresponding ABAP types. The semantic attributes of the data elements are used for the corresponding components of the internal table in the program.

Suppose the table type STRUCT_TABLE is defined in the Dictionary with the line type STRUCT from the previous example. We can refer to this in ABAP:

TYPES table_type TYPE struct_table.

DATA: table_wa TYPE table_type,

line_wa LIKE LINE OF table_wa.

...

LOOP AT table_wa INTO line_wa.

...

WRITE: line_wa-col1, line_wa-col1, line_wa-col1.

...

ENDLOOP.

This program defines an internal table type table_type . From it, we define data objects table_wa and, consequently, line_wa. line_wa corresponds to the line type of the table type in the Dictionary, and is therefore compatible with the structure STRUCT

Type Groups

Before Release 4.5A, it was not possible to define standalone types in the ABAP Dictionary to which you could refer using a TYPEaddition in an ABAP program. It was only possible to refer to flat structures. Structures in programs corresponded to the structures of database tables or structures in the ABAP Dictionary. In ABAP programs, you could only refer to database tables and structures in the ABAP Dictionary using LIKE. It was, however, possible to refer to individual components of the Dictionary type. Complex local data types such as internal tables or deep structures had no equivalent in the ABAP Dictionary. The solution to this from Release 3.0 onwards was to use type groups. Type groups were based on the include technique, and allowed you to store any type definitions globally in the Dictionary by defining them using TYPES statements.

The definition of a type group is a fragment of ABAP code which you enter in the ABAP Editor. The first statement for the type group pool is always:

TYPE-POOL pool.

After that, you define data types using the statement TYPES. It was also possible to define global constants using the CONSTANTS statement. All the names of these data types and constants must begin with the name of the type group and an underscore: pool_

In an ABAP program, you must declare a type group as follows before you can use it:

TYPE-POOLS pool.

if you want complete info just click

http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3138358411d1829f0000e829fbfe/content.htm

thanks

karthik

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 15, 2008 3:09 PM

Read only

Former Member
0 Likes
2,393

If you are trying to create nested structures in a table, it is not possible.

Regards,

Ravi kanth Talagana

Read only

0 Likes
2,393

What I want is to create a table type (which is not the same as an structure) into a Z table (Se11). Is that possible?? Thanks very much.

Read only

0 Likes
2,393

You can't create a table type in a database table, however you can use (create) a field (column) in a structure which refers to a table type.

Read only

0 Likes
2,393

I want to have for each row of a table Z a group of variables associated. I can not have an Internal table into another internal table. How can I do this ??.

Read only

0 Likes
2,393

Sounds to me that you want to create HEADER / ITEMS relationship.

So then create one header ZHEADER and ZITEMS table. Relationship will be based on the keyfield of the header which will be part of the Key of the ITEM table.

Is that what you want?

Correction: You can use internal table inside internal table in your coding....

Read only

0 Likes
2,393

That's correct. But I do not know the number of items(columns in second table) I should create. Should I have to create 40 just in case ??

Read only

0 Likes
2,393

How is it that you don't know the number of columns (fields) you have to define? When creating a db table, the (whole) idea would be to create a 'structure' for this (transparant) table in which all the fields are known at design time. It will not make any sense to create a table with 40 (why 40) columns if you don't know what these columns represent. Like is it a date, character field, numeric field etc.

I think you've lost me here. I don't know what you are trying to do, achieve. The first question was if it is possible to create table type in db table. But it seems to me now, that this is not really the issue anymore.

If you can,please elaborate on requirement.

Read only

0 Likes
2,393

I don't know the exact number of variables because they are all the same type. Probably, in some cases are 5 but other rows in table would need more than 5. It depends on the row. That's why I need something 'dynamic' if it is possible. I Thougth one table into another would resolve my problem but I am not sure about that. I didn't want to create two tables with the same key table to link them.

Example :

Table:

row 1:

Number of order - 4-key

begda - 01.01.2008-key

endda - 31.12.2008-key

categories - 1,4,6,7,3,8 -> The thing would be to use a second table here or something similar.

row 2:

Number of order - 6-key

begda - 01.01.2008-key

endda - 31.12.2008-key

categories - 1,5

Read only

0 Likes
2,393

If I understand correctly than you should create one Z-table Header (SE11) with following columns:

Number of order - 4-key (key field).

begda - 01.01.2008-key

endda - 31.12.2008-key

In the second (Items, or better categories) Z-table the following columns.

Number of order - 4-key

begda - 01.01.2008-key

endda - 31.12.2008-key

categories key.

This way you can have SEVERAL categories for ONE row in the header table.

This doesn't mean you have to create a new column for every categorie, but a new row (entry) per categorie.

Read only

Former Member
0 Likes
2,393

Hi Maria,

Can you please make the question clear.

You wanted to ask whether we can insert a structure into a Ztable or a table type i.e, do you want to include internal table into the Ztable.

If u can make it clear I can definetely help you out.

Regards,

AMK.