‎2009 Aug 22 6:49 AM
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 .
‎2009 Aug 22 7:47 AM
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.
‎2009 Aug 22 7:28 AM
Hello,
Your requirement is still not clear.
Explain with proper example.
Thanks,
Augustin.
‎2009 Aug 22 7:38 AM
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.
‎2009 Aug 22 7:47 AM
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.