Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

count

Former Member
0 Likes
1,564

Hi,

i want to count number of PERMIT_NO date wise.

for Example.

Date PERMIT_NO

02.02.2009 3451

02.02.2009 3452

02.02.2009 3453

03.02.2009 3454

03.02.2009 3455

03.02.2009 3456

03.02.2009 3457

04.02.2009 3458

04.02.2009 3459

04.02.2009 3460

04.02.2009 3461

04.02.2009 3462

out put :

date count

02.02.2009 3

03.02.2009 4

04.02.2009 5

A m ore informative subject will get you more and better answers.

Edited by: Rob Burbank on Feb 24, 2009 11:22 AM

1 ACCEPTED SOLUTION
Read only

Former Member
1,401

Hi Karthikeyan,

Have you checked my code.

It should work povided that if any fields are available before the date they should have the same value for

each date.

ie.

say for example your int tab contains fields and entries as below.

field1 Date          PERMIT_NO
   a    02.02.2009 3451
   b    02.02.2009 3452
   c    02.02.2009 3453.

as the field 1 has different values at end of will be executed for each date and the count will be 1 only for each date.

in this case create another int tab with fields date and count and calculate the count using the same

logic.

Regards,

Manoj Kumar P

Edited by: Manoj Kumar on Feb 25, 2009 1:22 PM

12 REPLIES 12
Read only

Former Member
0 Likes
1,401

Hi,

Below logic will give the count for each date.

SORT it_tab BY date.
LOOP AT it_tab INTO wa_tab.
  ADD 1 TO w_count.
  AT END OF date.
    WRITE: / wa_tab-date, w_count. "If you need you can update this count in the int tab
    CLEAR w_count.
  ENDAT.
ENDLOOP.

Hope this helps you.

Regards,

Manoj Kumar P

Edited by: Manoj Kumar on Feb 24, 2009 3:16 PM

Read only

Former Member
0 Likes
1,401

Hi,

Use this logic.

Let me consider internal table name as DATE_COUNT having two fields DATE and PERMIT_NO.

For Output:

data counter type i value 0.

Loop at DATE_COUNT into workarea.

count = count + 1.

AT END OF DATE.

write: / workarea-date, counter.

counter = 0.

ENDAT.

ENDLOOP.

Thanks and Regards,

Suresh

Read only

0 Likes
1,401

Hi,

sorry its not giving correct answer.

the output will be like this.

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

03.01.2009 1

05.01.2009 1

05.01.2009 1

05.01.2009 1

05.01.2009 1

05.01.2009 1

05.01.2009 1

Read only

0 Likes
1,401

Hi,

sorry its not giving correct answer.

the output will be like this.

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

02.01.2009 1

03.01.2009 1

05.01.2009 1

05.01.2009 1

05.01.2009 1

05.01.2009 1

05.01.2009 1

05.01.2009 1

Read only

Former Member
0 Likes
1,401

hi,

sort itab by date.

data: cnt type i value 1.

loop at itab into wa_itab.

at end of date.

wrtie: wa_itab-date, cnt.

endat.

cnt = cnt + 1.

endloop.

Cheers,

Rudhir

Read only

Former Member
0 Likes
1,401

Create an internal table with 2 fields: 1 for your date and 1 for a counter. Then simply collect your entries into that internal table.

types: begin of ty_dates,
              date(10) type c,
              count    type i,
          end of ty_dates.

data: it_dates type table of ty_dates,
        wa_date type ty_dates.


loop at [your itab].

   wa_dates-date = [your itab]-date.
   wa_dates-count = 1.
   collect wa_dates to it_dates.

endloop.

Read only

Former Member
1,402

Hi Karthikeyan,

Have you checked my code.

It should work povided that if any fields are available before the date they should have the same value for

each date.

ie.

say for example your int tab contains fields and entries as below.

field1 Date          PERMIT_NO
   a    02.02.2009 3451
   b    02.02.2009 3452
   c    02.02.2009 3453.

as the field 1 has different values at end of will be executed for each date and the count will be 1 only for each date.

in this case create another int tab with fields date and count and calculate the count using the same

logic.

Regards,

Manoj Kumar P

Edited by: Manoj Kumar on Feb 25, 2009 1:22 PM

Read only

0 Likes
1,401

Hi Manoj Kumar,

i got the output thank you so much.

Regards,

K.Karthikeyan.

Read only

Former Member
0 Likes
1,401

Hi Karthick,

this may help..


data:
w_count type i.

loop at itab.
add 1 to count.
at end of date.
write:/ itab-date,
          w_count.
w_count = 0.
endat.
endloop.

Regards,

Mdi.Deeba

Read only

Former Member
0 Likes
1,401

Hi Karthikeyan,

Date PERMIT_NO

02.02.2009 3451

02.02.2009 3452

02.02.2009 3453

03.02.2009 3454

03.02.2009 3455

03.02.2009 3456

03.02.2009 3457

04.02.2009 3458

04.02.2009 3459

04.02.2009 3460

04.02.2009 3461

04.02.2009 3462

sort itab by date permit_no.

data: l_itab like itab ,

l_count type i .

loop at itab

move itab to l_itab.

i = i + 1.

at end of date.

write : \ 1(10) l_itab-date

13 i .

clear i.

endat.

endloop.

Regards,

Anil

Read only

former_member610099
Discoverer
0 Likes
1,401

I want this answer with full code..

Its urgent please help me..

Thank you..

Read only

gregorw
SAP Mentor
SAP Mentor
1,401

I would suggest to learn some SQL basics.