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

Select duplicate Data with same No.

Former Member
0 Likes
633

Dear All experts,

How we giong to select the data with same No as 1 record count.

example : Bellow is the sample table contains 5 rows records, but of records ard same number.

post No. Name

1001 Jacky

1001 Jimmy

1002 Mark

1003 Jin

1004 chloe

when i use the select statement bellow :

Select * from table into corresposding of table t_table up to 3.

will get the result like below .

1001 Jacky

1001 Jimmy

1002 Mark

Question is , how i going to write the statement to get the 3(depend on user insert how many record) different no. example , 2records of 1001, 1002 , and 1003 .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
607

if its a ztable then better to keep a counter field for your requirement.

else.

parameter : count type i. "this holds number of required data.

select * from TT_XYZ into table gt_itab. 
loop at gt_itab into gs_itab.
 at end of post_no. 
   count = count - 1.
 endat.
 if count = 0.
  exit.
 endif.
 append gs_itab to gt_itab2.
 clear gs_itab.
endloop.

now gt_itab2 holds required entries for you.

3 REPLIES 3
Read only

Former Member
0 Likes
607

Hello,

Your requirement is still not clear.

Explain with proper example.

Thanks,

Augustin.

Read only

Former Member
0 Likes
607

Hi olrang,

I am not clear with your requirement but It appears that if there are duplicate records then u want it to display just first record for that number. In such case u can fetch whole data in internal table sort your table on number field and then use

DELETE ADJACENT DUPLICATES FROM t_table COMPARING <POST NUMBER FIELD NAME>.

Hope this may help you.

Thanks & Regards,

Vaibhav Pendse.

Read only

Former Member
0 Likes
608

if its a ztable then better to keep a counter field for your requirement.

else.

parameter : count type i. "this holds number of required data.

select * from TT_XYZ into table gt_itab. 
loop at gt_itab into gs_itab.
 at end of post_no. 
   count = count - 1.
 endat.
 if count = 0.
  exit.
 endif.
 append gs_itab to gt_itab2.
 clear gs_itab.
endloop.

now gt_itab2 holds required entries for you.