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

describe internal table

Former Member
0 Likes
3,642

experts,

itab

field1 field2

A 1

2

B 3

4

C 5

D 6

above is the internal table( with field1 and field2) which contains 6 records .

how to count the number of records where field1 is not empty using ' describe statement only'

can it be done or not.

thanks in advance.

experts,

itab

field1 field2

A 1

2

B 3

4

C 5

D 6

above is the internal table( with field1 and field2) which contains 6 records .

how to count the number of records where field1 is not empty using ' describe statement only'

can it be done or not.

thanks in advance.

12 REPLIES 12
Read only

former_member203501
Active Contributor
0 Likes
1,775

hi ,

use the count for this .....loop the internal table check the field .. if it is empty increment the count by one ...

REPORT Zpopup message-id zmsg.

data: begin of itab occurs 0,

field1 type c ,

field2 type c ,

end of itab .

itab-field1 = 'A'.

itab-field2 = '1' .

append itab .

itab-field1 = 'B'.

itab-field2 = ' ' .

append itab .

itab-field1 = 'C'.

itab-field2 = '2' .

append itab .

itab-field1 = 'C'.

itab-field2 = ' ' .

append itab .

itab-field1 = 'D'.

itab-field2 = '4' .

append itab .

data: v_count type i .

loop at itab .

if itab-field2 is initial .

v_count = v_count + 1 .

endif .

endloop .

write:/ v_count .

Edited by: venkat appikonda on Nov 26, 2008 1:07 PM

Read only

agnihotro_sinha2
Active Contributor
0 Likes
1,775

hi,

transfer data to another table

delete rows from that table which are having empty first field.

find out the size of 2nd table using "describe table".

regards,

ags

Read only

Former Member
0 Likes
1,775

HI,

No it cannot be done through the Describe table. Instead you need to loop through the internal table and calculate the count.

Read only

0 Likes
1,775

hi,

i dont understand why it cannot be done thru describe table...

if you copy the 1st table to a 2nd one and then delete the rows with Field1 NOT empty... and then find the size of the 2nd table using "describe table" the motif can be achieved.

later on delete this 2nd table.

regards,

ags

Read only

Former Member
0 Likes
1,775

HI with out looping ur internal table only with describe statement its not possible to count.

Read only

Former Member
0 Likes
1,775

hi

write in loop and check sy-tabix value.

you cant do with describe statment.

Read only

Former Member
0 Likes
1,775

Hi

Delete itab where field1 is intial.

then use

describe table itab lines line.

regards

Ramchander Rao.K

Read only

Former Member
0 Likes
1,775

Hi,

Cannot be done using describe stmt....

use two methods to do it...

1) loop the table and make a loop count with the condition on field1..

2) move the contents for which field1 is not empty to other temp table and then use describe for that temp table.....

Hope this will help.

Regards,

Rohan.

Read only

0 Likes
1,775

thanks experts for valuable answers.

Read only

Former Member
0 Likes
1,775

Hi,

You can simply use the DESCRIBE statement like

Describe table t_table lines w_lines.

Loop at t_table into wa_table.
  If wa_table-field1 is initial.
    w_lines = w_lines - 1.
  Endif.
Endloop.

With luck,

Pritam.

Read only

Former Member
0 Likes
1,775

Use this syntax:

DATA: lines(6) type N.

DISCRIBE TABLE <internal table name> LINES <lines>.

or Start debugging your program then observe value of SY-TFILL system variable while just executed that internal table statements.

Regards:

BBR.

Read only

SachinArtani
Active Participant
0 Likes
1,775

Below code helps you to get number of lines without loop using describe statement only -

REPORT ztest.

DATA: w_lines TYPE i.

types: BEGIN OF ty_itab,
        field1 TYPE c,
        field2 TYPE c,
      END OF ty_itab.

data: itab type TABLE OF ty_itab,
      wa type ty_itab.


wa-field1 = 'A'. wa-field2 = '1' .
APPEND wa to itab.

wa-field1 = 'B'. wa-field2 = '2' .
APPEND wa to itab .

wa-field1 = 'C'. wa-field2 = '3' .
APPEND wa to itab .


wa-field1 = 'D'.wa-field2 = '4' .
APPEND wa to itab .

DESCRIBE TABLE itab LINES w_lines.

WRITE: / w_lines.

Rewards, if useful.

Thanks