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 / nandana sai

TYPES : BEGIN OF ty,
eno(6) TYPE c,
sal TYPE labst,
END OF ty.

DATA : itab TYPE STANDARD TABLE OF ty,
wa_it TYPE ty,
itab1 TYPE STANDARD TABLE OF ty,
wa_it1 TYPE ty.

DATA : saal TYPE labst.

wa_it-eno = '1000'.
wa_it-sal = '10000'.
APPEND wa_it TO itab.
CLEAR wa_it.

wa_it-eno = '1001'.
wa_it-sal = '19000'.
APPEND wa_it TO itab.
CLEAR wa_it.

wa_it-eno = '1002'.
wa_it-sal = '10500'.
APPEND wa_it TO itab.
CLEAR wa_it.

wa_it-eno = '1003'.
wa_it-sal = '10080'.
APPEND wa_it TO itab.
CLEAR wa_it.

wa_it-eno = '1004'.
wa_it-sal = '10200'.
APPEND wa_it TO itab.
CLEAR wa_it.

wa_it-eno = '1006'.
wa_it-sal = '10400'.
APPEND wa_it TO itab.
CLEAR wa_it.

wa_it-eno = '1005'.
wa_it-sal = '10400'.
APPEND wa_it TO itab.
CLEAR wa_it.

wa_it-eno = '1007'.
wa_it-sal = '19000'.
APPEND wa_it TO itab.
CLEAR wa_it.

SORT itab BY sal DESCENDING.

itab1 = itab.

DELETE ADJACENT DUPLICATES FROM itab1 COMPARING sal.

READ TABLE itab1 INTO wa_it1 INDEX '3'.
saal = wa_it1-sal.

LOOP AT itab INTO wa_it WHERE sal EQ saal.

WRITE :/ wa_it-eno, 10 wa_it-sal.
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 a transport?

616


What are the major steps will you use for tuning?

587


How do you backup Sapscript layout sets? Can you download and upload? How?

621


Difference between sap script and report?

738


What are the dynamic actions and how to configure it? : sap abap hr

575






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

540


What is the difference between table and template?

566


What function does data dictionary perform?

562


Difference between transparent tables and pooled tables? : abap hr

546


What are the internal tables and work area?

543


What is the relationship existing between the various data elements in data dictionary? : abap data dictionary

711


What is the difference between function group and function module?

511


How can we use / display table in a screen?

628


What is the use of info groups? : sap abap hr

550


What is a transaction variant and why are they used?

539