Skip to content
Permalink
Browse files

RFC enable additional checks (#716)

* rfc enable check 26

* Update 26.md

* check 33, enable RFC

* Update 33.md

* 72, enable rfc

* Update 72.md

* 51, enable RFC

note that this is a bit special, this will report errors also if the system does not support escaping

* Update 51.md

* 48, enable rfc

* Update 48.md

* 81, enable rfc

* Update 81.md

* 82, enable rfc

* Update 82.md

* bugfixes
  • Loading branch information...
larshp committed May 15, 2019
1 parent 9159e1d commit 6d6434a204f1be21433116a2452a910d6363d3ec
@@ -1,12 +1,12 @@
---
title: No direct changes to standard tables
cNumber: CHECK_26
rfc: false
rfc: true
---

This check will report an error if the code contains MODIFY/DELETE/INSERT/UPDATE of standard database tables.

Use [BAPI](http://help.sap.com/saphelp_erp60_sp/helpdata/en/7e/5e115e4a1611d1894c0000e829fbbd/content.htm) or other standard functionality to modify contents of standard tables.

### Configuration
![Configuration](/img/26_conf.png)
![Configuration](/img/26_conf.png)
@@ -1,7 +1,7 @@
---
title: Append structure field names
cNumber: CHECK_33
rfc: false
rfc: true
---

When adding an append structure to SAP standard tables/structures, the field names should be named ZZ or YY something.
@@ -11,4 +11,4 @@ See [http://help.sap.com/saphelp_nw73/helpdata/en/cf/21eb61446011d189700000e8322
If adding a field as described in a SAP note in non customer namespace, do not use append structures, add it to the SAP object. As the append structure will cause problems when upgrading the system.

### Configuration
![Configuration](/img/default_conf.png)
![Configuration](/img/default_conf.png)
@@ -1,7 +1,7 @@
---
title: Internal tables
cNumber: CHECK_48
rfc: false
rfc: true
---

### DEFAULT KEY, add table key or EMPTY KEY
@@ -13,4 +13,4 @@ see [https://scn.sap.com/community/abap/blog/2013/06/27/abap-news-for-release-74
Internal tables with header lines are obsolete, so accessing table body via `[]` is not needed

### Configuration
![Configuration](/img/default_conf.png)
![Configuration](/img/default_conf.png)
@@ -1,12 +1,12 @@
---
title: Open SQL - Escape host variables
cNumber: CHECK_51
rfc: false
rfc: true
---

from 740sp05

see [https://help.sap.com/http.svc/rc/abapdocu_750_index_htm/7.50/en-US/abenopen_sql_hostvar_obsolete.htm](https://help.sap.com/http.svc/rc/abapdocu_750_index_htm/7.50/en-US/abenopen_sql_hostvar_obsolete.htm)

### Configuration
![Configuration](/img/default_conf.png)
![Configuration](/img/default_conf.png)
@@ -1,7 +1,7 @@
---
title: TABL Enhancement category missing
cNumber: CHECK_72
rfc: false
rfc: true
---

### TABL: Enhancement category missing
@@ -1,7 +1,7 @@
---
title: Missing space
cNumber: CHECK_81
rfc: false
rfc: true
---

### Missing space before or after '
@@ -1,7 +1,7 @@
---
title: Pseudo comment placement
cNumber: CHECK_82
rfc: false
rfc: true
---

### Pseudo comment placement
@@ -19,8 +19,13 @@ CLASS zcl_aoc_check_26 DEFINITION
REDEFINITION.
PROTECTED SECTION.

DATA:
mt_tables TYPE scit_tabl.
DATA mt_tables TYPE scit_tabl .

METHODS find_user
IMPORTING
!iv_tabname TYPE clike
RETURNING
VALUE(rv_as4user) TYPE dd02l-as4user .
PRIVATE SECTION.
ENDCLASS.

@@ -101,13 +106,8 @@ CLASS ZCL_AOC_CHECK_26 IMPLEMENTATION.
CONTINUE.
ENDIF.

SELECT SINGLE as4user FROM dd02l INTO lv_as4user
WHERE tabname = <ls_rt>-code
AND as4local = 'A'
AND as4vers = space
AND tabclass = 'TRANSP'. "#EC CI_SEL_NESTED
IF sy-subrc = 0
AND ( lv_as4user = 'SAP' OR lv_as4user = 'DDIC' )
lv_as4user = find_user( <ls_rt>-code ).
IF ( lv_as4user = 'SAP' OR lv_as4user = 'DDIC' )
AND <ls_rt>-code IN mt_tables.
lv_include = get_include( p_level = <ls_statement>-level ).

@@ -129,16 +129,47 @@ CLASS ZCL_AOC_CHECK_26 IMPLEMENTATION.

super->constructor( ).

version = '001'.
position = '026'.
version = '001'.
position = '026'.

has_attributes = abap_true.
attributes_ok = abap_true.

mv_errty = c_error.
CLEAR mt_tables.

ENDMETHOD. "CONSTRUCTOR
enable_rfc( ).

ENDMETHOD.


METHOD find_user.

DATA: lv_tabname TYPE dd02l-tabname,
ls_dd02v TYPE dd02v,
lv_destination TYPE rfcdest.


lv_tabname = iv_tabname.

lv_destination = get_destination( ).

CALL FUNCTION 'DD_TABL_GET'
DESTINATION lv_destination
EXPORTING
tabl_name = lv_tabname
IMPORTING
dd02v_wa_a = ls_dd02v
EXCEPTIONS
access_failure = 1
OTHERS = 2.
IF sy-subrc <> 0.
RETURN.
ENDIF.

rv_as4user = ls_dd02v-as4user.

ENDMETHOD.


METHOD get_attributes.
@@ -24,8 +24,8 @@ CLASS ZCL_AOC_CHECK_33 IMPLEMENTATION.

super->constructor( ).

version = '001'.
position = '033'.
version = '001'.
position = '033'.

has_documentation = c_true.
has_attributes = abap_true.
@@ -35,7 +35,9 @@ CLASS ZCL_AOC_CHECK_33 IMPLEMENTATION.

add_obj_type( 'TABL' ).

ENDMETHOD. "CONSTRUCTOR
enable_rfc( ).

ENDMETHOD.


METHOD get_message_text.
@@ -60,9 +62,10 @@ CLASS ZCL_AOC_CHECK_33 IMPLEMENTATION.
* https://github.com/larshp/abapOpenChecks
* MIT License

DATA: lv_name TYPE ddobjname,
ls_dd02v TYPE dd02v,
lt_dd03p TYPE TABLE OF dd03p.
DATA: lv_tabname TYPE dd02l-tabname,
ls_dd02v TYPE dd02v,
lv_destination TYPE rfcdest,
lt_dd03p TYPE TABLE OF dd03p.

FIELD-SYMBOLS: <ls_dd03p> LIKE LINE OF lt_dd03p.

@@ -71,16 +74,22 @@ CLASS ZCL_AOC_CHECK_33 IMPLEMENTATION.
RETURN.
ENDIF.

lv_name = object_name.
CALL FUNCTION 'DDIF_TABL_GET'
lv_tabname = object_name.

lv_destination = get_destination( ).

CALL FUNCTION 'DD_TABL_GET'
DESTINATION lv_destination
EXPORTING
name = lv_name
tabl_name = lv_tabname
IMPORTING
dd02v_wa = ls_dd02v
dd02v_wa_a = ls_dd02v
TABLES
dd03p_tab = lt_dd03p.

IF ls_dd02v-tabclass <> 'APPEND'.
dd03p_tab_a = lt_dd03p
EXCEPTIONS
access_failure = 1
OTHERS = 2.
IF sy-subrc <> 0 OR ls_dd02v-tabclass <> 'APPEND'.
RETURN.
ENDIF.

@@ -133,8 +133,8 @@ CLASS ZCL_AOC_CHECK_48 IMPLEMENTATION.

super->constructor( ).

version = '002'.
position = '048'.
version = '002'.
position = '048'.

has_attributes = abap_true.
attributes_ok = abap_true.
@@ -147,7 +147,9 @@ CLASS ZCL_AOC_CHECK_48 IMPLEMENTATION.
ls_message-pcom = '"#EC CI_DEFAULT_KEY'.
INSERT ls_message INTO TABLE scimessages.

ENDMETHOD. "CONSTRUCTOR
enable_rfc( ).

ENDMETHOD.


METHOD get_message_text.
@@ -82,15 +82,17 @@ CLASS ZCL_AOC_CHECK_51 IMPLEMENTATION.

super->constructor( ).

version = '001'.
position = '051'.
version = '001'.
position = '051'.

has_attributes = abap_true.
attributes_ok = abap_true.

mv_errty = c_error.

ENDMETHOD. "CONSTRUCTOR
enable_rfc( ).

ENDMETHOD.


METHOD get_message_text.
@@ -35,7 +35,9 @@ CLASS ZCL_AOC_CHECK_72 IMPLEMENTATION.

add_obj_type( 'TABL' ).

ENDMETHOD. "CONSTRUCTOR
enable_rfc( ).

ENDMETHOD.


METHOD get_message_text.
@@ -60,18 +62,33 @@ CLASS ZCL_AOC_CHECK_72 IMPLEMENTATION.
* https://github.com/larshp/abapOpenChecks
* MIT License

DATA: lv_exclass TYPE dd02l-exclass.
DATA: lv_tabname TYPE dd02l-tabname,
ls_dd02v TYPE dd02v,
lv_destination TYPE rfcdest.


IF object_type <> 'TABL'.
RETURN.
ENDIF.

SELECT SINGLE exclass FROM dd02l INTO lv_exclass
WHERE tabname = object_name
AND as4local = 'A'
AND as4vers = '0000'.
lv_tabname = object_name.

lv_destination = get_destination( ).

CALL FUNCTION 'DD_TABL_GET'
DESTINATION lv_destination
EXPORTING
tabl_name = lv_tabname
IMPORTING
dd02v_wa_a = ls_dd02v
EXCEPTIONS
access_failure = 1
OTHERS = 2.
IF sy-subrc <> 0.
RETURN.
ENDIF.

IF sy-subrc = 0 AND lv_exclass = '0'.
IF ls_dd02v-exclass = '0'.
inform( p_test = myname
p_kind = mv_errty
p_code = '001' ).
@@ -99,6 +99,8 @@ CLASS ZCL_AOC_CHECK_81 IMPLEMENTATION.

mv_errty = c_error.

enable_rfc( ).

ENDMETHOD.


@@ -68,6 +68,8 @@ CLASS ZCL_AOC_CHECK_82 IMPLEMENTATION.

mv_errty = c_error.

enable_rfc( ).

ENDMETHOD.


@@ -418,6 +418,7 @@ CLASS ZCL_AOC_SUPER IMPLEMENTATION.
METHOD get_source.

DATA: ls_source LIKE LINE OF mt_source,
lt_source TYPE STANDARD TABLE OF abaptxt255 WITH DEFAULT KEY,
lv_destination TYPE rfcdest.

FIELD-SYMBOLS: <ls_source> LIKE LINE OF mt_source.
@@ -440,15 +441,18 @@ CLASS ZCL_AOC_SUPER IMPLEMENTATION.
program_name = is_level-name
with_includelist = abap_false
only_source = abap_true
with_lowercase = abap_true
TABLES
source_extended = rt_code
source_extended = lt_source
EXCEPTIONS
cancelled = 1
not_found = 2
permission_error = 3
OTHERS = 4.
ASSERT sy-subrc = 0.

rt_code = lt_source.

ls_source-name = is_level-name.
ls_source-code = rt_code.
INSERT ls_source INTO TABLE mt_source.
@@ -575,7 +579,7 @@ CLASS ZCL_AOC_SUPER IMPLEMENTATION.
" We need to find the calling statement and point to this line.
lv_line = p_line.
lv_column = p_column.
IF ( lv_line = 0 OR lv_column = 0 ) AND p_position <> 0.
IF ( lv_line = 0 OR lv_column = 0 ) AND p_position <> 0 AND NOT ref_scan IS INITIAL.
READ TABLE ref_scan->statements INTO statement_wa INDEX p_position.
IF sy-subrc = 0.
get_line_column_rel(
Oops, something went wrong.

0 comments on commit 6d6434a

Please sign in to comment.
You can’t perform that action at this time.