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

Fetching output from internal table based on some count

Former Member
0 Likes
444

Hi,

I have a requirement like this.

I have an internal table with just one row, lets say "orderid". Now in my scenario, I fill this orderid's which can be repeating, like for eg. it can have same orderid n number of times.

But I also have a requirement like this. I have a condition variable lets say "Count" which will be dynamically passed by the user.

Now i want to fetch all the orderid's from the internal table and store it into a different table which is exactly repeated "Count" number of times. So get all the orderid's from the internal table which is exactly present count times.

Can anyone tell me if I can do this by writing a select query or by using any other efficient method, if possible with some explanation.

Thanks,

Siva.

PS: Points will be rewarded.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
422

hi siva,

data : begin of itab occurs 0.

data : project like zmytable-project.

data : cnt type i.

data : end of itab.

Select project count(*) as cnt

from zmytable

into table itab

group by project

i think this will help u

regards,

sindhu.

3 REPLIES 3
Read only

Former Member
0 Likes
423

hi siva,

data : begin of itab occurs 0.

data : project like zmytable-project.

data : cnt type i.

data : end of itab.

Select project count(*) as cnt

from zmytable

into table itab

group by project

i think this will help u

regards,

sindhu.

Read only

Former Member
0 Likes
422

Check this code, hope this helps


data:
  count type i.
sort itab by orderid.
loop at itab.
   count = count + 1. 
  at end of orderid.
   if count = p_count
     append itab to temp_itab.
   endif.
   clear count.
  endat.
endloop.

Read only

Former Member
0 Likes
422

Thanks a lot. Problem solved.