abaplint icon indicating copy to clipboard operation
abaplint copied to clipboard

unused_ddic - foreign key in another table

Open Zeatynis opened this issue 3 years ago • 13 comments

Hi, shouldn't this rule check also if other tables are referencing to the currently checked table? obraz

obraz

Zeatynis avatar Feb 04 '22 08:02 Zeatynis

yes, can you help creating a public example? just a few dummy objects should be enough to reproduce this error?

larshp avatar Feb 04 '22 08:02 larshp

Yes, ofc. Two Z tables should be enough, right?

Zeatynis avatar Feb 04 '22 08:02 Zeatynis

yea, try :)

larshp avatar Feb 04 '22 08:02 larshp

Funny thing: on version 2.74.61 it's ok 😄 Here are samples you asked about:

@EndUserText.label : 'AbapLint test table 1'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zlint_test1 {
  key client : abap.clnt not null;
  key bukrs  : bukrs not null;
}
@EndUserText.label : 'AbapLint test table 2'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zlint_test2 {
  key client : abap.clnt not null;
  @AbapCatalog.foreignKey.screenCheck : false
  key bukrs  : bukrs not null
    with foreign key zlint_test1
      where client = zlint_test2.client
        and bukrs = zlint_test2.bukrs;

}
CLASS zlint_test DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    TYPES ty_bukrs_config TYPE STANDARD TABLE OF zlint_test1 WITH KEY bukrs.
    METHODS get_bukrs_config
      RETURNING VALUE(bukrs_config) TYPE ty_bukrs_config.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.



CLASS zlint_test IMPLEMENTATION.
  METHOD get_bukrs_config.
    SELECT bukrs INTO TABLE bukrs_config
      FROM zlint_test1
      ORDER BY PRIMARY KEY.
    ASSERT sy-subrc <> 0.

  ENDMETHOD.
ENDCLASS.

$ZABAPLINT_TEST_CASES_20220204_094524.zip

Zeatynis avatar Feb 04 '22 08:02 Zeatynis

how about latest, 2.85.9? does it give the false positive?

larshp avatar Feb 04 '22 09:02 larshp

Docker downloads 2.84.9 as latest and there is a false positive there.

Zeatynis avatar Feb 04 '22 09:02 Zeatynis

argh, the docker build keeps stopping every 60 days, anyhow, triggered again, latest should be up in a bit

larshp avatar Feb 04 '22 09:02 larshp

Yup, on 2.85.9 still false positive

Zeatynis avatar Feb 04 '22 10:02 Zeatynis

anyhow, need the files that abapGit creates, and as of now, TABL are serialized to XML by abapGit

larshp avatar Feb 04 '22 16:02 larshp

Here you can see the effect of the check. There are XMLs that you asked about. https://github.com/Zeatynis/abaplint-issue/commit/0dc66e613b05c332773dcf5470fc221b54814db0

Zeatynis avatar May 21 '22 14:05 Zeatynis

@Zeatynis try again, 2.91.0

larshp avatar Jun 05 '22 09:06 larshp

Same. You can check in my test repo: https://github.com/Zeatynis/abaplint-issue/actions/runs/2363288530

Zeatynis avatar Jun 06 '22 11:06 Zeatynis

the finding is correct, https://github.com/Zeatynis/abaplint-issue/search?q=zlint_test2

zlint_test2 is not used anywhere in the other objects?

larshp avatar Jun 06 '22 13:06 larshp

I just rechecked. It's resolved. I must have check it wrong.

Zeatynis avatar Jun 14 '23 15:06 Zeatynis