Issue 3324: WDA Texts are not taken into account (#3352)

* Issue 3324: WDA Texta are not taken into accout

* Remove the not allowed Web Dynpro component

* Correct ABAB CHECKS 702 for SOTR_HANDLER

* ABAP Check 702 SOTR_HANDLER II

* ABAP Check 702 SOTR_HANDLER III: AUnit Exception

* ABAP Check 702 compliant IV

* ABAB Check 702 compliance V

* ABAP Check Compliance 702 VI

* ABAP Check 702 compliance VII

* ABAP Check 702 compliance VIII: delete comment

* ABAP Check compliance 702 IX : conv #

* Commit X: Improvements of ABAP Unit tests

-Test uses a 100% existing wd component and TEST(!) checks it
-Test enhanced with a non existing component -> no exception is raised nor existence is checked inside the PRODUCTIVE ROUTINE(!) via WDR_REPOSITORY_INFO as this check should have been done earlier not in this last phase to append the texts, labels, etc... to the component archive

* C XI: ABAP Unit Tests(2)

* C XII : ABAP Checks 702 for ABAP Unit Tests

* C XIII : ABAP CHECKS 702

* C XIV : ABAP CHECKS 702

Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
KDS42 2020-06-04 14:57:06 +02:00 committed by GitHub
parent 5fcf121ae0
commit f8f6241890
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 305 additions and 60 deletions

View File

@ -69,7 +69,7 @@ ENDCLASS.
CLASS zcl_abapgit_object_wdyn IMPLEMENTATION.
CLASS ZCL_ABAPGIT_OBJECT_WDYN IMPLEMENTATION.
METHOD add_fm_exception.
@ -743,7 +743,8 @@ CLASS zcl_abapgit_object_wdyn IMPLEMENTATION.
METHOD zif_abapgit_object~deserialize.
DATA: ls_component TYPE wdy_component_metadata.
DATA: lt_sotr TYPE zif_abapgit_definitions=>ty_sotr_tt,
ls_component TYPE wdy_component_metadata.
FIELD-SYMBOLS: <ls_view> LIKE LINE OF ls_component-view_metadata,
<ls_controller> LIKE LINE OF ls_component-ctlr_metadata.
@ -772,6 +773,14 @@ CLASS zcl_abapgit_object_wdyn IMPLEMENTATION.
recover_view( <ls_view> ).
ENDLOOP.
io_xml->read( EXPORTING iv_name = 'SOTR'
CHANGING cg_data = lt_sotr ).
IF lines( lt_sotr ) > 0.
zcl_abapgit_sotr_handler=>create_sotr( it_sotr = lt_sotr
iv_package = iv_package ).
ENDIF.
zcl_abapgit_objects_activation=>add_item( ms_item ).
ENDMETHOD.
@ -830,8 +839,10 @@ CLASS zcl_abapgit_object_wdyn IMPLEMENTATION.
METHOD zif_abapgit_object~serialize.
DATA: ls_component TYPE wdy_component_metadata.
DATA: ls_component TYPE wdy_component_metadata,
lt_sotr TYPE zif_abapgit_definitions=>ty_sotr_tt,
ls_description TYPE wdy_ext_ctx_map,
lv_object_name TYPE sobj_name.
ls_component = read( ).
@ -842,5 +853,15 @@ CLASS zcl_abapgit_object_wdyn IMPLEMENTATION.
io_xml->add( ig_data = mt_sources
iv_name = 'SOURCES' ).
READ TABLE ls_component-comp_metadata-descriptions INTO ls_description INDEX 1.
IF sy-subrc = 0.
lv_object_name = ls_description-component_name.
lt_sotr = zcl_abapgit_sotr_handler=>read_sotr_wda( lv_object_name ).
IF lines( lt_sotr ) > 0.
io_xml->add( iv_name = 'SOTR'
ig_data = lt_sotr ).
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@ -729,62 +729,7 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION.
METHOD zif_abapgit_oo_object_fnc~read_sotr.
DATA: lv_concept TYPE sotr_head-concept,
lt_seocompodf TYPE STANDARD TABLE OF seocompodf WITH DEFAULT KEY,
ls_header TYPE sotr_head,
lt_entries TYPE sotr_text_tt.
FIELD-SYMBOLS: <ls_sotr> LIKE LINE OF rt_sotr,
<ls_seocompodf> LIKE LINE OF lt_seocompodf,
<ls_entry> LIKE LINE OF lt_entries.
SELECT * FROM seocompodf
INTO TABLE lt_seocompodf
WHERE clsname = iv_object_name
AND version = '1'
AND exposure = '2'
AND attdecltyp = '2'
AND type = 'SOTR_CONC'
ORDER BY PRIMARY KEY. "#EC CI_SUBRC
LOOP AT lt_seocompodf ASSIGNING <ls_seocompodf>.
lv_concept = translate( val = <ls_seocompodf>-attvalue from = '''' to = '' ).
CALL FUNCTION 'SOTR_GET_CONCEPT'
EXPORTING
concept = lv_concept
IMPORTING
header = ls_header
TABLES
entries = lt_entries
EXCEPTIONS
no_entry_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
CLEAR: ls_header-paket,
ls_header-crea_name,
ls_header-crea_tstut,
ls_header-chan_name,
ls_header-chan_tstut.
LOOP AT lt_entries ASSIGNING <ls_entry>.
CLEAR: <ls_entry>-version,
<ls_entry>-crea_name,
<ls_entry>-crea_tstut,
<ls_entry>-chan_name,
<ls_entry>-chan_tstut.
ENDLOOP.
APPEND INITIAL LINE TO rt_sotr ASSIGNING <ls_sotr>.
<ls_sotr>-header = ls_header.
<ls_sotr>-entries = lt_entries.
ENDLOOP.
rt_sotr = zcl_abapgit_sotr_handler=>read_sotr_seocomp( iv_object_name ).
ENDMETHOD.

View File

@ -0,0 +1,200 @@
CLASS zcl_abapgit_sotr_handler DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
TYPES: yt_sotr_use TYPE STANDARD TABLE OF sotr_use WITH DEFAULT KEY,
yt_seocompodf TYPE STANDARD TABLE OF seocompodf WITH DEFAULT KEY.
CLASS-METHODS read_sotr_wda
IMPORTING
iv_object_name TYPE sobj_name
RETURNING
VALUE(rt_sotr) TYPE zif_abapgit_definitions=>ty_sotr_tt
RAISING
zcx_abapgit_exception.
CLASS-METHODS read_sotr_seocomp
IMPORTING
iv_object_name TYPE sobj_name
RETURNING
VALUE(rt_sotr) TYPE zif_abapgit_definitions=>ty_sotr_tt
RAISING
zcx_abapgit_exception.
CLASS-METHODS create_sotr
IMPORTING
iv_package TYPE devclass
it_sotr TYPE zif_abapgit_definitions=>ty_sotr_tt
RAISING
zcx_abapgit_exception.
PROTECTED SECTION.
CLASS-METHODS get_sotr_4_concept
IMPORTING
iv_concept TYPE sotr_conc
RETURNING
VALUE(rt_sotr) TYPE zif_abapgit_definitions=>ty_sotr_tt.
ENDCLASS.
CLASS ZCL_ABAPGIT_SOTR_HANDLER IMPLEMENTATION.
METHOD create_sotr.
DATA: lt_sotr TYPE zif_abapgit_definitions=>ty_sotr_tt,
lt_objects TYPE sotr_objects,
ls_paket TYPE sotr_pack,
lv_object LIKE LINE OF lt_objects.
FIELD-SYMBOLS: <ls_sotr> LIKE LINE OF lt_sotr.
LOOP AT it_sotr ASSIGNING <ls_sotr>.
CALL FUNCTION 'SOTR_OBJECT_GET_OBJECTS'
EXPORTING
object_vector = <ls_sotr>-header-objid_vec
IMPORTING
objects = lt_objects
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
zcx_abapgit_exception=>raise( |error from SOTR_OBJECT_GET_OBJECTS. Subrc = { sy-subrc }| ).
ENDIF.
READ TABLE lt_objects INDEX 1 INTO lv_object.
ASSERT sy-subrc = 0.
ls_paket-paket = iv_package.
CALL FUNCTION 'SOTR_CREATE_CONCEPT'
EXPORTING
paket = ls_paket
crea_lan = <ls_sotr>-header-crea_lan
alias_name = <ls_sotr>-header-alias_name
object = lv_object
entries = <ls_sotr>-entries
concept_default = <ls_sotr>-header-concept
EXCEPTIONS
package_missing = 1
crea_lan_missing = 2
object_missing = 3
paket_does_not_exist = 4
alias_already_exist = 5
object_type_not_found = 6
langu_missing = 7
identical_context_not_allowed = 8
text_too_long = 9
error_in_update = 10
no_master_langu = 11
error_in_concept_id = 12
alias_not_allowed = 13
tadir_entry_creation_failed = 14
internal_error = 15
error_in_correction = 16
user_cancelled = 17
no_entry_found = 18
OTHERS = 19.
IF sy-subrc <> 0 AND sy-subrc <> 5.
zcx_abapgit_exception=>raise( |Error from SOTR_CREATE_CONCEPT. Subrc = { sy-subrc }| ).
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD get_sotr_4_concept.
DATA: ls_header TYPE sotr_head,
lt_entries TYPE sotr_text_tt,
lv_obj_name TYPE trobj_name.
FIELD-SYMBOLS: <ls_sotr> LIKE LINE OF rt_sotr,
<ls_entry> LIKE LINE OF lt_entries.
CALL FUNCTION 'SOTR_GET_CONCEPT'
EXPORTING
concept = iv_concept
IMPORTING
header = ls_header
TABLES
entries = lt_entries
EXCEPTIONS
no_entry_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
RETURN.
ENDIF.
CLEAR: ls_header-paket,
ls_header-crea_name,
ls_header-crea_tstut,
ls_header-chan_name,
ls_header-chan_tstut.
LOOP AT lt_entries ASSIGNING <ls_entry>.
CLEAR: <ls_entry>-version,
<ls_entry>-crea_name,
<ls_entry>-crea_tstut,
<ls_entry>-chan_name,
<ls_entry>-chan_tstut.
ENDLOOP.
APPEND INITIAL LINE TO rt_sotr ASSIGNING <ls_sotr>.
<ls_sotr>-header = ls_header.
<ls_sotr>-entries = lt_entries.
ENDMETHOD.
METHOD read_sotr_seocomp.
DATA: lv_concept TYPE sotr_head-concept.
DATA: lt_seocompodf TYPE yt_seocompodf.
FIELD-SYMBOLS <ls_seocompodf> TYPE seocompodf.
SELECT * FROM seocompodf
INTO TABLE lt_seocompodf
WHERE clsname = iv_object_name
AND version = '1'
AND exposure = '2'
AND attdecltyp = '2'
AND type = 'SOTR_CONC'
ORDER BY PRIMARY KEY. "#EC CI_SUBRC
IF sy-subrc = 0.
LOOP AT lt_seocompodf ASSIGNING <ls_seocompodf>.
lv_concept = translate( val = <ls_seocompodf>-attvalue from = '''' to = '' ).
rt_sotr = get_sotr_4_concept( lv_concept ).
ENDLOOP.
ENDIF.
ENDMETHOD.
METHOD read_sotr_wda.
DATA: lv_concept TYPE sotr_head-concept.
DATA: lt_sotr_use TYPE yt_sotr_use.
DATA: lv_obj_name TYPE trobj_name.
FIELD-SYMBOLS <ls_sotr_use> TYPE sotr_use.
lv_obj_name = |{ iv_object_name }%|. "Existence check via WDR_REPOSITORY_INFO should have been done earlier
CALL FUNCTION 'SOTR_USAGE_READ'
EXPORTING
pgmid = 'LIMU' " Program ID in requests and tasks
object = 'WDYV' " Object Type
obj_name = lv_obj_name
IMPORTING
sotr_usage = lt_sotr_use
EXCEPTIONS
no_entry_found = 1
error_in_pgmid = 2
OTHERS = 3.
IF sy-subrc = 0.
LOOP AT lt_sotr_use ASSIGNING <ls_sotr_use>.
lv_concept = translate( val = <ls_sotr_use>-concept from = '''' to = '' ).
rt_sotr = get_sotr_4_concept( lv_concept ).
ENDLOOP.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@ -0,0 +1,62 @@
*"* use this source file for your ABAP unit test classes
CLASS ltcl_sotr_handler DEFINITION FOR TESTING
DURATION SHORT
RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS is_wd_component_existing
IMPORTING iv_component_name TYPE sobj_name
RETURNING VALUE(rv_is_wd_component_existing) TYPE abap_bool.
METHODS sotr_wda_0001 FOR TESTING.
METHODS sotr_wda_0003_not_exist FOR TESTING.
METHODS sotr_cx_0002 FOR TESTING.
ENDCLASS.
CLASS ltcl_sotr_handler IMPLEMENTATION.
METHOD is_wd_component_existing.
DATA ls_repository TYPE wdy_rr_cluster.
DATA lv_component_name TYPE string.
lv_component_name = iv_component_name.
CALL FUNCTION 'WDR_REPOSITORY_INFO'
EXPORTING
component_name = lv_component_name
IMPORTING
repository = ls_repository.
IF ls_repository IS NOT INITIAL.
rv_is_wd_component_existing = abap_true.
ENDIF.
ENDMETHOD.
METHOD sotr_wda_0001.
CONSTANTS lc_wd_component_name TYPE sobj_name VALUE 'SALV_WD_TEST_TABLE_SIMPLE'.
DATA lt_sotr TYPE zif_abapgit_definitions=>ty_sotr_tt.
IF is_wd_component_existing( lc_wd_component_name ) = abap_true.
TRY.
lt_sotr = zcl_abapgit_sotr_handler=>read_sotr_wda( iv_object_name = lc_wd_component_name ).
cl_aunit_assert=>assert_not_initial( lt_sotr ).
CATCH zcx_abapgit_exception.
cl_aunit_assert=>fail( quit = if_aunit_constants=>method ).
ENDTRY.
ENDIF.
ENDMETHOD.
METHOD sotr_wda_0003_not_exist.
CONSTANTS lc_wd_not_exist_component_name TYPE sobj_name VALUE '_NOT_EXISTING'.
DATA lt_sotr TYPE zif_abapgit_definitions=>ty_sotr_tt.
IF is_wd_component_existing( lc_wd_not_exist_component_name ) <> abap_true.
TRY.
lt_sotr = zcl_abapgit_sotr_handler=>read_sotr_wda( iv_object_name = lc_wd_not_exist_component_name ).
cl_aunit_assert=>assert_initial( lt_sotr ).
CATCH zcx_abapgit_exception.
cl_aunit_assert=>fail( quit = if_aunit_constants=>method ).
ENDTRY.
ENDIF.
ENDMETHOD.
METHOD sotr_cx_0002.
DATA lt_sotr TYPE zif_abapgit_definitions=>ty_sotr_tt.
TRY.
lt_sotr = zcl_abapgit_sotr_handler=>read_sotr_seocomp( iv_object_name = 'CX_ABAP_INVALID_NAME' ).
cl_aunit_assert=>assert_not_initial( lt_sotr ).
CATCH zcx_abapgit_exception.
cl_aunit_assert=>fail( quit = if_aunit_constants=>method ).
ENDTRY.
ENDMETHOD.
ENDCLASS.

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>ZCL_ABAPGIT_SOTR_HANDLER</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>Class to Read and Create SOTR Objects</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
<WITH_UNIT_TESTS>X</WITH_UNIT_TESTS>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>