Hi, My question is " How to display 3rd highest salary
record from the internal table. The internal table has 2
fields named emno(Employee number) and salary.".
Send answer to my mail shaiksha.it@gmail.com.
Thanking you.
Answer Posted / 7hills
DATA :
BEGIN OF emp,
xcode TYPE STRING,
xname TYPE STRING,
xbasic TYPE P DECIMALS 2,
END OF EMP,
gt_emp LIKE TABLE OF emp,
gw_emp LIKE LINE OF gt_emp.
*EMP 1*
CLEAR gw_emp.
gw_emp-xcode = 'EMP001'.
gw_emp-xname = 'JAMES'.
gw_emp-xbasic = '4500'.
APPEND gw_emp TO gt_emp.
*EMP 2*
CLEAR gw_emp.
gw_emp-xcode = 'EMP002'.
gw_emp-xname = 'TOM'.
gw_emp-xbasic = '2450'.
APPEND gw_emp TO gt_emp.
*EMP 3*
CLEAR gw_emp.
gw_emp-xcode = 'EMP003'.
gw_emp-xname = 'JACK'.
gw_emp-xbasic = '2300'.
APPEND gw_emp TO gt_emp.
*EMP 4*
CLEAR gw_emp.
gw_emp-xcode = 'EMP004'.
gw_emp-xname = 'NAGS'.
gw_emp-xbasic = '2200'.
APPEND gw_emp TO gt_emp.
*EMP 5*
CLEAR gw_emp.
gw_emp-xcode = 'EMP005'.
gw_emp-xname = 'GUNTA'.
gw_emp-xbasic = '2000'.
APPEND gw_emp TO gt_emp.
CLEAR gw_emp.
WRITE : /.
WRITE : / 'Internal table before sorting', /.
LOOP AT gt_emp INTO gw_emp.
WRITE :/ gw_emp-xcode, gw_emp-xname, gw_emp-xbasic.
ENDLOOP.
WRITE : /.
WRITE : / 'Internal table after sorting', /.
SORT gt_emp ASCENDING BY xbasic DESCENDING.
LOOP AT gt_emp INTO gw_emp.
WRITE :/ gw_emp-xcode, gw_emp-xname, gw_emp-xbasic.
ENDLOOP.
WRITE : /.
WRITE : / 'Displaying 3rd highest salary from the itab', /.
CLEAR gw_emp.
READ TABLE gt_emp INTO gw_emp INDEX 3.
WRITE :/ gw_emp-xcode, gw_emp-xname, gw_emp-xbasic.
Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
What is size category?
What are multiple use BADIS?
While using extract datasets it is required to have a special workarea for interface. State true or false. : abap modularization
What application areas are you comfortable in?
What is the abap program name to process the batch input session automatically? : abap bdc
What is ole?
How can we set the table spaces and extent sizes? : abap data dictionary
What are field symbols?
In order to upload purchase order details, how you handle multiple values for a single field?
Which function module would you use to check the user’s authorization to access files before opening a file?
What is IMG in SAP?
List the events in abap/4 language?
What is the process to enhance the Infotype
Explain the difference between cluster tables and pool table?
Reports: Event functionality.