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
Why is pretty printer user in abap?
Can i know some of the Realtime tickets that anyone has been faced ?
MY DOMAIN IS SAP-ABAP COMPARE TO WEBDYNPRO AND CRM-TECHNICAL WHICH IS BEST?
What is meant by a schema? : sap abap hr
Can you create an internal table dynamically?(at run time)
Does every abap/4 have a modular structure? : abap modularization
What is processing class, where we do them and why? : sap abap hr
How did you transfer legacy data in the mid of the financial year (us) to the sap system? : sap abap hr
What is the difference between the function module and a normal abap/4 subroutine? : abap modularization
Difference between /N and /BEND?
What is the difference between a dialog program and a report?
What is collective search help? : sap abap data dictionary
What does the ‘suppress dialog’ do?
What is bdc programming in sap?
What’s value table?