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: 

Describe table

Former Member
0 Kudos

what is the use of DESCRIBE TABLE command

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

It's to get some characteristics of an internal table as the numbers of records:

DESCRIBE TABLE ITAB LINES V_LINES.

See the help for more details

Max

14 REPLIES 14

Former Member
0 Kudos

it gives you the properties of an internal table

for example:

DATA L_LINES TYPE I.

--

--

DESCRIBE TABLE LINES L_LINES.

now L_LINES contains the number of lines/rows in the internal table filled...

pls refer to the following links for more information

<a href="http://help.sap.com/saphelp_45b/helpdata/en/34/8e72fc6df74873e10000009b38f9b8/content.htm">http://help.sap.com/saphelp_45b/helpdata/en/34/8e72fc6df74873e10000009b38f9b8/content.htm</a>

<a href="

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3798358411d1829f0000e829fbfe/content.htm

">http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3798358411d1829f0000e829fbfe/content.htm</a>

[url]http://help.sap.com/saphelp_40b/helpdata/en/fc/eb3798358411d1829f0000e829fbfe/content.htm

[/url]

hope this info helps...

thx

pavan

**pls reward for helpful answers

Former Member
0 Kudos

Hi

It's to get some characteristics of an internal table as the numbers of records:

DESCRIBE TABLE ITAB LINES V_LINES.

See the help for more details

Max

Former Member
0 Kudos

Hi Jeya sree,

To determine the number of rows in an internal table, use the sy-tfill variable. It is set by the describe table statement.

<b>Syntax for the describe table Statement</b>

The following is the syntax for the describe table statement.

describe table it [lines i] [occurs j].

where:

it is the name of an internal table.

i and j are numeric variables.

This statement fills the three system variables.

<b>DESCRIBE TABLE Statement Fills These System Variables</b>

Variable Value

sy-tfill Number of rows

sy-tleng Length of a row in bytes

sy-toccu Current value of the occurs clause

The following points apply:

If the lines i addition is specified, the number of rows is placed in both sy-tfill and i.

If the occurs j addition is specified, the size of the occurs clause is placed in both sy-toccu and j.

Hope this resolves your query.

Reward all the helpful answers.

Regards

Vijay
Active Contributor
0 Kudos

Hi ........

"DESCRIBE" statement is used for getting simple information about internal tables and I guess you want to acquire information about a database table. So, you can use the FM "DDIF_NAMETAB_GET" .

This FM will give technical information about the database table. To acquire the number of records you can use "SELECT COUNT( * ) " statement.

Hope this helps...

<b>plz award pts if helpful.</b>

Kind Regards

vijay

former_member1109645
Participant
0 Kudos

hi,

To find out the attributes of an internal table at runtime that were not available statically, use the statement:

DESCRIBE TABLE itab [LINES lin] [OCCURS n] [KIND knd].

If you use the LINES parameter, the number of filled lines is written to the variable lin. If you use the OCCURS parameter, the value of the INITIAL SIZEof the table is returned to the variable n. If you use the KIND parameter, the table type is returned to the variable knd: ‘T’ for standard table, ‘S’ for sorted table, and ‘H’ for hashed table.

REPORT demo_int_tables_describe_table .

DATA: BEGIN OF line,

col1 TYPE i,

col2 TYPE i,

END OF line.

DATA itab LIKE HASHED TABLE OF line WITH UNIQUE KEY col1

INITIAL SIZE 10.

DATA: lin TYPE i,

ini TYPE i,

knd(1) TYPE c.

DESCRIBE TABLE itab LINES lin OCCURS ini KIND knd.

WRITE: / lin, ini, knd.

DO 1000 TIMES.

line-col1 = sy-index.

line-col2 = sy-index ** 2.

INSERT line INTO TABLE itab.

ENDDO.

DESCRIBE TABLE itab LINES lin OCCURS ini KIND knd.

WRITE: / lin, ini, knd.

The list output is:

0 10 H

1,000 10 H

Here, a hashed table itab is created and filled. The DESCRIBE TABLE statement is processed before and after the table is filled. The current number of lines changes, but the number of initial lines cannot change.

Former Member
0 Kudos

Hi Jeya,<b>

<b>Describe table statement :</b>

Describes the attributes of an internal table.

Syntax

DESCRIBE TABLE [LINES <l>] [OCCURS<n>] [KIND <k>].

Depending on the additions you use, writes the number of lines occupied, the value specified for the INITIAL SIZE of the table, or the table type into a corresponding variable.

Example code:

<b>data : w_line type i.

describe table it_tab lines w_line.

if wa_line = 1.

read table it_tab into wa_tab.

endif.</b>

Hence, this code helps to describe each record of the internal table it_tab with referred to w_line, that is, it specifies the record number.

Regards,

Thasneem

Former Member
0 Kudos

hi,

This determines some properties of the internal table itab and assigns them to the specified variables. The various additions enable you to determine the table type, the number of currently filled rows and the initial memory requirement.

thnx.

Former Member
0 Kudos

Hi,

Describe statement is useful to know the below things.

1)Return attributes of a field

2)Return attributes of an internal table

3)Determine distance between two fields

4)Return attributes of a list

If you want to know in detail then click F1 on Describe word and read the entire help.

thanks,

sksingh

Former Member
0 Kudos

hi

