Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
larshp committed Aug 14, 2023
1 parent 356011e commit 4e021d5
Show file tree
Hide file tree
Showing 37 changed files with 1,192 additions and 233 deletions.
12 changes: 9 additions & 3 deletions cloud/zcl_abapgit_abap_language_vers.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ ENDCLASS.



CLASS ZCL_ABAPGIT_ABAP_LANGUAGE_VERS IMPLEMENTATION.
CLASS zcl_abapgit_abap_language_vers IMPLEMENTATION.


METHOD get_abap_language_vers_by_devc.

DATA lv_class TYPE string.
DATA lv_abap_lang_version_devc TYPE string.
DATA lo_abap_language_version_cfg TYPE REF TO object.

lv_class = 'CL_ABAP_LANGUAGE_VERSION_CFG'.

TRY.
CREATE OBJECT lo_abap_language_version_cfg TYPE ('IF_ABAP_LANGUAGE_VERSION_CFG').

CALL METHOD ('CL_ABAP_LANGUAGE_VERSION_CFG')=>('GET_INSTANCE')
CALL METHOD (lv_class)=>('GET_INSTANCE')
RECEIVING
ro_instance = lo_abap_language_version_cfg.

Expand Down Expand Up @@ -73,13 +76,16 @@ CLASS ZCL_ABAPGIT_ABAP_LANGUAGE_VERS IMPLEMENTATION.

METHOD get_abap_language_vers_by_objt.

DATA lv_class TYPE string.
DATA lo_abap_language_version TYPE REF TO object.

lv_class = 'CL_ABAP_LANGUAGE_VERSION_CFG'.

TRY.

CREATE OBJECT lo_abap_language_version TYPE ('IF_ABAP_LANGUAGE_VERSION').

CALL METHOD ('CL_ABAP_LANGUAGE_VERSION')=>('GET_INSTANCE')
CALL METHOD (lv_class)=>('GET_INSTANCE')
RECEIVING
ro_instance = lo_abap_language_version.

Expand Down
5 changes: 4 additions & 1 deletion cloud/zcl_abapgit_aff_registry.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ CLASS zcl_abapgit_aff_registry DEFINITION
INTERFACES:
zif_abapgit_aff_registry.

CONSTANTS c_aff_feature TYPE string VALUE 'AFF'.

METHODS:
constructor
IMPORTING
io_settings TYPE REF TO zcl_abapgit_settings OPTIONAL.
PROTECTED SECTION.
PRIVATE SECTION.

TYPES:
BEGIN OF ty_registry_entry,
obj_type TYPE I_CustABAPObjDirectoryEntry-ABAPObjectType,
Expand Down Expand Up @@ -83,7 +86,7 @@ CLASS zcl_abapgit_aff_registry IMPLEMENTATION.
READ TABLE gt_registry WITH TABLE KEY obj_type = iv_obj_type INTO ls_registry_entry.
IF sy-subrc = 0 AND ls_registry_entry-experimental = abap_false.
rv_result = abap_true.
ELSEIF sy-subrc = 0 AND mo_settings->get_experimental_features( ) = abap_true.
ELSEIF sy-subrc = 0 AND mo_settings->is_feature_enabled( c_aff_feature ) = abap_true.
rv_result = abap_true.
ELSE.
rv_result = abap_false.
Expand Down
6 changes: 5 additions & 1 deletion cloud/zcl_abapgit_aff_registry.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ CLASS ltcl_aff_registry IMPLEMENTATION.


CREATE OBJECT lo_settings_stub.
lo_settings_stub->set_experimental_features( iv_experimental ).
IF iv_experimental = abap_true.
lo_settings_stub->set_experimental_features( zcl_abapgit_aff_registry=>c_aff_feature ).
ELSE.
lo_settings_stub->set_experimental_features( '' ).
ENDIF.
CREATE OBJECT lo_cut TYPE zcl_abapgit_aff_registry
EXPORTING
io_settings = lo_settings_stub.
Expand Down
214 changes: 205 additions & 9 deletions cloud/zcl_abapgit_convert.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CLASS zcl_abapgit_convert DEFINITION
CLASS-METHODS xstring_to_string_utf8
IMPORTING
!iv_data TYPE xsequence
iv_length TYPE i OPTIONAL
!iv_length TYPE i OPTIONAL
RETURNING
VALUE(rv_string) TYPE string
RAISING
Expand Down Expand Up @@ -83,6 +83,33 @@ CLASS zcl_abapgit_convert DEFINITION
!ev_size TYPE i
!et_bintab TYPE STANDARD TABLE .

CLASS-METHODS language_sap1_to_sap2
IMPORTING
im_lang_sap1 TYPE sy-langu
RETURNING
VALUE(re_lang_sap2) TYPE string
EXCEPTIONS
no_assignment.

CLASS-METHODS language_sap2_to_sap1
IMPORTING
im_lang_sap2 TYPE laiso
RETURNING
VALUE(re_lang_sap1) TYPE sy-langu
EXCEPTIONS
no_assignment.

