Clean abap

From marcellourbani/vscode_abap_remote_fs · View interactive version

Clean abap is an AI agent skill from the GitHub repository marcellourbani/vscode_abap_remote_fs. Clean ABAP style and maintainability guidance. Use when writing ABAP code or when a review explicitly asks for Clean ABAP style, readability, naming, structure, modern syntax, formatting, comments, or refactoring. For a general ABAP report correctness review, use abap-code-review-helper first; apply

How to use this skill

Skill file

Clean ABAP — AI-Optimized Rules

Distilled from the SAP Clean ABAP Style Guide.

Licensed under Creative Commons BY 3.0.

© SAP SE. Attribution preserved per license terms.

Apply ALL rules below when writing or reviewing ABAP code. Every rule is mandatory unless explicitly marked "consider".

Before writing, modifying, or reviewing ABAP code, read the abap-code-review-helper skill in full (skip if skill is unavailable), unless its complete contents are already available in your current context. Apply its correctness safeguards alongside these style rules; do not let a style preference change business behavior. Keep passed checks internal.


Names

```abap

DATA max_response_time_in_millisec TYPE i.

```

```abap

CLASS /clean/account.

METHODS read_entries.

IF is_empty( table ).

```

```abap

" good

result = a + b.

" bad

rv_result = iv_a + iv_b.

```

Language

```abap

FUNCTION check_business_partner [...].

DATA(validator) = NEW /clean/biz_partner_validator( ).

result = validator->validate( business_partners ).

ENDFUNCTION.

```

```abap

DATA(variable) = 'A'. " not MOVE

DATA(uppercase) = to_upper( str ). " not TRANSLATE

index += 1. " not ADD 1 TO

DATA(obj) = NEW /clean/cls( ). " not CREATE OBJECT

```

```abap

DATA(line) = value_pairs[ name = 'A' ].

```

```abap

SELECT * FROM spfli WHERE carrid = @carrid INTO TABLE @itab.

```

Constants

```abap

IF abap_type = cl_abap_typedescr=>typekind_date. " not 'D'

```

```abap

CONSTANTS status_inactive TYPE mmsta VALUE '90'. " not c_01

```

```abap

TYPES: BEGIN OF ENUM type, warning, error, END OF ENUM type.

```

```abap

CONSTANTS:

BEGIN OF message_severity,

warning TYPE symsgty VALUE 'W',

error TYPE symsgty VALUE 'E',

END OF message_severity.

```

Variables

```abap

DATA(name) = 'something'.

```

```abap

DATA name TYPE seoclsname.

DATA reader TYPE REF TO reader.

```

Tables

```abap

DATA itab TYPE STANDARD TABLE OF row_type WITH EMPTY KEY.

```

```abap

IF line_exists( my_table[ key = 'A' ] ).

```

```abap

TRY.

DATA(row) = my_table[ key = input ].

CATCH cx_sy_itab_line_not_found.

RAISE EXCEPTION NEW /clean/not_found( ).

ENDTRY.

```

Strings

```abap

DATA(msg) = |HTTP { status_code }: { text }|.

```

Booleans

```abap

DATA has_entries TYPE abap_bool.

IF has_entries = abap_false.

```

```abap

DATA(has_entries) = xsdbool( line IS NOT INITIAL ).

```

Conditions

```abap

IF condition_is_fulfilled( ). " not = abap_true

```

Ifs

Regular Expressions

Classes

Object Orientation

Scope

```abap

DATA name TYPE string READ-ONLY.

```

Constructors

```abap

CLASS-METHODS new_from_template IMPORTING template TYPE REF TO zcl_tmpl

RETURNING VALUE(result) TYPE REF TO zcl_doc.

CLASS-METHODS new_from_name IMPORTING name TYPE string

RETURNING VALUE(result) TYPE REF TO zcl_doc.

```

Methods

Calls

```abap

cl_my_class=>static_method( ). " not lo_instance->static_method( )

```

Object Orientation

Parameters

```abap

update_without_saving( ). " not update( do_save = abap_true )

update_and_save( ).

```

```abap

METHODS get_name RETURNING VALUE(result) TYPE string.

```

Parameter Initialization

Method Body

Control Flow

Error Handling

Messages

Return Codes

Exceptions

Throwing

```abap

RAISE EXCEPTION NEW cx_gen_error( previous = exception ).

```

Catching

```abap

CATCH cx_amdp_failure INTO DATA(ex).

RAISE EXCEPTION NEW cx_generation_failure( previous = ex ).

```

Comments

Formatting

```abap

structure-type = 'A'.

structure-id = '4711'.

```

Testing

Principles

Test Classes

Code Under Test

Injection

```abap

DATA(mock) = CAST if_reader( cl_abap_testdouble=>create( 'if_reader' ) ).

cl_abap_testdouble=>configure_call( mock )->returning( value ).

```

Test Methods

Test Data

Assertions

```abap

TRY.

cut->do_something( '' ).

cl_abap_unit_assert=>fail( ).

CATCH /clean/some_exception.

ENDTRY.

```

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.