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.

Answers were Sorted based on User's Feedback



Hi, My question is " How to display 3rd highest salary record from the internal table. The int..

Answer / naresh

Sort the internal table by descending order based on
salary.then read the table with index 3.

read table itab into w_itab index = 3.

Is This Answer Correct ?    34 Yes 4 No

Hi, My question is " How to display 3rd highest salary record from the internal table. The int..

Answer / dileep kumar chinnaiah

READ TABLE gt_emp INTO gw_emp INDEX 3.

Does not work's if two employees has same salaries. So stop
following this procedure.

The Interviewer exactly looking for Control break statements.
use Sort descending by salary & loop internal table. &
maintain a counter under "AT NEW" & catch the value of
employee ID, when your condition triggers.

Is This Answer Correct ?    15 Yes 2 No

Hi, My question is " How to display 3rd highest salary record from the internal table. The int..

Answer / deepak kumar

SORT THE INTERNAL TABLE IN DECENDING ORDER

READ TABLE ITAB INTO WA_ITAB INDEX 3.

WRITE:/ WA_ITAB-FIELDNAME.

Is This Answer Correct ?    10 Yes 6 No

Hi, My question is " How to display 3rd highest salary record from the internal table. The int..

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

Hi, My question is " How to display 3rd highest salary record from the internal table. The int..

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

Hi, My question is " How to display 3rd highest salary record from the internal table. The int..

Answer / tiki patra

SORT itab DECENDING salary.
DELETE ADJACENT DUPLICATE COMPARING salary.
READ TABLE itab into wa INDEX 3.

WRITE:/ wa-salary.

Is This Answer Correct ?    3 Yes 2 No

Hi, My question is " How to display 3rd highest salary record from the internal table. The int..

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

Hi, My question is " How to display 3rd highest salary record from the internal table. The int..

Answer / shaiksha

Extract the content of 2nd field Using... <Select distinct
salary from ztable_emp into .... order by descending.>. Now
you can have all records in it table, exactly 3rd record
itself is highest salary record. Then basing salary extract
entire record using select statement.

Is This Answer Correct ?    4 Yes 4 No

Hi, My question is " How to display 3rd highest salary record from the internal table. The int..

Answer / sivaramakrishna

first sort the internal table and now using do statement
for 3 repetetions using local varieble. inside do
statement use the loop statement for reading the records
from internal table to work area.

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More SAP ABAP Interview Questions

can i use data element or domain in the program and how

3 Answers   HCL,


What are system fields for secondary lists?

0 Answers  


What are the different types of view?

0 Answers  


Hi All, Can u tell me the difference between RFC and BAPI. I know Both are remote enabled.

2 Answers   IBM,


What is the relation between Badi and Bapi ?

1 Answers   Accenture,






how many indexes can be created for a table?

7 Answers   Wipro,


Hi, I have 100 records in a table, how to read every 7Th record each in that...

3 Answers   Infosys, TCS,


Explain what are the different functions used in sap script? What are the parameters used in each function?

0 Answers  


what type of error exactly you will be seeing in the log file while using call transaction mode ā€˜Eā€™

2 Answers   EDS,


Do you use select statement in loop end loop, how will be the performance? To improve the performance?

2 Answers  


which layout sets you used?

1 Answers   Wipro,


If there are 100 records...explain the BDC session method step by step how you gonna do ?

2 Answers   Deloitte,


