2007 Jun 20 2:05 PM
hallow
i have internal table and i wont to count lines with key
example
data
001
001
002
003
001
i wont in some fiels to now how much number of 001 i have here 3
regards
2007 Jun 20 2:09 PM
syntax:
DESCRIBE TABLE itab2 LINES n.
You will get teh number of lines in variable n.
If you want to know the number of keys proceed this way.
1. Get all the keys to a itab1.
2. GEt all the data to itab2
3. Loop at itab1.
loop at itab2 where key = itab1-key.
count the number of times the key ocuurs and store * to a variable or do a write
endloop.
endloop.
hallow
i have internal table and i wont to count lines with key
example
data
001
001
002
003
001
i wont in some fiels to now how much number of 001 i have here 3
regards
2007 Jun 20 2:09 PM
syntax:
DESCRIBE TABLE itab2 LINES n.
You will get teh number of lines in variable n.
If you want to know the number of keys proceed this way.
1. Get all the keys to a itab1.
2. GEt all the data to itab2
3. Loop at itab1.
loop at itab2 where key = itab1-key.
count the number of times the key ocuurs and store * to a variable or do a write
endloop.
endloop.
2007 Jun 20 2:09 PM
hi,
data: value type i.
loop at itab where itab-fld = '001'.
value = value + 1.
write:/10 value.
endloop.
and if u want to count no. of lines ina internal table then use describe command as
ex: describe lines value.
write:/10 value.
if useful reward some points.
with regards,
suresh.
2007 Jun 20 2:09 PM
data: lv_count typei.
loop at itab into wa.
if itab-some_field = 'value'.
lv_count = lv_count + 1.
endif.
endloop.
write lv_count
2007 Jun 20 2:14 PM
Hi,
You can get the number of lines in a table using the DESCRIBE statement.
DESCRIBE TABLE itab [KIND knd] [LINES lin] [OCCURS n]
Effect
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.
You can also loop at the internal table where data = key.Then keep an count and increase it everytime.
loop at itab where data = key.
cnt = cnt + 1.
endloop.
This will serve your purpose I suppose.
Hope it will be useful.
Thanks,
Sandeep.
2007 Jun 20 2:14 PM
Hi Shnya,
first sort the internal table based on the field that u want to have count...
Example: lets suppose that the field name itself is data and the internal table name is l_itab and it has the values that u have given in your post...
Sample code:
sort l_itab by data.
loop at l_itab into wa_itab.
lv_counter = lv_counter + 1.
at end of data.
Each time it triggers, lv_counter will be having the * value for a particular value in data field.. for the * first time it will be having counter for 001, second * time 002 and so on...
write code according to your requirement.. and then * clear lv_counter...
endat.
endloop.
Hope this helps u...
Regards,
Phani.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |