2008 Nov 26 11:53 AM
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.
2008 Nov 26 11:55 AM
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
2008 Nov 26 11:55 AM
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
2008 Nov 26 11:55 AM
HI,
No it cannot be done through the Describe table. Instead you need to loop through the internal table and calculate the count.
2008 Nov 26 11:59 AM
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
2008 Nov 26 11:58 AM
HI with out looping ur internal table only with describe statement its not possible to count.
2008 Nov 26 11:58 AM
hi
write in loop and check sy-tabix value.
you cant do with describe statment.
2008 Nov 26 12:00 PM
Hi
Delete itab where field1 is intial.
then use
describe table itab lines line.
regards
Ramchander Rao.K
2008 Nov 26 12:01 PM
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.
2008 Nov 26 12:05 PM
2008 Nov 26 12:09 PM
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.
2008 Nov 26 12:11 PM
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.
2019 Jul 25 12:35 PM
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
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |