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


Please Help Members By Posting Answers For Below Questions

What are the different types of views in sap? : abap data dictionary

624


What is an evaluation path? : sap abap hr

567


What is the max no of match code id's that can be defined for one match code object? : abap data dictionary

660


What is the use of buffering?

574


How to give programe name as input in BDC report of abap ?

1743






What are the names of the function modules that will be generated upon activation of a lock object?

561


A field containing currency amounts (data type curr) must be assigned to a reference table and a reference field. Explain?

883


What is a table cluster? : abap data dictionary

747


Define batch input session?

589


function modules are also external subroutines. State true or false. : abap modularization

611


What is the sap abap?

639


What are the abap/4 commands that link to a layout set?

886


What are th control break events in abap?

618


Can we define our own match code id's for sap matchcodes ?

598


Can we reuse a userexit?

1083