ABAP Forum
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ADT Extract Method error if the code contains SUBMIT AND RETURN

Sandra_Rossi
Active Contributor
0 Likes
107

If I extract code containing SUBMIT ... AND RETURN, there is the error:

Refactoring Condition Check Failed

Source contains program flow change by RETURN. Refactoring is not possible.

 

SUBMIT fagl_account_balance
       AND RETURN.

Sandra_Rossi_4-1791528726378.png

Sandra_Rossi_1-1791528576697.png

Sandra_Rossi_5-1791528764160.png

Workaround

Of course, the workaround is to temporarily comment out SUBMIT and uncomment after the refactoring.

Question

Is this problem fixed? In which version?

Thanks.

Sandra

My system: Eclipse 2025-09, ADT 3.52.3, backend 7.58 SP 1.

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
91

Short answer: the bug is in the method CAN_BE_EXTRACTED of the class CL_ART_SNIPPET (below are the details).

There's currently no SAP note containing a fix in that method.

Sandra

Detailed analysis

The ADT communication log indicates this data when using Extract Method (program named Z_DEMO_PROGRAM):

POST /sap/bc/adt/refactorings?step=evaluate&rel=http%3A%2F%2Fwww.sap.com%2Fadt%2Frelations%2Frefactoring%2Fextractmethod&uri=%2Fsap%2Fbc%2Fadt%2Fprograms%2Fprograms%2Fz_demo_program%2Fsource%2Fmain%23start%3D171%2C0%3Bend%3D176%2C0 HTTP/1.1

Sandra_Rossi_0-1791530895492.png

Error code: SRFAC_IMPL056

The debug of the ADT tools indicates that the error code is sent by the method CAN_BE_EXTRACTED of the class CL_ART_SNIPPET:

Sandra_Rossi_1-1791530975073.png

Sandra_Rossi_2-1791534264020.png

Call stack (class on the left followed by the method):

  • CL_PST_STATEMENT contains_keyword [method]
  • CL_ART_SNIPPET can_be_extracted [method]
  • CL_RFAC_SELECTION_ANALYZER check_extract_method_supported [method]
  • CL_RFAC_SELECTION_ANALYZER if_rfac_selection_analyzer~get_selection_as_method [method]
  • CL_RFAC_EXTRACT_METHOD determine_method_description [method]
  • CL_RFAC_EXTRACT_METHOD get_method_description [method]
  • CL_RFAC_ADT_EXTRACT_METHOD if_rfac_adt_refactoring~create_evaluate_result [method]
  • CL_RFAC_ADT_RES_REFACTORING evaluate [method]
  • CL_RFAC_ADT_RES_REFACTORING post [method]
  • CL_ADT_REST_RESOURCE if_rest_handler~handle [method]
  • CL_REST_ROUTER if_rest_handler~handle [method]
  • CL_REST_RFC_UTILITIES call_rest_rfc_handler [method]
  • Function module SADT_REST_RFC_ENDPOINT

I can conclude that Extract Method fails incorrectly on these 2 ABAP statements based on the Index of the ABAP 7.58 Keyword documentation (search by full word RETURN):

  • SUBMIT ... AND RETURN
  • LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN ...

View solution in original post

If I extract code containing SUBMIT ... AND RETURN, there is the error:

Refactoring Condition Check Failed

Source contains program flow change by RETURN. Refactoring is not possible.

 

SUBMIT fagl_account_balance
       AND RETURN.

Sandra_Rossi_4-1791528726378.png

Sandra_Rossi_1-1791528576697.png

Sandra_Rossi_5-1791528764160.png

Workaround

Of course, the workaround is to temporarily comment out SUBMIT and uncomment after the refactoring.

Question

Is this problem fixed? In which version?

Thanks.

Sandra

My system: Eclipse 2025-09, ADT 3.52.3, backend 7.58 SP 1.

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
92

Short answer: the bug is in the method CAN_BE_EXTRACTED of the class CL_ART_SNIPPET (below are the details).

There's currently no SAP note containing a fix in that method.

Sandra

Detailed analysis

The ADT communication log indicates this data when using Extract Method (program named Z_DEMO_PROGRAM):

POST /sap/bc/adt/refactorings?step=evaluate&rel=http%3A%2F%2Fwww.sap.com%2Fadt%2Frelations%2Frefactoring%2Fextractmethod&uri=%2Fsap%2Fbc%2Fadt%2Fprograms%2Fprograms%2Fz_demo_program%2Fsource%2Fmain%23start%3D171%2C0%3Bend%3D176%2C0 HTTP/1.1

Sandra_Rossi_0-1791530895492.png

Error code: SRFAC_IMPL056

The debug of the ADT tools indicates that the error code is sent by the method CAN_BE_EXTRACTED of the class CL_ART_SNIPPET:

Sandra_Rossi_1-1791530975073.png

Sandra_Rossi_2-1791534264020.png

Call stack (class on the left followed by the method):

  • CL_PST_STATEMENT contains_keyword [method]
  • CL_ART_SNIPPET can_be_extracted [method]
  • CL_RFAC_SELECTION_ANALYZER check_extract_method_supported [method]
  • CL_RFAC_SELECTION_ANALYZER if_rfac_selection_analyzer~get_selection_as_method [method]
  • CL_RFAC_EXTRACT_METHOD determine_method_description [method]
  • CL_RFAC_EXTRACT_METHOD get_method_description [method]
  • CL_RFAC_ADT_EXTRACT_METHOD if_rfac_adt_refactoring~create_evaluate_result [method]
  • CL_RFAC_ADT_RES_REFACTORING evaluate [method]
  • CL_RFAC_ADT_RES_REFACTORING post [method]
  • CL_ADT_REST_RESOURCE if_rest_handler~handle [method]
  • CL_REST_ROUTER if_rest_handler~handle [method]
  • CL_REST_RFC_UTILITIES call_rest_rfc_handler [method]
  • Function module SADT_REST_RFC_ENDPOINT

I can conclude that Extract Method fails incorrectly on these 2 ABAP statements based on the Index of the ABAP 7.58 Keyword documentation (search by full word RETURN):

  • SUBMIT ... AND RETURN
  • LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN ...
Read only

0 Likes
87

So, you can get the same by commenting just the "and return" clause?
I will assume that if some day SAP fixes that, it will do for the VSC ADT and we, eclipse dinosaurs, will need to adapt to it. (until SAP changes direction again, when we'll get used to VSC ADT)