PROTECTED SECTION.
PRIVATE SECTION.

CLASS-DATA go_convert_out TYPE REF TO cl_abap_conv_out_ce .

Check failure on line 105 in cloud/zcl_abapgit_convert.clas.abap

View check run for this annotation

abaplint / abaplint / cloud

Variable "GO_CONVERT_OUT" contains unknown: REF, unable to resolve cl_abap_conv_out_ce

https://rules.abaplint.org/unknown_types
CLASS-DATA go_convert_in TYPE REF TO cl_abap_conv_in_ce .

Check failure on line 106 in cloud/zcl_abapgit_convert.clas.abap

View check run for this annotation

abaplint / abaplint / cloud

Variable "GO_CONVERT_IN" contains unknown: REF, unable to resolve cl_abap_conv_in_ce

https://rules.abaplint.org/unknown_types

CLASS-METHODS xstring_remove_bom
IMPORTING
iv_xstr TYPE xsequence
RETURNING
VALUE(rv_xstr) TYPE xstring.
ENDCLASS.


Expand All @@ -92,7 +119,7 @@ CLASS zcl_abapgit_convert IMPLEMENTATION.

METHOD base64_to_xstring.

ASSERT 1 = 'todo'.
rv_xstr = cl_web_http_utility=>decode_x_base64( iv_base64 ).

ENDMETHOD.

Expand Down Expand Up @@ -129,7 +156,13 @@ CLASS zcl_abapgit_convert IMPLEMENTATION.

METHOD conversion_exit_isola_output.

ASSERT 1 = 'todo'.
cl_gdt_conversion=>language_code_outbound(

Check failure on line 159 in cloud/zcl_abapgit_convert.clas.abap

View check run for this annotation

abaplint / abaplint / cloud

Class cl_gdt_conversion not found

https://rules.abaplint.org/check_syntax
EXPORTING
im_value = iv_spras
IMPORTING
ex_value = rv_spras ).

TRANSLATE rv_spras TO UPPER CASE.

ENDMETHOD.

Expand Down Expand Up @@ -161,7 +194,26 @@ CLASS zcl_abapgit_convert IMPLEMENTATION.

METHOD string_to_tab.

ASSERT 1 = 'todo'.
DATA lv_length TYPE i.
DATA lv_iterations TYPE i.
DATA lv_offset TYPE i.

FIELD-SYMBOLS <lg_line> TYPE any.


CLEAR et_tab.
ev_size = strlen( iv_str ).

APPEND INITIAL LINE TO et_tab ASSIGNING <lg_line>.
<lg_line> = iv_str.
DESCRIBE FIELD <lg_line> LENGTH lv_length IN CHARACTER MODE.

Check failure on line 209 in cloud/zcl_abapgit_convert.clas.abap

View check run for this annotation

abaplint / abaplint / cloud

Statement does not exist in ABAPCloud(or a parser error), "DESCRIBE"

https://rules.abaplint.org/parser_error
lv_iterations = ev_size DIV lv_length.

DO lv_iterations TIMES.
lv_offset = sy-index * lv_length.
APPEND INITIAL LINE TO et_tab ASSIGNING <lg_line>.
<lg_line> = iv_str+lv_offset.
ENDDO.

ENDMETHOD.

Expand All @@ -175,21 +227,82 @@ CLASS zcl_abapgit_convert IMPLEMENTATION.

METHOD string_to_xstring_utf8.

ASSERT 1 = 'todo'.
DATA lx_error TYPE REF TO cx_root.

TRY.
IF go_convert_out IS INITIAL.
go_convert_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).

Check failure on line 234 in cloud/zcl_abapgit_convert.clas.abap

View check run for this annotation

abaplint / abaplint / cloud

Class cl_abap_conv_out_ce not found

https://rules.abaplint.org/check_syntax
ENDIF.

go_convert_out->convert(

Check failure on line 237 in cloud/zcl_abapgit_convert.clas.abap

View check run for this annotation

abaplint / abaplint / cloud

Method "convert" not found, methodCallChain

https://rules.abaplint.org/check_syntax
EXPORTING
data = iv_string
IMPORTING
buffer = rv_xstring ).

CATCH cx_parameter_invalid_range
cx_sy_codepage_converter_init
cx_sy_conversion_codepage
cx_parameter_invalid_type INTO lx_error.
zcx_abapgit_exception=>raise_with_text( lx_error ).
ENDTRY.

ENDMETHOD.


METHOD string_to_xstring_utf8_bom.

ASSERT 1 = 'todo'.
IF iv_string IS INITIAL.
RETURN.
ENDIF.

rv_xstring = string_to_xstring_utf8( iv_string ).

" Add UTF-8 BOM
IF xstrlen( rv_xstring ) < 3 OR rv_xstring(3) <> cl_abap_char_utilities=>byte_order_mark_utf8.
rv_xstring = cl_abap_char_utilities=>byte_order_mark_utf8 && rv_xstring.
ENDIF.

ENDMETHOD.


METHOD xstring_remove_bom.

rv_xstr = iv_xstr.

