Application Development 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: 

count of records itab based on multiple conditions

Former Member
0 Kudos

I need count the records from itab with various conditions , my itab is as below


cycle date

01 01/02/2010

02 04/01/2010

01 03/01/2010

03 06/01/2010

04 07/01/2010

02 04/01/2010

03 06/01/2010

01 01/02/2010

03 05/01/2016

02 04/01/2010

03 06/01/20107


for each cycle there will one or two dates , so i need count the records and display as below.

cycle date no records

01 01/02/2010 2
01 03/01/2010 1
02 04/01/2010 3
03 06/01/2010 3
03 05/01/2016 1
04 07/01/2010 1 I know AT NEW can be used , but not vey sure how it is useful in this scenarios.

Thanks for your inputs

NK

1 ACCEPTED SOLUTION

0 Kudos

You could to sort your internal table by date field.. And to do something like:

loop at it_tab into ls_tab.

if ls_tab-date ne lv_date_old.

append initial line to it_out assigning field-symbol(<out>).

move-corresponding ls_tab to <out>.

endif.

add 1 to <out>-counter.

lv_date_old = ls_tab-date.

endloop.

9 REPLIES 9

0 Kudos

You could to sort your internal table by date field.. And to do something like:

loop at it_tab into ls_tab.

if ls_tab-date ne lv_date_old.

append initial line to it_out assigning field-symbol(<out>).

move-corresponding ls_tab to <out>.

endif.

add 1 to <out>-counter.

lv_date_old = ls_tab-date.

endloop.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

What have you tried yourself?

Former Member
0 Kudos

Would be nice to

  • write a date definition like MM/DD/YYYY at the beginning
  • write date in technical notation like YYYYMMDD
  • write long date format like 01/jan/2010

Former Member
0 Kudos

Why not create a 2nd itab with COLLECT for output ?

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Oh no, no COLLECT for that task ...

Former Member
0 Kudos

achived through ATNEW and ONCHANGE of .

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

ON CHANGE of? Oh my ...

matt
Active Contributor
0 Kudos

You know that ON CHANGE OF has been obsolete for a very long time.? Why are you using obsolete code? What version of ABAP are you on - 2.1?