09-23-2008 1:54 PM
how to count the number of rows in a loop satisfying a specific condition
like there are 5 rows of kunnr = '10001'
I dnt want to increment counter because Im doing an inner loop for that condition
In a sense I want to compare the numbe rof records in the inner loop and outer loop where kunnr = '10001'
09-23-2008 1:58 PM
Hi,
You can have a temporary table.
data : l_lines type i.
gt_temp[] = gt_data[].
delete gt_temp where kunnr ne '10001'.
describe gt_temp lines l_lines.
l_lines will have the necessary values.
Best regards,
Prashant
09-23-2008 1:58 PM
Hi,
You can have a temporary table.
data : l_lines type i.
gt_temp[] = gt_data[].
delete gt_temp where kunnr ne '10001'.
describe gt_temp lines l_lines.
l_lines will have the necessary values.
Best regards,
Prashant
09-23-2008 2:03 PM
you can move the data to a dummy table with only valid records and get the line count.
data : lines type i.
i_temp[] = i_data[].
"lines will have the no of rows of the temp table
delete gt_temp where kunnr ne '10001'.
lines = lines( i_temp ).
09-23-2008 2:03 PM
09-23-2008 2:19 PM
Hi,
try this short example:
DATA: IVBAK TYPE TABLE OF VBAK WITH HEADER LINE.
DATA: BEGIN OF IKUNNR OCCURS 0,
KUNNR LIKE VBAK-KUNNR,
I TYPE I,
END OF IKUNNR.
*
SELECT * FROM VBAK INTO TABLE IVBAK.
*
LOOP AT IVBAK.
IKUNNR-KUNNR = IVBAK-KUNNR. IKUNNR-I = 1.
COLLECT IKUNNR.
ENDLOOP.
*
SORT IKUNNR.
*
LOOP AT IKUNNR. WRITE: / IKUNNR-KUNNR, IKUNNR-I. ENDLOOP.
Regards, Dieter
09-23-2008 2:23 PM
Hi sia anjali,
Declare a Temporary table(say itab1) and Try as following;
REFRESH itab1.
itab1[] = itab[].
DELETE itab1 WHERE kunnr = '1001'.
DESCRIBE TABLE itab1.
After Describe statement System field SY-TFILL contain the number of lines in the table itab1. Use that.
Regards
Karthik D