08-16-2007 12:30 PM
Hi,
I want to know the fields that are filled in the table.
For exanple I have an internal table which contains 10 fields with field name FIELD1,FIELD2,...ETC.
Suppose there are 100 records in the table.Now I want to know how many records have field1 value.Same for other records.
Do let me know.
Thanks in advance.
SP
08-16-2007 12:34 PM
data lv_count type i value 0.
loop at itab into wa.
if not wa-field1 is initial.
lv_count = lv_count + 1.
endif.
endloop.
write: 'Number of records with a value in Field1: ', lv_count.
08-16-2007 12:34 PM
Hi Sandeep,
I think this is a crude requirement. you have to follow this path:
data: loc_count1 type p, loc_count2 type p, loc_count3 type p.
loop at int_data.
if field1 ne space.
loc_count1 = loc_count1 + 1.
endif.
if field2 ne space.
loc_count2 = loc_count2 + 1.
endif.
if field3 ne space.
loc_count3 = loc_count3 + 1.
endif.
endloop.
Hope this will solve ur problem.
Regards
Krish
08-16-2007 12:36 PM
LOOP AT itab.
IF NOT itab-field IS INITIAL.
v_counter = v_counter + 1.
ENDIF.
ENDLOOP.
You need one counter for any field you want to check.
I think there is not any sentence in SAP for do it authomatically.
regards
08-16-2007 12:36 PM
data: lv_count type i value 0.
loop at itab where field1 <> ''.
lv_count = lv_count + 1.
endloop.
write:/ lv_count , 'non blank values'.
08-16-2007 12:37 PM
Hi Sandeep,
U can loop at the itab with condtion where field1 <> ' '.
Create a counter initialized with value 0, and within the loop incrase the count value by 1.
so therefore for every hit, it will increase the count value by 1..atlast u ll have the no.of records which have the value for field1.
Code follows,
data: count type i value 0.
loop at itab where field1 <> ' '.
count = count + 1.
endloop.
Write: Count.
hope this helps.
08-16-2007 12:41 PM
hin sandeep, seeing some of the other solution i´d still advice you to check against initial state and not against space or ' ', since e.G. the initial value of a type p field is 0,00, which again is not equal to space, but still it´s not a filled value.