A database table contains 3
fields(Student_no,Section,Total_marks).I want retrieve top 10
students from each section.Note:(Section contains data like
A,B,C.Each section contains more than 10 students).

Answer Posted / waseem

**Sorry guys for above wrong code which I posted, You can **use this code with 100 % result****

tables : ywt_student, ywt_result.
data : begin OF itab OCCURS 0, "structure from 2 tables
usn like ywt_student-usn,
name like ywt_student-name,
dob like ywt_student-dob,
cls like ywt_result-class,
marks like ywt_result-marks,
end of itab.

**"selecing values from 2 tables*****
select ywt_student~usn name dob class marks
INTO TABLE itab
from ywt_student INNER JOIN ywt_result on ywt_student~usn = ywt_result~usn.

**Sorting for testing Perpose*****

sort itab by cls ASCENDING marks DESCENDING.
LOOP AT itab.
on CHANGE OF itab-cls.
skip.
ENDon.
WRITE :/ itab-usn, itab-name, itab-dob, itab-cls, itab-marks.

ENDLOOP.



skip 2.
***Actual Logic of Requirement***
data : m LIKE ywt_result-marks.
data : count TYPE i value 0.
CLEAR itab.
sort itab by cls ASCENDING marks DESCENDING.
CLEAR itab.
LOOP AT itab.
m = itab-marks.
on CHANGE OF itab-cls.
skip 2.
count = 0.
ENDon.
AT NEW cls.
itab-marks = m.
count = count + 1.
IF count LE 10.
WRITE :/ itab-usn, itab-name, itab-dob, itab-cls, itab-marks.
CLEAR itab.
ENDIF.
ENDAT.
ENDLOOP.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an “on request field” statement?

662


stock transfer from one plant to another plant ? i want the total description.

1578


How do I find the output type of a table or a program?

593


What is an abap dictionary? : abap data dictionary

601


Hi to all abap gurus iam new to abap and my querry is as follows . and i feel so happy if u give exact anwers ? Querry1: i have one page( named "page1" )in my script with three windows(logo,adress,main windows) my requirement is to display some dynamic data in the script that is list of orders of the customer whn u give the customer number in selction-screen .then we can go for main window only to dispaly dynamic data ? or is there any other option ? then what should we give as apage number in the next page attribute in the header information. suppose if i dont give "page1" in the next page attribute as anext page what will happen ? i mean that dynamic data will be displayed or not ? Querry2: one one more querry incase if we have two pages in my layout .in page1 (3 windows as said above ) and page2 ( only logo and address window ) and no main window in page2. now if we give "page2" as next page in the next page attribute of page1 then that dynamic data will be displayed or not ?

1612






How many primary keys can be created for a table?

621


What is table buffer?

586


What kind of BDC programs are written ?

603


What are ranges?

596


How to create a link between modified form and modified print program?

590


What are secondary indexes. How can we know which index is being used in a select query?

1004


Explain the Types of Select statements?

655


Can you print decimals in type n? What is difference between float and packed data type?

760


Difference between /N and /BEND?

825


What is the difference between free and refresh?

601