Merge pull request #592 from gregorwolf/master

700 support #562 and abaplint check
This commit is contained in:
Gregor Wolf 2019-02-11 18:39:27 +01:00 committed by GitHub
commit f3d46100a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 275 additions and 131 deletions

View File

@ -12,6 +12,7 @@
<item>/package.json</item>
<item>/.travis.yml</item>
<item>/_config.yml</item>
<item>/abaplint.json</item>
</IGNORE>
</DATA>
</asx:values>

119
abaplint.json Normal file
View File

@ -0,0 +1,119 @@
{
"global": {
"version": "v700",
"skipGeneratedGatewayClasses": true,
"skipGeneratedPersistentClasses": true
},
"rules": {
"7bit_ascii": {
"enabled": false
},
"contains_tab": {
"enabled": false
},
"functional_writing": {
"enabled": false,
"ignoreExceptions": true
},
"line_length": {
"enabled": false,
"length": 120
},
"max_one_statement": {
"enabled": false
},
"parser_error": {
"enabled": true
},
"space_before_colon": {
"enabled": false
},
"colon_missing_space": {
"enabled": false
},
"exit_or_check": {
"enabled": false
},
"line_only_punc": {
"enabled": false,
"ignoreExceptions": true
},
"obsolete_statement": {
"enabled": false,
"refresh": true,
"compute": true,
"add": true,
"subtract": true,
"multiply": true,
"move": true,
"divide": true,
"requested": true
},
"start_at_tab": {
"enabled": false
},
"whitespace_end": {
"enabled": true
},
"exporting": {
"enabled": false
},
"empty_statement": {
"enabled": false
},
"sequential_blank": {
"enabled": false,
"lines": 4
},
"definitions_top": {
"enabled": false
},
"breakpoint": {
"enabled": false
},
"nesting": {
"enabled": false,
"depth": 5
},
"keywords_upper": {
"enabled": false,
"ignoreExceptions": true
},
"cloud_types": {
"enabled": true
},
"method_length": {
"enabled": false,
"statements": 100
},
"mix_returning": {
"enabled": true
},
"method_parameter_names": {
"enabled": false,
"ignoreExceptions": true,
"importing": "^I._.*$",
"returning": "^R._.*$",
"changing": "^C._.*$",
"exporting": "^E._.*$",
"ignoreNames": [
"P_TASK"
]
},
"inline_data_old_versions": {
"enabled": true
},
"local_variable_names": {
"enabled": false,
"expectedData": "^L._.*$",
"expectedConstant": "^LC_.*$",
"expectedFS": "^<L._.*>$"
},
"class_attribute_names": {
"enabled": false,
"ignoreExceptions": true,
"statics": "^G._.*$",
"instance": "^M._.*$"
}
}
}

View File

