mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 20:03:20 +08:00
refactor concatenated_key_to_where() (#6531)
This commit is contained in:
parent
58da735823
commit
97cdd3afa8
|
@ -27,12 +27,12 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@abaplint/cli": "^2.102.51",
|
"@abaplint/cli": "^2.102.56",
|
||||||
"@abaplint/database-sqlite": "^2.7.101",
|
"@abaplint/database-sqlite": "^2.7.101",
|
||||||
"@abaplint/runtime": "^2.7.101",
|
"@abaplint/runtime": "^2.7.102",
|
||||||
"@abaplint/transpiler-cli": "^2.7.101",
|
"@abaplint/transpiler-cli": "^2.7.102",
|
||||||
"abapmerge": "^0.16.0",
|
"abapmerge": "^0.16.0",
|
||||||
"c8": "^8.0.1",
|
"c8": "^8.0.1",
|
||||||
"eslint": "^8.50.0"
|
"eslint": "^8.51.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ CLASS zcl_abapgit_data_utils DEFINITION
|
||||||
CREATE PUBLIC.
|
CREATE PUBLIC.
|
||||||
|
|
||||||
PUBLIC SECTION.
|
PUBLIC SECTION.
|
||||||
|
TYPES ty_names TYPE STANDARD TABLE OF abap_compname WITH DEFAULT KEY .
|
||||||
CLASS-METHODS build_table_itab
|
CLASS-METHODS build_table_itab
|
||||||
IMPORTING
|
IMPORTING
|
||||||
!iv_name TYPE tadir-obj_name
|
!iv_name TYPE tadir-obj_name
|
||||||
|
@ -24,8 +24,6 @@ CLASS zcl_abapgit_data_utils DEFINITION
|
||||||
CLASS-METHODS jump
|
CLASS-METHODS jump
|
||||||
IMPORTING
|
IMPORTING
|
||||||
!is_item TYPE zif_abapgit_definitions=>ty_item
|
!is_item TYPE zif_abapgit_definitions=>ty_item
|
||||||
RETURNING
|
|
||||||
VALUE(rv_exit) TYPE abap_bool
|
|
||||||
RAISING
|
RAISING
|
||||||
zcx_abapgit_exception.
|
zcx_abapgit_exception.
|
||||||
CLASS-METHODS does_table_exist
|
CLASS-METHODS does_table_exist
|
||||||
|
@ -38,9 +36,6 @@ CLASS zcl_abapgit_data_utils DEFINITION
|
||||||
!iv_name TYPE tadir-obj_name
|
!iv_name TYPE tadir-obj_name
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_customizing) TYPE abap_bool.
|
VALUE(rv_customizing) TYPE abap_bool.
|
||||||
PROTECTED SECTION.
|
|
||||||
PRIVATE SECTION.
|
|
||||||
TYPES ty_names TYPE STANDARD TABLE OF abap_compname WITH DEFAULT KEY .
|
|
||||||
CLASS-METHODS list_key_fields
|
CLASS-METHODS list_key_fields
|
||||||
IMPORTING
|
IMPORTING
|
||||||
!iv_name TYPE tadir-obj_name
|
!iv_name TYPE tadir-obj_name
|
||||||
|
@ -48,6 +43,8 @@ CLASS zcl_abapgit_data_utils DEFINITION
|
||||||
VALUE(rt_names) TYPE ty_names
|
VALUE(rt_names) TYPE ty_names
|
||||||
RAISING
|
RAISING
|
||||||
zcx_abapgit_exception.
|
zcx_abapgit_exception.
|
||||||
|
PROTECTED SECTION.
|
||||||
|
PRIVATE SECTION.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -309,6 +309,8 @@ CLASS zcl_abapgit_repo_srv IMPLEMENTATION.
|
||||||
|
|
||||||
FIELD-SYMBOLS: <li_repo> LIKE LINE OF mt_list.
|
FIELD-SYMBOLS: <li_repo> LIKE LINE OF mt_list.
|
||||||
|
|
||||||
|
ASSERT iv_key IS NOT INITIAL.
|
||||||
|
|
||||||
IF mv_init = abap_false.
|
IF mv_init = abap_false.
|
||||||
refresh_all( ).
|
refresh_all( ).
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
|
@ -51,7 +51,9 @@ CLASS zcl_abapgit_gui_page_data DEFINITION
|
||||||
!iv_table TYPE tabname
|
!iv_table TYPE tabname
|
||||||
!iv_tabkey TYPE clike
|
!iv_tabkey TYPE clike
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_where) TYPE string .
|
VALUE(rv_where) TYPE string
|
||||||
|
RAISING
|
||||||
|
zcx_abapgit_exception.
|
||||||
METHODS add_via_transport
|
METHODS add_via_transport
|
||||||
RAISING
|
RAISING
|
||||||
zcx_abapgit_exception .
|
zcx_abapgit_exception .
|
||||||
|
@ -153,28 +155,38 @@ CLASS zcl_abapgit_gui_page_data IMPLEMENTATION.
|
||||||
METHOD concatenated_key_to_where.
|
METHOD concatenated_key_to_where.
|
||||||
|
|
||||||
DATA lo_structdescr TYPE REF TO cl_abap_structdescr.
|
DATA lo_structdescr TYPE REF TO cl_abap_structdescr.
|
||||||
DATA lt_fields TYPE ddfields.
|
DATA lo_typedescr TYPE REF TO cl_abap_typedescr.
|
||||||
DATA ls_field LIKE LINE OF lt_fields.
|
DATA lt_fields TYPE zcl_abapgit_data_utils=>ty_names.
|
||||||
|
DATA lv_field LIKE LINE OF lt_fields.
|
||||||
|
DATA lv_table TYPE tadir-obj_name.
|
||||||
|
DATA lv_length TYPE i.
|
||||||
|
DATA lv_tabix TYPE i.
|
||||||
DATA lv_key TYPE c LENGTH 900.
|
DATA lv_key TYPE c LENGTH 900.
|
||||||
|
|
||||||
lv_key = iv_tabkey.
|
lv_key = iv_tabkey.
|
||||||
lo_structdescr ?= cl_abap_typedescr=>describe_by_name( iv_table ).
|
lo_structdescr ?= cl_abap_typedescr=>describe_by_name( iv_table ).
|
||||||
|
|
||||||
lt_fields = lo_structdescr->get_ddic_field_list( ).
|
lv_table = iv_table.
|
||||||
|
lt_fields = zcl_abapgit_data_utils=>list_key_fields( lv_table ).
|
||||||
|
|
||||||
LOOP AT lt_fields INTO ls_field WHERE keyflag = abap_true.
|
LOOP AT lt_fields INTO lv_field.
|
||||||
IF ls_field-position = '0001' AND ls_field-datatype = 'CLNT'.
|
lv_tabix = sy-tabix.
|
||||||
lv_key = lv_key+ls_field-leng.
|
lo_typedescr = cl_abap_typedescr=>describe_by_name( |{ iv_table }-{ lv_field }| ).
|
||||||
|
lv_length = lo_typedescr->length / cl_abap_char_utilities=>charsize.
|
||||||
|
|
||||||
|
IF lv_tabix = 1 AND lo_typedescr->get_relative_name( ) = 'MANDT'.
|
||||||
|
lv_key = lv_key+lv_length.
|
||||||
CONTINUE.
|
CONTINUE.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
IF lv_key = |*|.
|
IF lv_key = |*|.
|
||||||
EXIT. " current loop
|
EXIT. " current loop
|
||||||
ENDIF.
|
ENDIF.
|
||||||
IF NOT rv_where IS INITIAL.
|
IF NOT rv_where IS INITIAL.
|
||||||
rv_where = |{ rv_where } AND |.
|
rv_where = |{ rv_where } AND |.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
rv_where = |{ rv_where }{ to_lower( ls_field-fieldname ) } = '{ lv_key(ls_field-leng) }'|.
|
rv_where = |{ rv_where }{ to_lower( lv_field ) } = '{ lv_key(lv_length) }'|.
|
||||||
lv_key = lv_key+ls_field-leng.
|
lv_key = lv_key+lv_length.
|
||||||
ENDLOOP.
|
ENDLOOP.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
@ -300,7 +312,7 @@ CLASS zcl_abapgit_gui_page_data IMPLEMENTATION.
|
||||||
lt_configs = mi_config->get_configs( ).
|
lt_configs = mi_config->get_configs( ).
|
||||||
|
|
||||||
LOOP AT lt_configs INTO ls_config.
|
LOOP AT lt_configs INTO ls_config.
|
||||||
lo_form = zcl_abapgit_html_form=>create( ).
|
lo_form = zcl_abapgit_html_form=>create( ).
|
||||||
CREATE OBJECT lo_form_data.
|
CREATE OBJECT lo_form_data.
|
||||||
|
|
||||||
lo_form_data->set(
|
lo_form_data->set(
|
||||||
|
|
|
@ -8,6 +8,7 @@ CLASS ltcl_test DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL.
|
||||||
METHODS concatenated_key_to_where2 FOR TESTING RAISING cx_static_check.
|
METHODS concatenated_key_to_where2 FOR TESTING RAISING cx_static_check.
|
||||||
METHODS concatenated_key_to_where3 FOR TESTING RAISING cx_static_check.
|
METHODS concatenated_key_to_where3 FOR TESTING RAISING cx_static_check.
|
||||||
METHODS concatenated_key_to_where4 FOR TESTING RAISING cx_static_check.
|
METHODS concatenated_key_to_where4 FOR TESTING RAISING cx_static_check.
|
||||||
|
METHODS with_mandt FOR TESTING RAISING cx_static_check.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,4 +70,23 @@ CLASS ltcl_test IMPLEMENTATION.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD with_mandt.
|
||||||
|
|
||||||
|
DATA lv_where TYPE string.
|
||||||
|
|
||||||
|
IF sy-sysid = 'ABC'.
|
||||||
|
* dont run on open-abap
|
||||||
|
RETURN.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
lv_where = zcl_abapgit_gui_page_data=>concatenated_key_to_where(
|
||||||
|
iv_table = 'USR02'
|
||||||
|
iv_tabkey = '100ASDF' ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lv_where
|
||||||
|
exp = |bname = 'ASDF'| ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
|
@ -358,7 +358,7 @@ INTERFACE zif_abapgit_definitions
|
||||||
go_background TYPE string VALUE 'go_background',
|
go_background TYPE string VALUE 'go_background',
|
||||||
go_background_run TYPE string VALUE 'go_background_run',
|
go_background_run TYPE string VALUE 'go_background_run',
|
||||||
go_repo_diff TYPE string VALUE 'go_repo_diff',
|
go_repo_diff TYPE string VALUE 'go_repo_diff',
|
||||||
go_file_diff TYPE string VALUE 'go_fill_diff',
|
go_file_diff TYPE string VALUE 'go_file_diff',
|
||||||
go_stage TYPE string VALUE 'go_stage',
|
go_stage TYPE string VALUE 'go_stage',
|
||||||
go_stage_transport TYPE string VALUE 'go_stage_transport',
|
go_stage_transport TYPE string VALUE 'go_stage_transport',
|
||||||
go_commit TYPE string VALUE 'go_commit',
|
go_commit TYPE string VALUE 'go_commit',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user