-1

# Check of data in internal table

Nov 26, 2017 at 07:39 PM

62

Hi,

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)

Evgeniy Astafev Nov 27, 2017 at 04:43 AM
0

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```
Share
Sandra Rossi Nov 26, 2017 at 08:26 PM
0

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.

Share
Thomas Schleicher
Nov 27, 2017 at 08:30 PM
0

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:

DATA:
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.

FIELD-SYMBOLS:
<fs_eastl> TYPE eastl,
<fs_eastl_temp> TYPE eastl.

START-OF-SELECTION.

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.
ENDLOOP.
ENDLOOP.
ENDIF.
SORT lt_eastl_check BY anlage ASCENDING.
LOOP AT lt_eastl_check ASSIGNING <fs_eastl>.
IF ld_last_anlage = <fs_eastl>-anlage.
IF ld_count_devices GE 2.
f_double = abap_true.
ENDIF.
ELSE.
ld_count_devices = 1.
ENDIF.
ld_last_anlage = <fs_eastl>-anlage.
ENDLOOP.
IF f_double = abap_true.
WRITE 'LOGIKNRs of primary installation assigned multiple times'.
ENDIF.

Any ideas to improve?

Share