Skip to Content
0
Former Member
Jul 13, 2007 at 06:28 AM

Display records in Reverse order

61 Views

Hi,

How to display the records in the Reverse order.

Display the records from the internal table where the employee salary is highest in his department.

This is my program.

*LINE TYPE.

TYPES:

BEGIN OF TY_EMP,

EMPID(4) TYPE C,

ENAME(30) TYPE C,

DEPT(4) TYPE C,

GRADE(1) TYPE C,

SALARY TYPE I,

END OF TY_EMP.

  • TABLE TYPE

DATA:

FS_EMP TYPE TY_EMP,

IT_EMP TYPE TABLE OF TY_EMP.

FS_EMP-EMPID = 'E100'.

FS_EMP-ENAME = 'X'.

FS_EMP-DEPT = 'D100'.

FS_EMP-GRADE = 'A'.

FS_EMP-SALARY = 10000.

APPEND FS_EMP TO IT_EMP.

FS_EMP-EMPID = 'E200'.

FS_EMP-ENAME = 'Y'.

FS_EMP-DEPT = 'D200'.

FS_EMP-GRADE = 'A'.

FS_EMP-SALARY = 11000.

APPEND FS_EMP TO IT_EMP.

FS_EMP-EMPID = 'E101'.

FS_EMP-ENAME = 'Z'.

FS_EMP-DEPT = 'D100'.

FS_EMP-GRADE = 'A'.

FS_EMP-SALARY = 12000.

APPEND FS_EMP TO IT_EMP.

FS_EMP-EMPID = 'E103'.

FS_EMP-ENAME = 'B'.

FS_EMP-DEPT = 'D200'.

FS_EMP-GRADE = 'B'.

FS_EMP-SALARY = 8000.

APPEND FS_EMP TO IT_EMP.

FS_EMP-EMPID = 'E104'.

FS_EMP-ENAME = 'B'.

FS_EMP-DEPT = 'D200'.

FS_EMP-GRADE = 'B'.

FS_EMP-SALARY = 7000.

APPEND FS_EMP TO IT_EMP.

FS_EMP-EMPID = 'E105'.

FS_EMP-ENAME = 'C'.

FS_EMP-DEPT = 'D100'.

FS_EMP-GRADE = 'C'.

FS_EMP-SALARY = 5000.

APPEND FS_EMP TO IT_EMP.

FS_EMP-EMPID = 'E100'.

FS_EMP-ENAME = 'D'.

FS_EMP-DEPT = 'D200'.

FS_EMP-GRADE = 'B'.

FS_EMP-SALARY = 8500.

APPEND FS_EMP TO IT_EMP.

FS_EMP-EMPID = 'E200'.

FS_EMP-ENAME = 'E'.

FS_EMP-DEPT = 'D300'.

FS_EMP-GRADE = 'B'.

FS_EMP-SALARY = 9000.

APPEND FS_EMP TO IT_EMP.

FS_EMP-EMPID = 'E104'.

FS_EMP-ENAME = 'F'.

FS_EMP-DEPT = 'D300'.

FS_EMP-GRADE = 'A'.

FS_EMP-SALARY = 13000.

APPEND FS_EMP TO IT_EMP.

LOOP AT IT_EMP INTO FS_EMP.

WRITE:/ FS_EMP-EMPID,FS_EMP-ENAME,FS_EMP-DEPT,FS_EMP-GRADE,FS_EMP-SALARY.

ENDLOOP.