To find out the attributes of an internal table at runtime that were not available statically, use the statement:

DESCRIBE TABLE <itab> [LINES <l>] [OCCURS <n>] [KIND <k>].

If you use the LINES parameter, the number of filled lines is written to the variable <lin>. If you use the OCCURS parameter, the value of the INITIAL SIZE of the table is returned to the variable <n>. If you use the KIND parameter, the table type is returned to the variable <k>: ‘T’ for standard table, ‘S’ for sorted table, and ‘H’ for hashed table.

reward if helpful.

regards,

kiran kumar k

Former Member
0 Kudos

hi Jeya Shree,

use of describe is to get the number of record/row/line in the intertable.

hope this clear the doubt

suppose a internal table has 5 enteries.

data: lv_lines type i.

describe table itab lines lv_lines.

write:/ 'number of line',lv_lines.

result or out put

5.

hope this might give u a better idea

reward pionts if helpful.

anuj

Former Member
0 Kudos

HI go through this document

To find out the attributes of an internal table at runtime that were not available statically, use the statement:

DESCRIBE TABLE itab [LINES lin] [OCCURS n] [KIND knd].

If you use the LINES parameter, the number of filled lines is written to the variable lin. If you use the OCCURS parameter, the value of the INITIAL SIZEof the table is returned to the variable n. If you use the KIND parameter, the table type is returned to the variable knd: ‘T’ for standard table, ‘S’ for sorted table, and ‘H’ for hashed table.

REPORT demo_int_tables_describe_table .

DATA: BEGIN OF line,

col1 TYPE i,

col2 TYPE i,

END OF line.

DATA itab LIKE HASHED TABLE OF line WITH UNIQUE KEY col1

INITIAL SIZE 10.

DATA: lin TYPE i,

ini TYPE i,

knd(1) TYPE c.

DESCRIBE TABLE itab LINES lin OCCURS ini KIND knd.

WRITE: / lin, ini, knd.

DO 1000 TIMES.

line-col1 = sy-index.

line-col2 = sy-index ** 2.

INSERT line INTO TABLE itab.

ENDDO.

DESCRIBE TABLE itab LINES lin OCCURS ini KIND knd.

WRITE: / lin, ini, knd.

The list output is:

0 10 H

1,000 10 H

Here, a hashed table itab is created and filled. The DESCRIBE TABLE statement is processed before and after the table is filled. The current number of lines changes, but the number of initial lines cannot change.

former_member235056
Active Contributor
0 Kudos

Hi,

To find out the attributes of an internal table at runtime that were not available statically, use the statement:

DESCRIBE TABLE itab [LINES lin] [OCCURS n] [KIND knd].

If you use the LINES parameter, the number of filled lines is written to the variable lin. If you use the OCCURS parameter, the value of the INITIAL SIZEof the table is returned to the variable n. If you use the KIND parameter, the table type is returned to the variable knd: ‘T’ for standard table, ‘S’ for sorted table, and ‘H’ for hashed table.

REPORT demo_int_tables_describe_table .

DATA: BEGIN OF line,

col1 TYPE i,

col2 TYPE i,

END OF line.

DATA itab LIKE HASHED TABLE OF line WITH UNIQUE KEY col1

INITIAL SIZE 10.

DATA: lin TYPE i,

ini TYPE i,

knd(1) TYPE c.

DESCRIBE TABLE itab LINES lin OCCURS ini KIND knd.

WRITE: / lin, ini, knd.

DO 1000 TIMES.

line-col1 = sy-index.

line-col2 = sy-index ** 2.

INSERT line INTO TABLE itab.

ENDDO.

DESCRIBE TABLE itab LINES lin OCCURS ini KIND knd.

WRITE: / lin, ini, knd.

The list output is:

0 10 H

1,000 10 H

Here, a hashed table itab is created and filled. The DESCRIBE TABLE statement is processed before and after the table is filled. The current number of lines changes, but the number of initial lines cannot change.

Pls reward points.

Regards,

Ameet

Former Member
0 Kudos

This statement determines some properties of the internal table itab and assigns them to the specified variables. The various additions enable you to determine the table type, the number of currently filled rows and the initial memory requirement.In addition, the system fields sy-tfill and sy-tleng are filled with the current number

of table rows and the length of a table row in bytes.

<b>Fields of Internal Tables</b>

SY-TABIX

Current line of an internal table. SY-TABIX is set by the statements below, but only for index tables. The field is either not set or is set to 0 for hashed tables.

APPEND sets SY-TABIX to the index of the last line of the table, that is, it contains the overall number of entries in the table.

COLLECT sets SY-TABIX to the index of the existing or inserted line in the table. If the table has the type HASHED TABLE, SY-TABIX is set to 0.

LOOP AT sets SY-TABIX to the index of the current line at the beginning of each loop lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the loop. It is set to 0 if the table has the type HASHED TABLE.

READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry.

SEARCH <itab> FOR sets SY-TABIX to the index of the table line in which the search string is found.

SY-TFILL

After the statements <b>DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TFILL</b> contains the number of lines in the relevant internal table.

SY-TLENG

After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG contains the length of the lines in the relevant internal table.

SY-TOCCU

After the statements<b> DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG</b> contains the initial amount of memory allocated to the relevant internal table.

reward points if it is usefull ....

Girish

0 Kudos

Pl close this thread