@ -4217,7 +4217,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
endmethod.
method GET_TABLE.
METHOD get_table.
*--------------------------------------------------------------------*
* Comment D. Rauchenstein
* With this method, we get a fully functional Excel Upload, which solves
@ -4230,116 +4230,128 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
* CL_EXCEL_READER_2007->ZIF_EXCEL_READER~LOAD_FILE()
*--------------------------------------------------------------------*
field-symbols: <LS_LINE> type DATA.
field-symbols: <LV_VALUE> type DATA.
FIELD-SYMBOLS: <ls_line> TYPE data.
FIELD-SYMBOLS: <lv_value> TYPE data.
data LV_ACTUAL_ROW type INT4.
data LV_ACTUAL_COL type INT4.
data LV_ERRORMESSAGE type STRING.
data LV_MAX_COL type ZEXCEL_CELL_COLUMN.
data LV_MAX_ROW type INT4.
data LV_DELTA_COL type INT4.
data LV_VALUE type ZEXCEL_CELL_VALUE.
data LV_RC type SYSUBRC.
DATA lv_actual_row TYPE int4.
DATA lv_actual_row_string TYPE string.
DATA lv_actual_col TYPE int4.
DATA lv_actual_col_string TYPE string.
DATA lv_errormessage TYPE string.
DATA lv_max_col TYPE zexcel_cell_column.
DATA lv_max_row TYPE int4.
DATA lv_delta_col TYPE int4.
DATA lv_value TYPE zexcel_cell_value.
DATA lv_rc TYPE sysubrc.
LV_MAX_COL = ME->GET_HIGHEST_COLUMN( ).
LV_MAX_ROW = ME->GET_HIGHEST_ROW( ).
lv_max_col = me->get_highest_column( ).
lv_max_row = me->get_highest_row( ).
*--------------------------------------------------------------------*
* The row counter begins with 1 and should be corrected with the skips
*--------------------------------------------------------------------*
LV_ACTUAL_ROW = IV_SKIPPED_ROWS + 1.
LV_ACTUAL_COL = IV_SKIPPED_COLS + 1.
lv_actual_row = iv_skipped_rows + 1.
lv_actual_col = iv_skipped_cols + 1.
try.
TRY.
*--------------------------------------------------------------------*
* Check if we the basic features are possible with given "any table"
*--------------------------------------------------------------------*
append initial line to ET_TABLE assigning <LS_LINE>.
if SY-SUBRC <> 0 or <LS_LINE> is not assigned.
APPEND INITIAL LINE TO et_table ASSIGNING <ls_line>.
IF sy-subrc <> 0 OR <ls_line> IS NOT ASSIGNED.
LV_ERRORMESSAGE = 'Error at inserting new Line to internal Table'(002).
lv_errormessage = 'Error at inserting new Line to internal Table'(002).
zcx_excel=>raise_text( lv_errormessage ).
else.
LV_DELTA_COL = LV_MAX_COL - IV_SKIPPED_COLS.
assign component LV_DELTA_COL of structure <LS_LINE> to <LV_VALUE>.
if SY-SUBRC <> 0 or <LV_VALUE> is not assigned.
LV_ERRORMESSAGE = 'Internal table has less columns than excel'(003).
ELSE.
lv_delta_col = lv_max_col - iv_skipped_cols.
ASSIGN COMPONENT lv_delta_col OF STRUCTURE <ls_line> TO <lv_value>.
IF sy-subrc <> 0 OR <lv_value> IS NOT ASSIGNED.
lv_errormessage = 'Internal table has less columns than excel'(003).
zcx_excel=>raise_text( lv_errormessage ).
else.
ELSE.
*--------------------------------------------------------------------*
*now we are ready for handle the table data
*--------------------------------------------------------------------*
refresh ET_TABLE.
REFRESH et_table.
*--------------------------------------------------------------------*
* Handle each Row until end on right side
*--------------------------------------------------------------------*
while LV_ACTUAL_ROW <= LV_MAX_ROW .
WHILE lv_actual_row <= lv_max_row .
*--------------------------------------------------------------------*
* Handle each Column until end on bottom
* First step is to step back on first column
*--------------------------------------------------------------------*
LV_ACTUAL_COL = IV_SKIPPED_COLS + 1.
lv_actual_col = iv_skipped_cols + 1.
unassign <LS_LINE>.
append initial line to ET_TABLE assigning <LS_LINE>.
if SY-SUBRC <> 0 or <LS_LINE> is not assigned.
LV_ERRORMESSAGE = 'Error at inserting new Line to internal Table'(002).
UNASSIGN <ls_line>.
APPEND INITIAL LINE TO et_table ASSIGNING <ls_line>.
IF sy-subrc <> 0 OR <ls_line> IS NOT ASSIGNED.
lv_errormessage = 'Error at inserting new Line to internal Table'(002).
zcx_excel=>raise_text( lv_errormessage ).
endif.
while LV_ACTUAL_COL <= LV_MAX_COL.
ENDIF.
WHILE lv_actual_col <= lv_max_col.
LV_DELTA_COL = LV_ACTUAL_COL - IV_SKIPPED_COLS.
assign component LV_DELTA_COL of structure <LS_LINE> to <LV_VALUE>.
if SY-SUBRC <> 0.
LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|.
lv_delta_col = lv_actual_col - iv_skipped_cols.
ASSIGN COMPONENT lv_delta_col OF STRUCTURE <ls_line> TO <lv_value>.
IF sy-subrc <> 0.
lv_actual_col_string = lv_actual_col.
lv_actual_row_string = lv_actual_row.
CONCATENATE 'Error at assigning field (Col:'(004) lv_actual_col_string ' Row:'(005) lv_actual_row_string INTO lv_errormessage.
zcx_excel=>raise_text( lv_errormessage ).
endif.
ENDIF.
ME->GET_CELL(
exporting
IP_COLUMN = LV_ACTUAL_COL " Cell Column
IP_ROW = LV_ACTUAL_ROW " Cell Row
importing
EP_VALUE = LV_VALUE " Cell Value
EP_RC = LV_RC " Return Value of ABAP Statements
me->get_cell(
EXPORTING
ip_column = lv_actual_col " Cell Column
ip_row = lv_actual_row " Cell Row
IMPORTING
ep_value = lv_value " Cell Value
ep_rc = lv_rc " Return Value of ABAP Statements
).
if LV_RC <> 0
and LV_RC <> 4. "No found error means, zero/no value in cell
LV_ERRORMESSAGE = |{ 'Error at reading field value (Col:'(007) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|.
IF lv_rc <> 0
AND lv_rc <> 4. "No found error means, zero/no value in cell
lv_actual_col_string = lv_actual_col.
lv_actual_row_string = lv_actual_row.
CONCATENATE 'Error at reading field value (Col:'(007) lv_actual_col_string ' Row:'(005) lv_actual_row_string INTO lv_errormessage.
zcx_excel=>raise_text( lv_errormessage ).
endif.
ENDIF.
<LV_VALUE> = LV_VALUE.
<lv_value> = lv_value.
* CATCH zcx_excel. "
add 1 to LV_ACTUAL_COL.
endwhile.
add 1 to LV_ACTUAL_ROW.
endwhile.
endif.
ADD 1 TO lv_actual_col.
ENDWHILE.
ADD 1 TO lv_actual_row.
ENDWHILE.
ENDIF.
endif.
ENDIF.
catch CX_SY_ASSIGN_CAST_ILLEGAL_CAST.
LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|.
CATCH cx_sy_assign_cast_illegal_cast.
lv_actual_col_string = lv_actual_col.
lv_actual_row_string = lv_actual_row.
CONCATENATE 'Error at assigning field (Col:'(004) lv_actual_col_string ' Row:'(005) lv_actual_row_string INTO lv_errormessage.
zcx_excel=>raise_text( lv_errormessage ).
catch CX_SY_ASSIGN_CAST_UNKNOWN_TYPE.
LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|.
CATCH cx_sy_assign_cast_unknown_type.
lv_actual_col_string = lv_actual_col.
lv_actual_row_string = lv_actual_row.
CONCATENATE 'Error at assigning field (Col:'(004) lv_actual_col_string ' Row:'(005) lv_actual_row_string INTO lv_errormessage.
zcx_excel=>raise_text( lv_errormessage ).
catch CX_SY_ASSIGN_OUT_OF_RANGE.
LV_ERRORMESSAGE = 'Internal table has less columns than excel'(003).
CATCH cx_sy_assign_out_of_range.
lv_errormessage = 'Internal table has less columns than excel'(003).
zcx_excel=>raise_text( lv_errormessage ).
catch CX_SY_CONVERSION_ERROR.
LV_ERRORMESSAGE = |{ 'Error at converting field value (Col:'(006) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|.
CATCH cx_sy_conversion_error.
lv_actual_col_string = lv_actual_col.
lv_actual_row_string = lv_actual_row.
CONCATENATE 'Error at converting field value (Col:'(006) lv_actual_col_string ' Row:'(005) lv_actual_row_string INTO lv_errormessage.
zcx_excel=>raise_text( lv_errormessage ).
endtry.
endmethod.
ENDTRY.
ENDMETHOD.
method GET_TABLES_ITERATOR.

View File

@ -2298,7 +2298,8 @@ METHOD create_xl_comments.
lo_iterator TYPE REF TO cl_object_collection_iterator,
lo_comments TYPE REF TO zcl_excel_comments,
lo_comment TYPE REF TO zcl_excel_comment.
DATA: lv_rel_id TYPE i.
DATA: lv_rel_id TYPE i,
lv_author TYPE string.
DEFINE add_1_val_child_node.
* &1: parent element
@ -2344,7 +2345,8 @@ METHOD create_xl_comments.
lo_element_author = lo_document->create_simple_element( name = lc_xml_node_author
parent = lo_document ).
lo_element_author->set_value( |{ sy-uname }| ).
lv_author = sy-uname.
lo_element_author->set_value( lv_author ).
lo_element_authors->append_child( new_child = lo_element_author ).
lo_element_root->append_child( new_child = lo_element_authors ).
@ -2978,7 +2980,11 @@ METHOD create_xl_drawing_for_comments.
lv_row TYPE zexcel_cell_row,
lv_str_column TYPE zexcel_cell_column_alpha,
lv_column TYPE zexcel_cell_column,
lv_index TYPE i.
lv_index TYPE i,
lv_attr_id_index TYPE i,
lv_attr_id TYPE string,
lv_int_value TYPE i,
lv_int_value_string TYPE string.
DATA: lv_rel_id TYPE i.
DEFINE add_1_val_child_node.
@ -3072,7 +3078,10 @@ METHOD create_xl_drawing_for_comments.
lo_element_shape = lo_document->create_simple_element( name = lc_xml_node_shape
parent = lo_document ).
lo_element_shape->set_attribute_ns( : name = lc_xml_attr_id value = |_x0000_s{ 1024 + lv_index }| ),
lv_attr_id_index = 1024 + lv_index.
lv_attr_id = lv_attr_id_index.
CONCATENATE '_x0000_s' lv_attr_id INTO lv_attr_id.
lo_element_shape->set_attribute_ns( : name = lc_xml_attr_id value = lv_attr_id ),
name = lc_xml_attr_type value = '#_x0000_t202' ),
name = lc_xml_attr_style value = 'size:auto;width:auto;height:auto;position:absolute;margin-left:117pt;margin-top:172.5pt;z-index:1;visibility:hidden' ),
name = lc_xml_attr_fillcolor value = '#ffffe1' ),
@ -3124,13 +3133,15 @@ METHOD create_xl_drawing_for_comments.
lo_element_clientdata->append_child( new_child = lo_element_autofill ).
lo_element_row = lo_document->create_simple_element( name = lc_xml_node_row
parent = lo_document ).
* lo_element_row->set_value( '12' ).
lo_element_row->set_value( |{ lv_row - 1 }| ).
lv_int_value = lv_row - 1.
lv_int_value_string = lv_int_value.
lo_element_row->set_value( lv_int_value_string ).
lo_element_clientdata->append_child( new_child = lo_element_row ).
lo_element_column = lo_document->create_simple_element( name = lc_xml_node_column
parent = lo_document ).
* lo_element_column->set_value( '1' ).
lo_element_column->set_value( |{ lv_column - 1 }| ).
lv_int_value = lv_column - 1.
lv_int_value_string = lv_int_value.
lo_element_column->set_value( lv_int_value_string ).
lo_element_clientdata->append_child( new_child = lo_element_column ).
lo_element_shape->append_child( new_child = lo_element_clientdata ).

