Skip to content

Commit

Permalink
endless loop in bind_table (#1044)
Browse files Browse the repository at this point in the history
Fix #1043

* endless loop in bind_table
* Handle more than 100 identical texts
* correct typos in comments

Co-authored-by: sandraros <sandra.rossi@gmail.com>
Co-authored-by: Abo <andrea@borgia.bo.it>
  • Loading branch information
3 people committed Jul 13, 2022
1 parent 000b7cf commit 11b47ec
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/zcl_excel_worksheet.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -2964,14 +2964,18 @@ CLASS zcl_excel_worksheet IMPLEMENTATION.

DATA: lt_field_catalog TYPE zexcel_t_fieldcatalog,
lv_value_lowercase TYPE string,
lv_scrtext_l_initial TYPE scrtext_l,
lv_long_text TYPE string,
lv_max_length TYPE i,
lv_temp_length TYPE i,
lv_syindex TYPE c LENGTH 3,
lt_column_name_buffer TYPE SORTED TABLE OF string WITH UNIQUE KEY table_line.
FIELD-SYMBOLS: <ls_field_catalog> TYPE zexcel_s_fieldcatalog,
<scrtxt1> TYPE any,
<scrtxt2> TYPE any,
<scrtxt3> TYPE any.
<scrtxt1> TYPE any,
<scrtxt2> TYPE any,
<scrtxt3> TYPE any.

" Due restrinction of new table object we cannot have two column with the same name
" Due to restrictions in new table object we cannot have two columns with the same name
" Check if a column with the same name exists, if exists add a counter
" If no medium description is provided we try to use small or long

Expand Down Expand Up @@ -3008,6 +3012,8 @@ CLASS zcl_excel_worksheet IMPLEMENTATION.
<ls_field_catalog>-scrtext_l = 'Column'. " default value as Excel does
ENDIF.

lv_scrtext_l_initial = <ls_field_catalog>-scrtext_l.
DESCRIBE FIELD <ls_field_catalog>-scrtext_l LENGTH lv_max_length IN CHARACTER MODE.
DO.
lv_value_lowercase = <ls_field_catalog>-scrtext_l.
TRANSLATE lv_value_lowercase TO LOWER CASE.
Expand All @@ -3017,7 +3023,14 @@ CLASS zcl_excel_worksheet IMPLEMENTATION.
EXIT.
ELSE.
lv_syindex = sy-index.
CONCATENATE <ls_field_catalog>-scrtext_l lv_syindex INTO <ls_field_catalog>-scrtext_l.
CONCATENATE lv_scrtext_l_initial lv_syindex INTO lv_long_text.
IF strlen( lv_long_text ) <= lv_max_length.
<ls_field_catalog>-scrtext_l = lv_long_text.
ELSE.
lv_temp_length = strlen( lv_scrtext_l_initial ) - 1.
lv_scrtext_l_initial = substring( val = lv_scrtext_l_initial len = lv_temp_length ).
CONCATENATE lv_scrtext_l_initial lv_syindex INTO <ls_field_catalog>-scrtext_l.
ENDIF.
ENDIF.
ENDDO.

Expand Down

0 comments on commit 11b47ec

Please sign in to comment.