Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Extract organization by sorting date

Former Member
0 Likes
669

hi

An employee in an org. can be in different units in different time.I want to extract the employees organization in which he is currently working with.

 MANDT PERNR ENDDA      BEGDA      UNAME  PERSK    ORGEH    PLANS    STELL

  200       3 31.12.9999 24.02.2009 122910 11    10100519 50001466 80000301
  200       3 23.02.2009 01.11.2008 106953 11    10100519 50001466 80000301
  200       3 31.10.2008 01.10.2008 106953 10    10100463 50000005 80000002
  200       3 30.09.2008 04.09.2008 106953 10    10100008 50002108 80000404

I have to extract ORGEH corresponding to latest DATE i.e. ENDDA

How to sort the date ?

Sachin

1 ACCEPTED SOLUTION
Read only

GauthamV
Active Contributor
0 Likes
634

use this.

SORT itab BY pernr endda DESCENDING.

5 REPLIES 5
Read only

GauthamV
Active Contributor
0 Likes
635

use this.

SORT itab BY pernr endda DESCENDING.

Read only

Former Member
0 Likes
634

hi

i am using the query

SELECT orgeh from pa0001 INTO lv_emp_org UP TO 1 rows

WHERE pernr = 00000003 and

????????????????

ENDSELECT.

I want sort the endda in descending order and than want to extract the first record,,,??

Read only

Former Member
0 Likes
634

> SELECT orgeh from pa0001 INTO lv_emp_org UP TO 1 rows

> WHERE pernr = 00000003

> ORDER BY date_field DESCENDING.

> ENDSELECT.

Try like this.

Regards

Karthik D

Read only

Former Member
0 Likes
634

Hi,

Sort itab by ENDDA in descending order and read the first record. You will get what you required.

Thanks,

Rakesh.

Read only

Former Member
0 Likes
634

Hi,

After fectching the records from infotype 0001.

if not itab[] is initial.

Sort itab by pernr begda descending.

delete adjacent duplicates from itab comparing pernr.

endif.

So you will get latest record for each pernr.

Regards,

Kumar Bandanadham.