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

Structure

Former Member
0 Likes
770

Hi all,

If it is not a flat structure. How can be used it? How to declare it?

Please give reply it.

thanks & regards

Venkat V G Murali Mohan M

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
744

If it is not a structure, it would be an internal table. Internal tables are used to hold more than one line of data.

There are several ways to declare it depending on your requirements.

e.g. an internal table with a line type of VBAK

Data: lt_vbak type table of vbak.

Field-symbols: <fs_vbak> type vbak.

select * from vbak into table lt_vbak

where (your conditions).

loop at lt_vbak assigning <fs_vbak>.

:

:

endloop.

You can also have custom defined internal tables:

types: begin of ty_order,

vbeln type vbeln_va,

kunnr type kunag,

:

:

end of ty_order.

table. Internal tables are used to hold more than one line of data.

There are several ways to declare it depending on your requirements.

e.g. an internal table with a line type of VBAK

Data: lt_order type table of ty_order.

Field-symbols: <fs_order> type ty_order.

select vbeln

kunnr

:

from vbak into table lt_order

where (your conditions).

loop at lt_order assigning <fs_order>.

:

:

endloop.

Hope that helps,

Michael

4 REPLIES 4
Read only

Former Member
0 Likes
745

If it is not a structure, it would be an internal table. Internal tables are used to hold more than one line of data.

There are several ways to declare it depending on your requirements.

e.g. an internal table with a line type of VBAK

Data: lt_vbak type table of vbak.

Field-symbols: <fs_vbak> type vbak.

select * from vbak into table lt_vbak

where (your conditions).

loop at lt_vbak assigning <fs_vbak>.

:

:

endloop.

You can also have custom defined internal tables:

types: begin of ty_order,

vbeln type vbeln_va,

kunnr type kunag,

:

:

end of ty_order.

table. Internal tables are used to hold more than one line of data.

There are several ways to declare it depending on your requirements.

e.g. an internal table with a line type of VBAK

Data: lt_order type table of ty_order.

Field-symbols: <fs_order> type ty_order.

select vbeln

kunnr

:

from vbak into table lt_order

where (your conditions).

loop at lt_order assigning <fs_order>.

:

:

endloop.

Hope that helps,

Michael

Read only

Former Member
0 Likes
744

hi venkat,

if it is not a flat structure it will be an internal table.

internal tables can be declared using types and data statements.

TYPES

Syntax Forms

Use Predefined Types

1. TYPES { {dtype[(len)] TYPE abap_type [DECIMALS dec]}

| {dtype TYPE abap_type [LENGTH len] [DECIMALS dec]} }.

Refer to Existing Types

2. TYPES dtype { {TYPE [LINE OF] type}

| {LIKE [LINE OF] dobj} }.

Reference Types

3. TYPES dtype { {TYPE REF TO type}

| {LIKE REF TO dobj} }.

Structured Types

4. TYPES BEGIN OF struc_type.

...

{TYPES dtype ...} | {INCLUDE {TYPE|STRUCTURE} ...}.

...

TYPES END OF struc_type.

Table Types

5. TYPES dtype { {TYPE tabkind OF [REF TO] type}

| {LIKE tabkind OF dobj} }

[WITH key] [INITIAL SIZE n].

Ranges Table Types

6. TYPES dtype {TYPE RANGE OF type}|{LIKE RANGE OF dobj}

[INITIAL SIZE n].

Effect

The TYPES statement defines either an independent data type dtype or a structured data type struc_type. The naming conventions apply to the names dtype and struc_type. The defined data type can be viewed within the current context from this position.

Any data type dtype is either defined with the addition TYPE and a type, or with the addition LIKE and a data object. The syntax allows you to define elementary data types, reference types, structured types, and table types.

For the definition of a structured type struc_type, any type definitions of two TYPES statements are included with the additions BEGIN OF and END OF; a structured data type struc_type is defined here, which contains the included data types as components struc_type-dtype. The structure definitions can be nested.

DATA

Syntax Forms

Using Predefined Types

1. DATA { {var[(len)] TYPE abap_type [DECIMALS dec]}

| {var TYPE abap_type [LENGTH len] [DECIMALS dec]} }

[VALUE val|{IS INITIAL}]

[READ-ONLY].

Reference to Existing Types

2. DATA var { {TYPE [LINE OF] type}

| {LIKE [LINE OF] dobj} }

[VALUE val|{IS INITIAL}]

[READ-ONLY].

Reference Variables

3. DATA ref { {TYPE REF TO type}

| {LIKE REF TO dobj} }

[VALUE IS INITIAL]

[READ-ONLY].

Structures

4. DATA BEGIN OF struc [READ-ONLY].

...

{DATA comp ...} | {INCLUDE {TYPE|STRUCTURE} ...}.

...

DATA END OF struc.

Internal Tables

5. DATA itab { {TYPE tabkind OF [REF TO] type}

| {LIKE tabkind OF dobj} }

[WITH key] [INITIAL SIZE n]

[WITH HEADER LINE]

[VALUE IS INITIAL]

[READ-ONLY].

Ranges Table

6. DATA rtab {TYPE RANGE OF type}|{LIKE RANGE OF dobj}

[INITIAL SIZE n]

[WITH HEADER LINE]

[VALUE IS INITIAL]

[READ-ONLY].

Effect

The statement DATA declares a variable of any data type. The declared data object is visible within the current context as of this position. Within the declaration part of a class or an interface, DATA declares an instance attribute whose validity is bound to an instance of a class.

The data type of arbitrary variables var, reference variables ref , and internal tables itab, rtab, is defined either using the TYPE addition and a type specification, or using the LIKE addition and the specification of a data object. There are different syntax variants for the definition of elementary data objects, reference variables, and internal tables. If neither TYPE nor LIKE is specified, a data object with the bound data type c of length 1 is created.

For the definition of a structure struc, arbitrary data declarations are included by two DATA statements with the additions BEGIN OF and END OF. Here a struc structure is declared that contains the enclosed data objects comp as a struc-comp component. Structure definitions can be nested.

regards,

sravanthi

Read only

0 Likes
744

Thank you

Read only

Former Member
0 Likes
744

Hi,

If it is not a flat structure, it can be a nested or deep structure. If the structure contains another stucture in it. it is called a nested stucture. If it contains a variable length components like internal table in it, it is called a deep structure.

You can define and use a nested structure like this:

types: begin of s1,

f1 type char5,

f2 type c,

end of s1.

types: begin of s2,

struct1 type s1,

end of s2.

data wa type s2.

move 'abc' to wa-struct1-f1.

write wa-struct1-f1.

In the structure S2, if we use a internal table instead of the stucture s1, then it becomes a deep structure.

Award points if useful.

Regards,

Vidhya.