Categories
  • SAP Basis Interview Questions SAP Basis (1262)
  • SAP ABAP Interview Questions SAP ABAP (3939)
  • SAPScript Interview Questions SAPScript (236)
  • SAP SD (Sales & Distribution) Interview Questions SAP SD (Sales & Distribution) (2716)
  • SAP MM (Material Management) Interview Questions SAP MM (Material Management) (911)
  • SAP QM (Quality Management) Interview Questions SAP QM (Quality Management) (99)
  • SAP PP (Production Planning) Interview Questions SAP PP (Production Planning) (523)
  • SAP PM (Plant Maintenance) Interview Questions SAP PM (Plant Maintenance) (252)
  • SAP PS (Project Systems) Interview Questions SAP PS (Project Systems) (138)
  • SAP FI-CO (Financial Accounting & Controlling) Interview Questions SAP FI-CO (Financial Accounting & Controlling) (2766)
  • SAP HR (Human Resource Management) Interview Questions SAP HR (Human Resource Management) (1180)
  • SAP CRM (Customer Relationship Management) Interview Questions SAP CRM (Customer Relationship Management) (432)
  • SAP SRM (Supplier Relationship Management) Interview Questions SAP SRM (Supplier Relationship Management) (132)
  • SAP APO (Advanced Planner Optimizer) Interview Questions SAP APO (Advanced Planner Optimizer) (92)
  • SAP BW (Business Warehouse) Interview Questions SAP BW (Business Warehouse) (896)
  • SAP Business Workflow Interview Questions SAP Business Workflow (72)
  • SAP Security Interview Questions SAP Security (597)
  • SAP Interfaces Interview Questions SAP Interfaces (74)
  • SAP Netweaver Interview Questions SAP Netweaver (282)
  • SAP ALE IDocs Interview Questions SAP ALE IDocs (163)
  • SAP Business One Interview Questions SAP Business One (110)
  • SAP BO BOBJ (Business Objects) Interview Questions SAP BO BOBJ (Business Objects) (388)
  • SAP CPS (Central Process Scheduling) Interview Questions SAP CPS (Central Process Scheduling) (14)
  • SAP GTS (Global Trade Services) Interview Questions SAP GTS (Global Trade Services) (21)
  • SAP Hybris Interview Questions SAP Hybris (132)
  • SAP HANA Interview Questions SAP HANA (700)
  • SAP PI (Process Integration) Interview Questions SAP PI (Process Integration) (113)
  • SAP PO (Process Orchestration) Interview Questions SAP PO (Process Orchestration) (25)
  • SAP BI (Business Intelligence) Interview Questions SAP BI (Business Intelligence) (174)
  • SAP BPC (Business Planning and Consolidation) Interview Questions SAP BPC (Business Planning and Consolidation) (38)
  • SAP BODS (Business Objects Data Services) Interview Questions SAP BODS (Business Objects Data Services) (49)
  • SAP BODI (Business Objects Data Integrator) Interview Questions SAP BODI (Business Objects Data Integrator) (26)
  • SAP Ariba Interview Questions SAP Ariba (9)
  • SAP Fiori Interview Questions SAP Fiori (45)
  • SAP EWM (Extended Warehouse Management) Interview Questions SAP EWM (Extended Warehouse Management) (58)
  • Sap R/3 Interview Questions Sap R/3 (150)
  • SAP FSCM Financial Supply Chain Management Interview Questions SAP FSCM Financial Supply Chain Management (101)
  • SAP WM (Warehouse Management) Interview Questions SAP WM (Warehouse Management) (31)
  • SAP GRC (Governance Risk and Compliance) Interview Questions SAP GRC (Governance Risk and Compliance) (64)
  • SAP MDM (Master Data Management) Interview Questions SAP MDM (Master Data Management) (0)
  • SAP MRS (Multi Resource Scheduling) Interview Questions SAP MRS (Multi Resource Scheduling) (0)
  • SAP ESS MSS (Employee Manager Self Service) Interview Questions SAP ESS MSS (Employee Manager Self Service) (13)
  • SAP CS (Customer Service) Interview Questions SAP CS (Customer Service) (0)
  • SAP TRM (Treasury and Risk Management) Interview Questions SAP TRM (Treasury and Risk Management) (0)
  • SAP Web Dynpro ABAP Interview Questions SAP Web Dynpro ABAP (198)
  • SAP IBP (Integrated Business Planning) Interview Questions SAP IBP (Integrated Business Planning) (0)
  • SAP OO-ABAP (Object Oriented ABAP) Interview Questions SAP OO-ABAP (Object Oriented ABAP) (70)
  • SAP S/4 HANA Finance (Simple Finance) Interview Questions SAP S/4 HANA Finance (Simple Finance) (143)
  • SAP FS-CD (Collections and Disbursements) Interview Questions SAP FS-CD (Collections and Disbursements) (0)
  • SAP PLM (Product Lifecycle Management) Interview Questions SAP PLM (Product Lifecycle Management) (0)
  • SAP SuccessFactors Interview Questions SAP SuccessFactors (33)
  • SAP Vistex Interview Questions SAP Vistex (0)
  • SAP ISR (IS Retail) Interview Questions SAP ISR (IS Retail) (28)
  • SAP IdM (Identity Management) Interview Questions SAP IdM (Identity Management) (0)
  • SAP IM (Investment Management) Interview Questions SAP IM (Investment Management) (0)
  • SAP UI5 Interview Questions SAP UI5 (59)
  • SAP SCM (Supply Chain Management) Interview Questions SAP SCM (Supply Chain Management) (51)
  • SAP XI (Exchange Infrastructure) Interview Questions SAP XI (Exchange Infrastructure) (49)
  • SAP Cloud Platform Interview Questions SAP Cloud Platform (34)
  • SAP Testing Interview Questions SAP Testing (89)
  • SAP SolMan (Solution Manager) Interview Questions SAP SolMan (Solution Manager) (63)
  • SAP MaxDB Interview Questions SAP MaxDB (116)
  • SAP GUI Interview Questions SAP GUI (15)
  • SAP AllOther Interview Questions SAP AllOther (329)