2006 May 19 10:45 AM
hi,
I have to find the count in the itab based on some conditions.
How to do it.
Pls help.
Priya
Hi,
You can use any of the following techinic.
1) loop at itab.
incr = incr + 1.
endloop.
write : incr.
2) By using "DESCRIBE" Statement
Thanks
Sunil.
2006 May 19 10:48 AM
HI,
use LOOP at ITAB where 'condition'.
increment a counter.
endloop.
delete ITAB entries for unwated condition
and use DESCRIBE TABLE LINES v_lines.
rgds,
latheesh
2006 May 19 10:49 AM
Hi
You can only loop your table for those condition and count the number of hits.
LOOP AT ITAB WHERE
COUNT = COUNT + 1.
ENDLOOP.
Or you can count the records while appending them.
Max
2006 May 19 10:50 AM
hi,
try this..
data w_cnt type i.
loop at itab where <condition>
transporting no fields.
w_cnt = w_cnt + 1.
endloop.
* W_cnt will have the count.
Regards,
Suresh Datti
2006 May 19 10:52 AM
Hi,
If you have three condition and you want count accordingly then have three count variable and write logic for that.
loop at itab.
if condition 1.
count1 = count1+1.
elseif condition 2 .
count2 =count2 +1 .
elseif condition 3 .
count3 = count3 +1 .
endif.
<i>Hope This Info Helps YOU.</i>
Regards,
Raghav
2006 May 19 11:07 AM
Hai Priya
Go through the following Code
************************************************************************
Table Declaration *
************************************************************************
TABLES: mara.
************************************************************************
Types Declaration *
************************************************************************
TYPES: BEGIN OF typ_mara,
matnr TYPE mara-matnr, "Material Number"
mbrsh TYPE mara-mbrsh, "Industrial Sector"
mtart TYPE mara-mtart, "Material Type"
meins TYPE mara-meins, "Base Unit of Measure"
END OF typ_mara.
************************************************************************
Intrnal tables Declaration *
************************************************************************
DATA: it_mara TYPE STANDARD TABLE OF typ_mara WITH HEADER LINE.
Data : V_Count type I.
Data : V_lines type I.
************************************************************************
Selection Screen *
************************************************************************
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_mtart LIKE mara-mtart default 'ROH'.
SELECTION-SCREEN : END OF BLOCK b1.
************************************************************************
************************************************************************
At Selection-screen *
************************************************************************
AT SELECTION-SCREEN.
***
PERFORM validte_inputdata.
&----
*& Form Validte_Inputdta
&----
Validation of Select Option
----
FORM validte_inputdata .
SELECT SINGLE * FROM mara
WHERE mtart = p_mtart.
IF sy-subrc <> 0.
MESSAGE e001 WITH 'Material'(002) 'Type'(003) 'Does Not Exit'(400).
ENDIF.
ENDFORM. " Validte_Inputdta
START-OF-SELECTION.
***
SELECT matnr
mbrsh
mtart
meins
INTO TABLE it_mara
FROM mara
WHERE mtart = p_mtart.
if sy-subrc = 0.
sort it_mara by matnr.
else.
MESSAGE e001 WITH 'No data Found' ' For the Given'
'Selection Criteria'(400).
endif.
*First way
DESCRIBE TABLE it_mara LINES v_lines.
write 😕 v_lines.
*2nd way
loop at it_mara where mtart = p_mtart.
V_count = V_count + 1.
endloop.
write 😕 v_count.
Thanks & regards
Sreeni
2006 May 19 11:08 AM
Hi Priya,
only one condition or many conditions
data: count type i.
Loop at itab where field = 'ABC'.
count = count + 1.
endif.regards
vijay
2006 May 19 11:46 AM
Hi
Itab1 - ur intial table.
itab2 - dummy table liek itab1.
try this code.......
itab2[] = itab1[].
delete itab2[] where = <condition>
describe itab2 lines <variable>.
hope this help
Anirban
2006 May 19 3:32 PM
Hi,
You can use any of the following techinic.
1) loop at itab.
incr = incr + 1.
endloop.
write : incr.
2) By using "DESCRIBE" Statement
Thanks
Sunil.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |