Skip to Content

Check of data in internal table

Nov 26, 2017 at 07:39 PM


avatar image


I am looking for a solution for a specific analysis on table EASTL. As you can see on the screenshot the two logical numbers 5317 and 21506 (EASTL-LOGIKNR) are assigned to installation 21795 (EASTL-ANLAGE). I would like to find all other installations having the same devices installed in the same period as the installation I want to compare against.

In this example the result should be: installation 5354.

What's the simplest way to do that?devicedata.png

devicedata.png (16.3 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Evgeniy Astafev Nov 27, 2017 at 04:43 AM

Did you try join EASTL with EASTL? Something like this:

SELECT a~anlage, a~logiknr, a~bis, a~ab, b~anlage
  FROM eastl AS a JOIN eastl AS b ON a~anlage = b~anlage
                                 AND a~logiknr = b~logiknr
                                 AND a~bis = b~bis
  WHERE a~anlage = 21795
    AND a~anlage <> b~anlage
10 |10000 characters needed characters left characters exceeded
Sandra Rossi Nov 26, 2017 at 08:26 PM

Loop at all installations having the first logical number 5317. Within the loop, for each of these installations, read the same internal table with logical number 21506. Check the dates, and make sure to use adequate sorted/hashed index(es) for a better performance.

10 |10000 characters needed characters left characters exceeded
Thomas Schleicher
Nov 27, 2017 at 08:30 PM

I prefer to do it based on an internal data, because I have already read all the relevant data before.

For that reason my results look like this now:

lt_eastl_temp TYPE TABLE OF eastl,
lt_eastl_all TYPE TABLE OF eastl,
lt_eastl_check TYPE TABLE OF eastl,
f_double TYPE abap_bool,
ld_count_devices TYPE i,
ld_last_anlage TYPE anlage,
ld_double TYPE abap_bool.

<fs_eastl> TYPE eastl,
<fs_eastl_temp> TYPE eastl.


SELECT * FROM eastl INTO TABLE lt_eastl_temp
WHERE anlage = '0000021795' AND
bis = zslo_ccw_mame=>co_datemax.

IF lt_eastl_temp IS NOT INITIAL.
SELECT * FROM eastl INTO TABLE lt_eastl_all
FOR ALL ENTRIES IN lt_eastl_temp
WHERE logiknr = lt_eastl_temp-logiknr.
SORT lt_eastl_all BY logiknr ASCENDING.

LOOP AT lt_eastl_all ASSIGNING <fs_eastl>
WHERE anlage = '0000021795'.
LOOP AT lt_eastl_all ASSIGNING <fs_eastl_temp>
WHERE anlage NE '0000021795' AND
logiknr EQ <fs_eastl>-logiknr AND
bis EQ <fs_eastl>-bis AND
ab EQ <fs_eastl>-ab.
APPEND <fs_eastl_temp> TO lt_eastl_check.
SORT lt_eastl_check BY anlage ASCENDING.
LOOP AT lt_eastl_check ASSIGNING <fs_eastl>.
IF ld_last_anlage = <fs_eastl>-anlage.
ADD 1 TO ld_count_devices.
IF ld_count_devices GE 2.
f_double = abap_true.
ld_count_devices = 1.
ld_last_anlage = <fs_eastl>-anlage.
IF f_double = abap_true.
WRITE 'LOGIKNRs of primary installation assigned multiple times'.

Any ideas to improve?

10 |10000 characters needed characters left characters exceeded