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

Deep Structures

Former Member
0 Likes
1,407

Hi experts,

Pls tell me how to create deep structures and use them in the program with an example?Urgent.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 14, 2008 5:47 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,143

hii,

structures containing internal tables as components or

Internal table containing Structure as components are called Deep Internal table.

Please check this link for reading a deep structure.

Example:

TYPES: BEGIN OF TYPE_DEEP,

MATNR TYPE MATNR,

T_MARC TYPE MARC OCCURS 0,

END OF TYPE_DEEP.

DATA: T_DEEP TYPE STANDARD TABLE OF TYPE_DEEP.

DATA: WA_DEEP TYPE TYPE_DEEP.

DATA: T_MARC TYPE TABLE OF MARC.

DATA: S_MARC TYPE MARC.

Populating data.

WA_DEEP-MATNR = 'TEST'.

S_MARC-MATNR = 'TEST'.

S_MARC-WERKS = '9090'.

APPEND S_MARC TO T_MARC.

Append second level internal table.

WA_DEEP-T_MARC] = T_MARC[.

Append.

APPEND WA_DEEP TO T_DEEP.

Process the internal table.

LOOP AT T_DEEP INTO WA_DEEP.

WRITE: / WA_DEEP-MATNR.

PROCESS the second level internal table.

LOOP AT WA_DEEP-T_MARC INTO S_MARC.

WRITE: S_MARC-WERKS.

ENDLOOP.

ENDLOOP.

See the information of Structure in the below link also...

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2fcc358411d1829f0000e829fbfe/content.htm

Hope it will solve your problem..

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 14, 2008 5:48 PM

8 REPLIES 8
Read only

Former Member
0 Likes
1,144

hii,

structures containing internal tables as components or

Internal table containing Structure as components are called Deep Internal table.

Please check this link for reading a deep structure.

Example:

TYPES: BEGIN OF TYPE_DEEP,

MATNR TYPE MATNR,

T_MARC TYPE MARC OCCURS 0,

END OF TYPE_DEEP.

DATA: T_DEEP TYPE STANDARD TABLE OF TYPE_DEEP.

DATA: WA_DEEP TYPE TYPE_DEEP.

DATA: T_MARC TYPE TABLE OF MARC.

DATA: S_MARC TYPE MARC.

Populating data.

WA_DEEP-MATNR = 'TEST'.

S_MARC-MATNR = 'TEST'.

S_MARC-WERKS = '9090'.

APPEND S_MARC TO T_MARC.

Append second level internal table.

WA_DEEP-T_MARC] = T_MARC[.

Append.

APPEND WA_DEEP TO T_DEEP.

Process the internal table.

LOOP AT T_DEEP INTO WA_DEEP.

WRITE: / WA_DEEP-MATNR.

PROCESS the second level internal table.

LOOP AT WA_DEEP-T_MARC INTO S_MARC.

WRITE: S_MARC-WERKS.

ENDLOOP.

ENDLOOP.

See the information of Structure in the below link also...

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2fcc358411d1829f0000e829fbfe/content.htm

Hope it will solve your problem..

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 14, 2008 5:48 PM

Read only

Former Member
0 Likes
1,143

Hi,

Deep structures containing internal tables as components.


data : begin of itab1 occurs 0,
          bukrs like bsis-bukrs,
         end of itab1.

data : begin of itab2 occurs 0.
          include strcuture itab1.
data : hkont like bsis-hkont.
data : end of itab2.

Now Itab2 is the deep structure.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,143

Hi Hosmath,

see below sample exmple program.

TYPES: BEGIN OF ITAB1.

INCLUDE STRUCTURE ZST7.

TYPES: END OF ITAB1.

DATA: ITAB2 TYPE ITAB1 OCCURS 0 WITH HEADER LINE.

SELECT * FROM ZST7 INTO TABLE ITAB2.

LOOP AT ITAB2.

WRITE: / ITAB2-GROSSVALUE.

ENDLOOP.

Now its ITAB2 called by Deep Structure.

<REMOVED BY MODERATOR>

Regards,

S.Suresh.

Edited by: Alvaro Tejada Galindo on Apr 14, 2008 5:48 PM

Read only

0 Likes
1,143

I got an idea how to use in the programs but can any body tell me the steps to create deep structures in SE11(Data Type)?

Read only

0 Likes
1,143

these are the steps to create deep structures

Procedure

In the initial screen of the ABAP Dictionary, enter the structure name in field Data type and choose Create.

A dialog box appears in which you must select the type category.

Select Structure and choose .

The maintenance screen for structures appears.

Enter an explanatory short text in the field Short text.

You can for example find the structure at a later time using this short text.

Carry out the following steps for all the components you want to insert in the structure.

You can also include structures, tables or views instead of individual components.

the link is

http://help.sap.com/saphelp_nw04/helpdata/en/90/8d7301b1af11d194f600a0c929b3c3/frameset.htm

The procedure here is described in Inserting an Include(internal table in case of deep structure).

Inserting an Include

Prerequisites

Only flat structures may be included in a table. No field refers to another structure in a flat structure. All the fields of a flat structure therefore refer either to a data element or were directly assigned a data type, field length and decimal places.

A field name may not have more than 16 places in a table. A structure therefore can only be included in a table if none of the field names of the structure are longer than 16 places.

Procedure

Place the cursor under the line in which you want to insert the include and choose Edit ® Include ® Insert.

A dialog box appears.

Enter the structure name. You can optionally enter a group name (see Named Includes) or a three-place suffix.

With the group name, you can access the fields in the include together in ABAP programs.

The suffix can be used to avoid name collisions between fields of the include and fields already in the table. The suffix is added to all the fields of the include, whereby the field name is first truncated if necessary.

Choose .

A line with .INCLUDE in the Fields field and the name of the include in the Field type field is inserted in the field maintenance screen for the table.

Select column Key if all the fields in the include should be key fields of the table.

The table key must be at the start of the field list. If you select column Key, you must insert the include after the last key field or between the existing key fields of the table.

If you do not select column Key, none of the included fields is a key field of the table.

Choose .

Result

The fields of the include are added to the table in the database. If you inserted the fields of the include as key fields, the primary index of the table is built again.

You can find information about the activation flow in the activation log, which you can display with Utilities ® Activation log. The activation log is displayed immediately if errors occur when the table is activated.

Other Options

You can display the fields contained in an include by placing the cursor on the line of the include and choosing . The fields of the include are now shown below this line. You can cancel this action with .

Enter a name in column Components.

If you want to insert the structure as an include in a transparent table at a later time, the component names may not be longer than 16 characters.

Enter the name of the type whose attributes should be used in the component in field Component name. You can enter any type (data element, structure or table type) here.

If you want to add components by entering the data type and length directly, choose Built-in type. You can now enter values for fields DTyp, Length, Dec.places, and Short description. With Component type you can switch back to the screen for entering references to existing types.

You can also enter a Reference Type in the Component Type field. If you enter a class, interface, or generic reference (ANY, OBJECT, or DATA) in the Component Type field, the R type field is set automatically. If you enter a reference type already defined in the Dictionary as a reference type, a blue arrow appears in the D type column.

If the type defined in the ABAP Dictionary or the built-in type is a reference type, set the indicator in the R Type column.

You can combine components with direct type definition and components that are defined by referencing an existing type as you like.

The reference field and reference table must be specified for components of type CURR (currency) and QUAN (quantity).

You can make these entries on the Currency/quantity fields tab page.

Now maintain the foreign keys of the structure.

Proceed as when maintaining the foreign keys of a table (see Creating Foreign Keys).

Choose Search Help, if you want to assign a search help to a structure field that points to a data element. Enter the name of a search help in the dialog box that appears. See Attaching a Search Help to a Table or Structure Field.

Save your entries once you have defined all the components of the structure.

You are asked to assign the structure a development class. You can change the development class later with Goto ® Change object directory entry.

Choose an enhancement category. For more information, see Structure Enhancements.

Choose

You can expand all the includes contained in a table with . Cancel this action with .

You can copy the fields contained in the include directly to the table with Edit ® Include ® Copy components. The fields of the include become table fields. They are no longer adjusted to changes in the include.

the link is

http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ebd6446011d189700000e8322d00/frameset.htm

Enter a name in column Components.

If you want to insert the structure as an include in a transparent table at a later time, the component names may not be longer than 16 characters.

Enter the name of the type whose attributes should be used in the component in field Component name. You can enter any type (data element, structure or table type) here.

If you want to add components by entering the data type and length directly, choose Built-in type. You can now enter values for fields DTyp, Length, Dec.places, and Short description. With Component type you can switch back to the screen for entering references to existing types.

You can also enter a Reference Type in the Component Type field. If you enter a class, interface, or generic reference (ANY, OBJECT, or DATA) in the Component Type field, the R type field is set automatically. If you enter a reference type already defined in the Dictionary as a reference type, a blue arrow appears in the D type column.

If the type defined in the ABAP Dictionary or the built-in type is a reference type, set the indicator in the R Type column.

You can combine components with direct type definition and components that are defined by referencing an existing type as you like.

The reference field and reference table must be specified for components of type CURR (currency) and QUAN (quantity).

You can make these entries on the Currency/quantity fields tab page.

Now maintain the foreign keys of the structure.

Proceed as when maintaining the foreign keys of a table (see Creating Foreign Keys).

Choose Search Help, if you want to assign a search help to a structure field that points to a data element. Enter the name of a search help in the dialog box that appears. See Attaching a Search Help to a Table or Structure Field.

Save your entries once you have defined all the components of the structure.

You are asked to assign the structure a development class. You can change the development class later with Goto ® Change object directory entry.

Choose an enhancement category. For more information, see Structure Enhancements.

Choose .

for clear expalnation

http://help.sap.com/saphelp_nw04/helpdata/en/90/8d7301b1af11d194f600a0c929b3c3/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ebd6446011d189700000e8322d00/frameset.htm

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 14, 2008 5:49 PM

Read only

0 Likes
1,143

Hi,

Goto SE11 and select datatype option and give ur own structure name and click create.

Then it ask for data element, structure and table type.

Select structure and press enter.

Then give short description and give the fields you wish to include in that structure.

If you want to include the fields from exiting structure then type ". INLCUDE" in Component column and name of the existing structure name in the Component type column.So that you can get all fields from existing structure.

<REMOVED BY MODERATOR>

Regards,

Raghu

Edited by: Alvaro Tejada Galindo on Apr 14, 2008 5:49 PM

Read only

0 Likes
1,143

In SE11 for datatype option, structure name..

When it ask for data element, structure and table type.

I think we need to Select table type for deep structures if we go by the explaination link provided by you..

Advise me..