View File

@ -10,7 +10,8 @@ REPORT zdemo_excel_comments.
DATA: lo_excel TYPE REF TO zcl_excel,
lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_comment TYPE REF TO zcl_excel_comment,
lo_hyperlink TYPE REF TO zcl_excel_hyperlink.
lo_hyperlink TYPE REF TO zcl_excel_hyperlink,
lv_comment TYPE string.
CONSTANTS: gc_save_file_name TYPE string VALUE 'Comments.xlsx'.
INCLUDE zdemo_excel_outputopt_incl.
@ -37,8 +38,8 @@ START-OF-SELECTION.
lo_comment->set_text( ip_ref = 'C18' ip_text = 'Another comment' ).
lo_worksheet->add_comment( lo_comment ).
lo_comment = lo_excel->add_new_comment( ).
lo_comment->set_text( ip_ref = 'F6' ip_text = |A comment split{ cl_abap_char_utilities=>cr_lf }on 2 lines?| ).
lo_worksheet->add_comment( lo_comment ).
CONCATENATE 'A comment split' cl_abap_char_utilities=>cr_lf 'on 2 lines?' INTO lv_comment.
lo_comment->set_text( ip_ref = 'F6' ip_text = lv_comment ).
" Second sheet
lo_worksheet = lo_excel->add_new_worksheet( ).