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 / jitendra

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.

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.
SORT ITAB BY SAL DESCENDING.
READ TABLE ITAB INTO WA_IT INDEX '3'.
SAAL = WA_IT-SAL.
clear wa_it.

LOOP AT ITAB INTO WA_IT where sal eq saal.
*append wa_it to itab1.
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 the difference between a pool table and a transparent table?

532


How did you transfer legacy data in the mid of the financial year (us) to the sap system? : sap abap hr

536


What is asynchronous update?

570


What are the different types of parameters? : abap modularization

606


What is value table?

571






What are the steps to execute session method?

593


What is synchronous update?

564


Explain Singleton class

830


How do you take care of performance issues in your ABAP programs?

660


What is tcode se16? For what is it used.

579


Can there be more than 1 main window in sap script?

611


How does the system handle roll areas for external program components?

618


How can cluster table be created?

650


Can i Have Some Examples on Enhancements.

1968


What is the diffreence between bdc_close_group and bdc_close_dataset? : abap bdc

602