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

Did you create primary index?

736


What are pooled tables? : abap data dictionary

869


How will you link form with the event driven in sap scripts?

717


how to create view in bdc..??

2544


how to use table control?if suppose i have 6 records and i want more 4 records in sequence.How to handle this scenario?

1791






What is the table buffer? Which type of tables used this buffer?

747


What is the difference between abap and hr abap? : abap hr

818


How we can retrieve data using secondary index. Explain with simple example?

862


How do you get the number of lines in an internal table? How to use a specific number occurs statement?

691


What are roles and authorization objects?

1397


What is the use of enqueue function module? : sap abap data dictionary

809


What is the collect statement? How is it different from append?

743


What are the arithmetic operators in the sap abap?

783


What is pakey structure, pshd1 structure and what type of fields it contains? : abap hr

912


How do you display a data in a detail list?

760