" cl_abap_conv_in_ce does not handle BOM in non-Unicode systems, so we remove it
IF cl_abap_char_utilities=>charsize = 1 AND xstrlen( rv_xstr ) > 3
AND rv_xstr(3) = cl_abap_char_utilities=>byte_order_mark_utf8.

rv_xstr = rv_xstr+3.

ENDIF.

ENDMETHOD.


METHOD xstring_to_bintab.

ASSERT 1 = 'todo'.
DATA lv_length TYPE i.
DATA lv_iterations TYPE i.
DATA lv_offset TYPE i.

FIELD-SYMBOLS <lg_line> TYPE any.


CLEAR et_bintab.
ev_size = xstrlen( iv_xstr ).

APPEND INITIAL LINE TO et_bintab ASSIGNING <lg_line>.
<lg_line> = iv_xstr.
DESCRIBE FIELD <lg_line> LENGTH lv_length IN BYTE MODE.

Check failure on line 298 in cloud/zcl_abapgit_convert.clas.abap

View check run for this annotation

abaplint / abaplint / cloud

Statement does not exist in ABAPCloud(or a parser error), "DESCRIBE"

https://rules.abaplint.org/parser_error
lv_iterations = ev_size DIV lv_length.

DO lv_iterations TIMES.
lv_offset = sy-index * lv_length.
APPEND INITIAL LINE TO et_bintab ASSIGNING <lg_line>.
<lg_line> = iv_xstr+lv_offset.
ENDDO.

ENDMETHOD.

Expand All @@ -204,7 +317,36 @@ CLASS zcl_abapgit_convert IMPLEMENTATION.

METHOD xstring_to_string_utf8.

ASSERT 1 = 'todo'.
DATA lx_error TYPE REF TO cx_root.
DATA lv_data TYPE xstring.
DATA lv_length TYPE i.

" Remove BOM for non-Unicode systems
lv_data = xstring_remove_bom( iv_data ).

lv_length = iv_length.
IF lv_length <= 0.
lv_length = xstrlen( lv_data ).
ENDIF.

TRY.
IF go_convert_in IS INITIAL.
go_convert_in = cl_abap_conv_in_ce=>create( encoding = 'UTF-8' ).

Check failure on line 334 in cloud/zcl_abapgit_convert.clas.abap

View check run for this annotation

abaplint / abaplint / cloud

Class cl_abap_conv_in_ce not found

https://rules.abaplint.org/check_syntax
ENDIF.

go_convert_in->convert(

Check failure on line 337 in cloud/zcl_abapgit_convert.clas.abap

View check run for this annotation

abaplint / abaplint / cloud

Method "convert" not found, methodCallChain

https://rules.abaplint.org/check_syntax
EXPORTING
input = lv_data
n = lv_length
IMPORTING
data = rv_string ).

CATCH cx_parameter_invalid_range
cx_sy_codepage_converter_init
cx_sy_conversion_codepage
cx_parameter_invalid_type INTO lx_error.
zcx_abapgit_exception=>raise_with_text( lx_error ).
ENDTRY.

ENDMETHOD.

Expand All @@ -223,4 +365,58 @@ CLASS zcl_abapgit_convert IMPLEMENTATION.
GET BIT 8 OF iv_x INTO rv_bitbyte+7(1).

ENDMETHOD.
ENDCLASS.

METHOD language_sap1_to_sap2.

DATA lv_class TYPE string.

TRY.
SELECT SINGLE languageisocode FROM ('I_LANGUAGE')

WHERE language = @im_lang_sap1 INTO @re_lang_sap2.
IF sy-subrc <> 0.
RAISE no_assignment.
ENDIF.
CATCH cx_sy_dynamic_osql_error.
lv_class = 'CL_I18N_LANGUAGES'.
CALL METHOD (lv_class)=>sap1_to_sap2
EXPORTING
im_lang_sap1 = im_lang_sap1
RECEIVING
re_lang_sap2 = re_lang_sap2
EXCEPTIONS
no_assignment = 1
OTHERS = 2.
IF sy-subrc = 1.
RAISE no_assignment.
ENDIF.
ENDTRY.
ENDMETHOD.

METHOD language_sap2_to_sap1.

DATA lv_class TYPE string.

TRY.
SELECT SINGLE language FROM ('I_LANGUAGE')

WHERE languageisocode = @im_lang_sap2 INTO @re_lang_sap1.
IF sy-subrc <> 0.
RAISE no_assignment.
ENDIF.
CATCH cx_sy_dynamic_osql_error.
lv_class = 'CL_I18N_LANGUAGES'.
CALL METHOD (lv_class)=>sap2_to_sap1
EXPORTING
im_lang_sap2 = im_lang_sap2
RECEIVING
re_lang_sap1 = re_lang_sap1
EXCEPTIONS
no_assignment = 1
OTHERS = 2.
IF sy-subrc = 1.
RAISE no_assignment.
ENDIF.
ENDTRY.
ENDMETHOD.
ENDCLASS.
Loading

0 comments on commit 4e021d5

Please sign in to comment.