Search
Search

# link of table ANLC with ANLA

Hello experts,

I am trying to get the latest values from anlc where its ANLN1, ANLN2 and BUKRS is equal to ANLA of the same fields and ANLA-DEAKT IS INITIAL.

Here is a scenario(when I checked in SE16):

Table ANLA - one entry found

BUKRS = 'ABC'

ANLN1 = 651825

ANLN2 = 0

DEAKT = 00/00/0000

Table ANLC - multiple entries found

BUKRS = 'ABC'

ANLN1 = 651825

ANLN2 = 0

GJAHR = from year 1999 to 2006

Now, This has been bugging me for the longest time. How can I get the latest record in ANLC(so in this case, it is the record with a gjahr of 2006) based from ANLA where its DEAKT is '00/00/0000'?

##### Neil Woodruffreplied

select * from anlc up to 1 rows

where bukrs = anla-bukrs

and anln1 = anla-anln1

and anln2 = anla-anln2

order by gjahr descending

.

endselect.

But you could change the anla select to a join,

select * from anla

join anlc on anlcbukrs = anlabukrs

and anlcanln1 = anlaanln1

and anlcanln2 = anlaanln2 up to 1 rows

into corresponding fields of table your_table

order by gjahr descending

.

endselect.

delete adjacent duplicates FROM YOUR_TABLE comparing bukrs anln1 anln2.

or you could just read anlc entries into a table,

select * from anlc

INTO CORRRESPONDING FIELDS OF TABLE OF T_ANLC

where bukrs = anla-bukrs

and anln1 = anla-anln1

and anln2 = anla-anln2

.

SORT T_ANLC BY GJAHR DESCENDING.

delete adjacent duplicates FROM T_ANLC comparing bukrs anln1 anln2.

0 View this answer in context
View more on this topic or