abap-cleaner icon indicating copy to clipboard operation
abap-cleaner copied to clipboard

Feature Request: Replace "IF ... res = abap_true ELSE res = abap_false" with xsdbool

Open aviplot opened this issue 1 year ago • 2 comments

Replace a true / false based on IF statement, with boolc or other respective inner functions. For example:

IF field1 > 1 AND other_field < 2.
  res = abap_true.
ELSE.
  res = abap_false.
ENDIF.

can easily replaced with:

res = boolc(  field > 1 AND other_field < 2 ).

BTW, I'll be happy to contribute and implement that myself. I've tried to compile that project but failed on dependencies:

import com.sap.adt.tools.abapsource.parser.ABAPRndParser;
import com.sap.rnd.rndrt.Category;
import com.sap.rnd.rndrt.ErrorState;

Is there a tutorial how to build that project? (abap-cleaner) Thanks

aviplot avatar Dec 02 '24 08:12 aviplot

I support this suggestion. :)

By the way, you should prefer xsdbool to boolc. See here for more details: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-xsdbool-to-set-boolean-variables

You can also watch this issue for a contribution guideline: https://github.com/SAP/abap-cleaner/issues/30

ConjuringCoffee avatar Dec 02 '24 12:12 ConjuringCoffee

Hi Avraham,

that's a nice idea for sure, and you're right, I still owe the community some pages on setup for contributors!

Essentially, you need a target platform in which ABAP Development Tools is installed:

  • Download and extract a current Eclipse, e.g. Eclipse 2024-09 (4.33) as the target IDE
  • Start target IDE, open menu "Help / Install New Software …" and in the "Work with" field, enter a suitable link for SAP Development Tools (e.g. https://tools.hana.ondemand.com/2024-09 or https://tools.hana.ondemand.com/latest) and press ENTER
  • Select ABAP Development Tools and follow the wizard to install ADT into the target IDE.

Then, in your development IDE, in which you edit the ABAP cleaner code, use menu "Window / Preferences" -> Plug-in Development -> Target Platform to select the target IDE (Add … -> Locations -> Add … -> Directory -> select local folder that contains the eclipse.exe of the target IDE).

Hope that works – more extended description to follow!

Kind regards, Jörg-Michael

jmgrassau avatar Dec 06 '24 07:12 jmgrassau