Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positives for CHECK statement inside a loop #603

Open
sachin-b-k opened this issue Aug 25, 2023 · 3 comments
Open

False positives for CHECK statement inside a loop #603

sachin-b-k opened this issue Aug 25, 2023 · 3 comments
Labels
bug Something isn't working correctly

Comments

@sachin-b-k
Copy link

馃挕 Code pal for ABAP follows the Clean ABAP. If the issue relates to coding style, please submit it here.

Check Name
CHECK Statement Position Check

Actual Behavior
It is showing errors for few CHECK statements which are inside LOOP or DO statements in the methods PREPARE_AIF_MESSAGES, ADD_COSP_AMOUNTS, ADD_COSP_QUANTITIES, of class CL_FINS_CFIN_PD_C2A_REPLICATOR and for the method CHECK_COSP_AMOUNTS_ITEM and local test class of the class CL_FINS_CFIN_PD_C2A_AGENT.

Expected Behavior
According to the documentation of the check, if the check statement occurs inside a loop then it should not shown as an error.

@sachin-b-k sachin-b-k added the bug Something isn't working correctly label Aug 25, 2023
@bjoern-jueliger-sap
Copy link
Member

  1. Are you sure the findings you're getting are from CHECK Statement Position and not from CHECK in LOOP?
  2. Please provide actual code examples (that one could copy into any system and that would produce the false positive) instead of referring to object names: This is an open source repository and customers typically cannot scan SAP code with ATC, so contributors outside of SAP would be unable to reproduce this issue as described.

@sachin-b-k
Copy link
Author

Hello Bjoern,

  1. Yes the findings are from CHECK Statement Position.

  2. Please find below the code examples. For all the check statement in the below example the error is shown.

    LOOP AT lt_e070a ASSIGNING FIELD-SYMBOL(<fs_e070a>).
    LOOP AT lt_e070 ASSIGNING FIELD-SYMBOL(<fs_e070>).
    LOOP AT lt_e071 ASSIGNING FIELD-SYMBOL(<fs_e071>).

     ENDLOOP.
    

    ENDLOOP.

    CHECK <fs_e070a>-trkorr IS NOT INITIAL.

    ENDLOOP.

    DO 4 TIMES.
    DO 6 TIMES.
    CASE ev_yrsof_srvc.
    WHEN 1.
    CHECK ev_yrsof_srvc = 1.
    WHEN 2.
    CHECK ev_yrsof_srvc = 2.
    WHEN OTHERS.
    ENDCASE.
    ENDDO.

    ENDDO.

@bjoern-jueliger-sap
Copy link
Member

Ah, yes,

is too naive: It only checks whether there's any LOOPs in the innermost structure containing the CHECK statement, but in order to tell whether we're inside a loop at all this should check all enclosing structures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

2 participants