Merge pull request #566 from AtomKrieg/master

modern style exception raise
This commit is contained in:
Ivan 2018-10-19 15:18:51 -05:00 committed by GitHub
commit 3c578c447e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 102 additions and 225 deletions

View File

@ -306,9 +306,7 @@ METHOD delete_worksheet.
lo_worksheet = me->get_worksheet_by_index( 1 ). lo_worksheet = me->get_worksheet_by_index( 1 ).
IF lo_worksheet = io_worksheet. IF lo_worksheet = io_worksheet.
lv_errormessage = 'Deleting last remaining worksheet is not allowed'(002). lv_errormessage = 'Deleting last remaining worksheet is not allowed'(002).
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( lv_errormessage ).
EXPORTING
error = lv_errormessage.
ENDIF. ENDIF.
ENDIF. ENDIF.
@ -325,9 +323,7 @@ METHOD delete_worksheet_by_index.
lo_worksheet = me->get_worksheet_by_index( iv_index ). lo_worksheet = me->get_worksheet_by_index( iv_index ).
IF lo_worksheet IS NOT BOUND. IF lo_worksheet IS NOT BOUND.
lv_errormessage = 'Worksheet not existing'(001). lv_errormessage = 'Worksheet not existing'(001).
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( lv_errormessage ).
EXPORTING
error = lv_errormessage.
ENDIF. ENDIF.
me->delete_worksheet( lo_worksheet ). me->delete_worksheet( lo_worksheet ).
@ -342,9 +338,7 @@ METHOD delete_worksheet_by_name.
lo_worksheet = me->get_worksheet_by_name( iv_title ). lo_worksheet = me->get_worksheet_by_name( iv_title ).
IF lo_worksheet IS NOT BOUND. IF lo_worksheet IS NOT BOUND.
lv_errormessage = 'Worksheet not existing'(001). lv_errormessage = 'Worksheet not existing'(001).
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( lv_errormessage ).
EXPORTING
error = lv_errormessage.
ENDIF. ENDIF.
me->delete_worksheet( lo_worksheet ). me->delete_worksheet( lo_worksheet ).
@ -481,9 +475,7 @@ method GET_STYLE_INDEX_IN_STYLES.
ENDWHILE. ENDWHILE.
IF ep_index IS INITIAL. IF ep_index IS INITIAL.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( 'Index not found' ).
EXPORTING
error = 'Index not found'.
else. else.
SUBTRACT 1 from ep_index. " In excel list starts with "0" SUBTRACT 1 from ep_index. " In excel list starts with "0"
ENDIF. ENDIF.
@ -495,9 +487,7 @@ METHOD get_style_to_guid.
" # issue 139 " # issue 139
READ TABLE me->t_stylemapping2 INTO ep_stylemapping WITH TABLE KEY guid = ip_guid. READ TABLE me->t_stylemapping2 INTO ep_stylemapping WITH TABLE KEY guid = ip_guid.
IF sy-subrc <> 0. IF sy-subrc <> 0.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( 'GUID not found' ).
EXPORTING
error = 'GUID not found'.
ENDIF. ENDIF.
IF ep_stylemapping-dynamic_style_guid IS NOT INITIAL. IF ep_stylemapping-dynamic_style_guid IS NOT INITIAL.
@ -576,9 +566,7 @@ METHOD set_active_sheet_index.
lo_worksheet = me->get_worksheet_by_index( i_active_worksheet ). lo_worksheet = me->get_worksheet_by_index( i_active_worksheet ).
IF lo_worksheet IS NOT BOUND. IF lo_worksheet IS NOT BOUND.
lv_errormessage = 'Worksheet not existing'(001). lv_errormessage = 'Worksheet not existing'(001).
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( lv_errormessage ).
EXPORTING
error = lv_errormessage.
ENDIF. ENDIF.
me->worksheets->active_worksheet = i_active_worksheet. me->worksheets->active_worksheet = i_active_worksheet.

View File

@ -185,9 +185,7 @@ method SET_COLUMN_STYLE_BY_GUID.
DATA: stylemapping TYPE zexcel_s_stylemapping. DATA: stylemapping TYPE zexcel_s_stylemapping.
IF me->excel IS NOT BOUND. IF me->excel IS NOT BOUND.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( 'Internal error - reference to ZCL_EXCEL not bound' ).
EXPORTING
error = 'Internal error - reference to ZCL_EXCEL not bound'.
ENDIF. ENDIF.
TRY. TRY.
stylemapping = me->excel->get_style_to_guid( ip_style_guid ). stylemapping = me->excel->get_style_to_guid( ip_style_guid ).
@ -216,9 +214,7 @@ METHOD set_width.
me->width = ip_width. me->width = ip_width.
io_column = me. io_column = me.
CATCH cx_sy_conversion_no_number. CATCH cx_sy_conversion_no_number.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( 'Unable to interpret width as number' ).
EXPORTING
error = 'Unable to interpret width as number'.
ENDTRY. ENDTRY.
ENDMETHOD. ENDMETHOD.

View File

@ -405,9 +405,7 @@ METHOD convert_column2alpha.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
IF lv_column > 16384 IF lv_column > 16384
OR lv_column < 1. OR lv_column < 1.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( 'Index out of bounds' ).
EXPORTING
error = 'Index out of bounds'.
ENDIF. ENDIF.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
@ -488,13 +486,8 @@ METHOD convert_column2int.
CONDENSE lv_column_c NO-GAPS. CONDENSE lv_column_c NO-GAPS.
IF lv_column_c EQ ''. IF lv_column_c EQ ''.
* lv_errormessage = 'Unable to interpret input as column'(003). * lv_errormessage = 'Unable to interpret input as column'(003).
* RAISE EXCEPTION TYPE zcx_excel
* EXPORTING
* error = lv_errormessage.
MESSAGE e800(zabap2xlsx) INTO lv_errormessage. MESSAGE e800(zabap2xlsx) INTO lv_errormessage.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_symsg( ).
EXPORTING
syst_at_raise = syst.
ENDIF. ENDIF.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
@ -520,9 +513,7 @@ METHOD convert_column2int.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
IF ep_column > 16384 OR ep_column < 1. IF ep_column > 16384 OR ep_column < 1.
lv_errormessage = 'Index out of bounds'(004). lv_errormessage = 'Index out of bounds'(004).
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( lv_errormessage ).
EXPORTING
error = lv_errormessage.
ENDIF. ENDIF.
EXIT. EXIT.
ENDIF. ENDIF.
@ -536,13 +527,8 @@ METHOD convert_column2int.
lv_column_s = lv_column_c. lv_column_s = lv_column_c.
IF lv_column_s CN sy-abcde. IF lv_column_s CN sy-abcde.
* lv_errormessage = 'Unable to interpret input as column'(003). * lv_errormessage = 'Unable to interpret input as column'(003).
* RAISE EXCEPTION TYPE zcx_excel
* EXPORTING
* error = lv_errormessage.
MESSAGE e800(zabap2xlsx) INTO lv_errormessage. MESSAGE e800(zabap2xlsx) INTO lv_errormessage.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_symsg( ).
EXPORTING
syst_at_raise = syst.
ENDIF. ENDIF.
DO 1 TIMES. "Because of using CHECK DO 1 TIMES. "Because of using CHECK
@ -556,13 +542,8 @@ METHOD convert_column2int.
lv_modulo = cl_abap_conv_out_ce=>uccpi( lv_column+0(1) ) MOD zcl_excel_common=>c_excel_col_module. lv_modulo = cl_abap_conv_out_ce=>uccpi( lv_column+0(1) ) MOD zcl_excel_common=>c_excel_col_module.
IF lv_modulo < 1 OR lv_modulo > 26. IF lv_modulo < 1 OR lv_modulo > 26.
* lv_errormessage = 'Unable to interpret input as column'(003). * lv_errormessage = 'Unable to interpret input as column'(003).
* RAISE EXCEPTION TYPE zcx_excel
* EXPORTING
* error = lv_errormessage.
MESSAGE e800(zabap2xlsx) INTO lv_errormessage. MESSAGE e800(zabap2xlsx) INTO lv_errormessage.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_symsg( ).
EXPORTING
syst_at_raise = syst.
ENDIF. ENDIF.
ep_column = lv_modulo. " Leftmost digit ep_column = lv_modulo. " Leftmost digit
@ -573,13 +554,8 @@ METHOD convert_column2int.
lv_modulo = cl_abap_conv_out_ce=>uccpi( lv_column+1(1) ) MOD zcl_excel_common=>c_excel_col_module. lv_modulo = cl_abap_conv_out_ce=>uccpi( lv_column+1(1) ) MOD zcl_excel_common=>c_excel_col_module.
IF lv_modulo < 1 OR lv_modulo > 26. IF lv_modulo < 1 OR lv_modulo > 26.
* lv_errormessage = 'Unable to interpret input as column'(003). * lv_errormessage = 'Unable to interpret input as column'(003).
* RAISE EXCEPTION TYPE zcx_excel
* EXPORTING
* error = lv_errormessage.
MESSAGE e800(zabap2xlsx) INTO lv_errormessage. MESSAGE e800(zabap2xlsx) INTO lv_errormessage.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_symsg( ).
EXPORTING
syst_at_raise = syst.
ENDIF. ENDIF.
ep_column = 26 * ep_column + lv_modulo. " if second digit is present first digit is for 26^1 ep_column = 26 * ep_column + lv_modulo. " if second digit is present first digit is for 26^1
@ -590,13 +566,8 @@ METHOD convert_column2int.
lv_modulo = cl_abap_conv_out_ce=>uccpi( lv_column+2(1) ) MOD zcl_excel_common=>c_excel_col_module. lv_modulo = cl_abap_conv_out_ce=>uccpi( lv_column+2(1) ) MOD zcl_excel_common=>c_excel_col_module.
IF lv_modulo < 1 OR lv_modulo > 26. IF lv_modulo < 1 OR lv_modulo > 26.
* lv_errormessage = 'Unable to interpret input as column'(003). * lv_errormessage = 'Unable to interpret input as column'(003).
* RAISE EXCEPTION TYPE zcx_excel
* EXPORTING
* error = lv_errormessage.
MESSAGE e800(zabap2xlsx) INTO lv_errormessage. MESSAGE e800(zabap2xlsx) INTO lv_errormessage.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_symsg( ).
EXPORTING
syst_at_raise = syst.
ENDIF. ENDIF.
ep_column = 26 * ep_column + lv_modulo. " if third digit is present first digit is for 26^2 and second digit for 26^1 ep_column = 26 * ep_column + lv_modulo. " if third digit is present first digit is for 26^2 and second digit for 26^1
ENDDO. ENDDO.
@ -606,9 +577,7 @@ METHOD convert_column2int.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
IF ep_column > 16384 OR ep_column < 1. IF ep_column > 16384 OR ep_column < 1.
lv_errormessage = 'Index out of bounds'(004). lv_errormessage = 'Index out of bounds'(004).
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( lv_errormessage ).
EXPORTING
error = lv_errormessage.
ENDIF. ENDIF.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
@ -695,9 +664,7 @@ method CONVERT_RANGE2COLUMN_A_ROW.
SHIFT lv_range LEFT BY sy-fdpos PLACES. SHIFT lv_range LEFT BY sy-fdpos PLACES.
ELSE. ELSE.
lv_errormessage = 'Invalid range'(001). lv_errormessage = 'Invalid range'(001).
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( lv_errormessage ).
EXPORTING
error = lv_errormessage.
ENDIF. ENDIF.
ELSEIF i_range CS '!'. " c) sheetname existing - does not start with ' ELSEIF i_range CS '!'. " c) sheetname existing - does not start with '
@ -917,9 +884,7 @@ method EXCEL_STRING_TO_DATE.
ep_value = ep_value + 1. ep_value = ep_value + 1.
ENDIF. ENDIF.
CATCH cx_sy_conversion_error. CATCH cx_sy_conversion_error.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( 'Index out of bounds' ).
EXPORTING
error = 'Index out of bounds'.
ENDTRY. ENDTRY.
endmethod. endmethod.
@ -947,9 +912,7 @@ method EXCEL_STRING_TO_TIME.
ep_value = lv_seconds_in_day. ep_value = lv_seconds_in_day.
CATCH cx_sy_conversion_error. CATCH cx_sy_conversion_error.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( 'Unable to interpret time' ).
EXPORTING
error = 'Unable to interpret time'.
ENDTRY. ENDTRY.
endmethod. endmethod.
@ -1381,9 +1344,7 @@ METHOD shift_formula.
MOVE: iv_reference_formula+lv_offset1(lv_tlen) TO lv_ref_cell_addr. "Ref cell address MOVE: iv_reference_formula+lv_offset1(lv_tlen) TO lv_ref_cell_addr. "Ref cell address
CATCH cx_root. CATCH cx_root.
lv_errormessage = 'Internal error in Class ZCL_EXCEL_COMMON Method SHIFT_FORMULA Spot 1 '. " Change to messageclass if possible lv_errormessage = 'Internal error in Class ZCL_EXCEL_COMMON Method SHIFT_FORMULA Spot 1 '. " Change to messageclass if possible
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( lv_errormessage ).
EXPORTING
error = lv_errormessage.
ENDTRY. ENDTRY.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
@ -1720,9 +1681,7 @@ method UNESCAPE_STRING.
REPLACE REGEX `^'(.*)'$` IN ev_unescaped_string WITH '$1'. REPLACE REGEX `^'(.*)'$` IN ev_unescaped_string WITH '$1'.
IF sy-subrc <> 0. IF sy-subrc <> 0.
lv_errormessage = 'Input not properly escaped - &'(002). lv_errormessage = 'Input not properly escaped - &'(002).
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( lv_errormessage ).
EXPORTING
error = lv_errormessage.
ENDIF. ENDIF.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
@ -1731,9 +1690,7 @@ method UNESCAPE_STRING.
FIND REGEX lcv_regex IN ev_unescaped_string. FIND REGEX lcv_regex IN ev_unescaped_string.
IF sy-subrc = 0. IF sy-subrc = 0.
lv_errormessage = 'Input not properly escaped - &'(002). lv_errormessage = 'Input not properly escaped - &'(002).
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( lv_errormessage ).
EXPORTING
error = lv_errormessage.
ENDIF. ENDIF.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*

View File

@ -127,9 +127,7 @@ method GET_COLOR.
lv_index = ip_index + 1. lv_index = ip_index + 1.
READ TABLE colors INTO ep_color INDEX lv_index. READ TABLE colors INTO ep_color INDEX lv_index.
IF sy-subrc <> 0. IF sy-subrc <> 0.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( 'Invalid color index' ).
EXPORTING
error = 'Invalid color index'.
ENDIF. ENDIF.
endmethod. endmethod.
@ -152,9 +150,7 @@ method SET_COLOR.
lv_index = ip_index + 1. lv_index = ip_index + 1.
READ TABLE colors ASSIGNING <lv_color> INDEX lv_index. READ TABLE colors ASSIGNING <lv_color> INDEX lv_index.
IF sy-subrc <> 0. IF sy-subrc <> 0.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( 'Invalid color index' ).
EXPORTING
error = 'Invalid color index'.
ENDIF. ENDIF.
IF <lv_color> <> ip_color. IF <lv_color> <> ip_color.

View File

@ -3584,9 +3584,7 @@ METHOD read_from_applserver.
OPEN DATASET lv_filename FOR INPUT IN BINARY MODE. OPEN DATASET lv_filename FOR INPUT IN BINARY MODE.
IF sy-subrc <> 0. IF sy-subrc <> 0.
lv_errormessage = 'A problem occured when reading the file'(001). lv_errormessage = 'A problem occured when reading the file'(001).
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( lv_errormessage ).
EXPORTING
error = lv_errormessage.
ENDIF. ENDIF.
WHILE sy-subrc = 0. WHILE sy-subrc = 0.
@ -3648,9 +3646,7 @@ METHOD read_from_local_file.
OTHERS = 19 ). OTHERS = 19 ).
IF sy-subrc <> 0. IF sy-subrc <> 0.
lv_errormessage = 'A problem occured when reading the file'(001). lv_errormessage = 'A problem occured when reading the file'(001).
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( lv_errormessage ).
EXPORTING
error = lv_errormessage.
ENDIF. ENDIF.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*

View File

@ -211,9 +211,7 @@ method LOAD_WORKSHEET.
io_worksheet = io_worksheet ). io_worksheet = io_worksheet ).
catch lcx_not_found into lx_not_found. catch lcx_not_found into lx_not_found.
raise exception type zcx_excel zcx_excel=>raise_text( lx_not_found->error ).
exporting
error = lx_not_found->error.
endtry. endtry.
endmethod. endmethod.

View File

@ -190,9 +190,7 @@ method SET_OUTLINE_LEVEL.
IF ip_outline_level < 0 IF ip_outline_level < 0
OR ip_outline_level > 7. OR ip_outline_level > 7.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( 'Outline level must range between 0 and 7.' ).
EXPORTING
error = 'Outline level must range between 0 and 7.'.
ENDIF. ENDIF.
me->outline_level = ip_outline_level. me->outline_level = ip_outline_level.
@ -203,9 +201,7 @@ method SET_ROW_HEIGHT.
TRY. TRY.
me->row_height = ip_row_height. me->row_height = ip_row_height.
CATCH cx_sy_conversion_no_number. CATCH cx_sy_conversion_no_number.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( 'Unable to interpret ip_row_height as number' ).
EXPORTING
error = 'Unable to interpret ip_row_height as number'.
ENDTRY. ENDTRY.
endmethod. endmethod.

View File

@ -261,9 +261,7 @@ method GET_TOTALS_FORMULA.
RETURN. RETURN.
WHEN OTHERS. WHEN OTHERS.
RAISE EXCEPTION TYPE zcx_excel zcx_excel=>raise_text( 'Invalid totals formula. See ZCL_ for possible values' ).
EXPORTING
error = 'Invalid totals formula. See ZCL_ for possible values'.
ENDCASE. ENDCASE.
CONCATENATE 'SUBTOTAL(' lv_function_id ',[' ip_column '])' INTO ep_formula. CONCATENATE 'SUBTOTAL(' lv_function_id ',[' ip_column '])' INTO ep_formula.

View File

@ -2817,9 +2817,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
( LV_MAXCOL ge ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( LO_CURTABLE->SETTINGS-TOP_LEFT_COLUMN ) and LV_MAXCOL le ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( LO_CURTABLE->SETTINGS-BOTTOM_RIGHT_COLUMN ) ) ( LV_MAXCOL ge ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( LO_CURTABLE->SETTINGS-TOP_LEFT_COLUMN ) and LV_MAXCOL le ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( LO_CURTABLE->SETTINGS-BOTTOM_RIGHT_COLUMN ) )
). ).
LV_ERRORMESSAGE = 'Table overlaps with previously bound table and will not be added to worksheet.'(400). LV_ERRORMESSAGE = 'Table overlaps with previously bound table and will not be added to worksheet.'(400).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endif. endif.
endwhile. endwhile.
@ -3395,9 +3393,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
* move_supplied_multistyles: complete. * move_supplied_multistyles: complete.
if IP_COMPLETE is supplied. if IP_COMPLETE is supplied.
if IP_XCOMPLETE is not supplied. if IP_XCOMPLETE is not supplied.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Complete styleinfo has to be supplied with corresponding X-field' ).
exporting
ERROR = 'Complete styleinfo has to be supplied with corresponding X-field'.
endif. endif.
move-corresponding IP_COMPLETE to COMPLETE_STYLE. move-corresponding IP_COMPLETE to COMPLETE_STYLE.
move-corresponding IP_XCOMPLETE to COMPLETE_STYLEX. move-corresponding IP_XCOMPLETE to COMPLETE_STYLEX.
@ -3727,9 +3723,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
delete ME->MT_ROW_OUTLINES where ROW_FROM = IV_ROW_FROM delete ME->MT_ROW_OUTLINES where ROW_FROM = IV_ROW_FROM
and ROW_TO = IV_ROW_TO. and ROW_TO = IV_ROW_TO.
if SY-SUBRC <> 0. " didn't find outline that was to be deleted if SY-SUBRC <> 0. " didn't find outline that was to be deleted
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Row outline to be deleted does not exist' ).
exporting
ERROR = 'Row outline to be deleted does not exist'.
endif. endif.
endmethod. endmethod.
@ -3738,21 +3732,15 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
method FREEZE_PANES. method FREEZE_PANES.
if IP_NUM_COLUMNS is not supplied and IP_NUM_ROWS is not supplied. if IP_NUM_COLUMNS is not supplied and IP_NUM_ROWS is not supplied.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Pleas provide number of rows and/or columns to freeze' ).
exporting
ERROR = 'Pleas provide number of rows and/or columns to freeze'.
endif. endif.
if IP_NUM_COLUMNS is supplied and IP_NUM_COLUMNS <= 0. if IP_NUM_COLUMNS is supplied and IP_NUM_COLUMNS <= 0.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Number of columns to freeze should be positive' ).
exporting
ERROR = 'Number of columns to freeze should be positive'.
endif. endif.
if IP_NUM_ROWS is supplied and IP_NUM_ROWS <= 0. if IP_NUM_ROWS is supplied and IP_NUM_ROWS <= 0.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Number of rows to freeze should be positive' ).
exporting
ERROR = 'Number of rows to freeze should be positive'.
endif. endif.
FREEZE_PANE_CELL_COLUMN = IP_NUM_COLUMNS + 1. FREEZE_PANE_CELL_COLUMN = IP_NUM_COLUMNS + 1.
@ -4189,18 +4177,14 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
if SY-SUBRC <> 0 or <LS_LINE> is not assigned. 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).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
else. else.
LV_DELTA_COL = LV_MAX_COL - IV_SKIPPED_COLS. LV_DELTA_COL = LV_MAX_COL - IV_SKIPPED_COLS.
assign component LV_DELTA_COL of structure <LS_LINE> to <LV_VALUE>. assign component LV_DELTA_COL of structure <LS_LINE> to <LV_VALUE>.
if SY-SUBRC <> 0 or <LV_VALUE> is not assigned. if SY-SUBRC <> 0 or <LV_VALUE> is not assigned.
LV_ERRORMESSAGE = 'Internal table has less columns than excel'(003). LV_ERRORMESSAGE = 'Internal table has less columns than excel'(003).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
else. else.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
*now we are ready for handle the table data *now we are ready for handle the table data
@ -4221,9 +4205,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
append initial line to ET_TABLE assigning <LS_LINE>. append initial line to ET_TABLE assigning <LS_LINE>.
if SY-SUBRC <> 0 or <LS_LINE> is not assigned. 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).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endif. endif.
while LV_ACTUAL_COL <= LV_MAX_COL. while LV_ACTUAL_COL <= LV_MAX_COL.
@ -4231,9 +4213,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
assign component LV_DELTA_COL of structure <LS_LINE> to <LV_VALUE>. assign component LV_DELTA_COL of structure <LS_LINE> to <LV_VALUE>.
if SY-SUBRC <> 0. if SY-SUBRC <> 0.
LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endif. endif.
ME->GET_CELL( ME->GET_CELL(
@ -4247,9 +4227,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
if LV_RC <> 0 if LV_RC <> 0
and LV_RC <> 4. "No found error means, zero/no value in cell 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 }|. LV_ERRORMESSAGE = |{ 'Error at reading field value (Col:'(007) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endif. endif.
<LV_VALUE> = LV_VALUE. <LV_VALUE> = LV_VALUE.
@ -4265,24 +4243,16 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
catch CX_SY_ASSIGN_CAST_ILLEGAL_CAST. catch CX_SY_ASSIGN_CAST_ILLEGAL_CAST.
LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
catch CX_SY_ASSIGN_CAST_UNKNOWN_TYPE. catch CX_SY_ASSIGN_CAST_UNKNOWN_TYPE.
LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. LV_ERRORMESSAGE = |{ 'Error at assigning field (Col:'(004) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
catch CX_SY_ASSIGN_OUT_OF_RANGE. catch CX_SY_ASSIGN_OUT_OF_RANGE.
LV_ERRORMESSAGE = 'Internal table has less columns than excel'(003). LV_ERRORMESSAGE = 'Internal table has less columns than excel'(003).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
catch CX_SY_CONVERSION_ERROR. catch CX_SY_CONVERSION_ERROR.
LV_ERRORMESSAGE = |{ 'Error at converting field value (Col:'(006) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|. LV_ERRORMESSAGE = |{ 'Error at converting field value (Col:'(006) } { LV_ACTUAL_COL } { ' Row:'(005) } { LV_ACTUAL_ROW }|.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endtry. endtry.
endmethod. endmethod.
@ -4512,9 +4482,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
<FS_VALUE> type SIMPLE. <FS_VALUE> type SIMPLE.
if IP_VALUE is not supplied and IP_FORMULA is not supplied. if IP_VALUE is not supplied and IP_FORMULA is not supplied.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Please provide the value or formula' ).
exporting
ERROR = 'Please provide the value or formula'.
endif. endif.
* Begin of change issue #152 - don't touch exisiting style if only value is passed * Begin of change issue #152 - don't touch exisiting style if only value is passed
@ -4617,9 +4585,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
* End of change issue #152 - don't touch exisiting style if only value is passed * End of change issue #152 - don't touch exisiting style if only value is passed
when others. when others.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Invalid data type of input value' ).
exporting
ERROR = 'Invalid data type of input value'.
endcase. endcase.
endif. endif.
@ -4781,17 +4747,13 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
try. try.
WIDTH = IP_WIDTH_FIX. WIDTH = IP_WIDTH_FIX.
if WIDTH <= 0. if WIDTH <= 0.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Please supply a positive number as column-width' ).
exporting
ERROR = 'Please supply a positive number as column-width'.
endif. endif.
LO_COLUMN->SET_WIDTH( WIDTH ). LO_COLUMN->SET_WIDTH( WIDTH ).
exit. exit.
catch CX_SY_CONVERSION_NO_NUMBER. catch CX_SY_CONVERSION_NO_NUMBER.
* Strange stuff passed --> raise error * Strange stuff passed --> raise error
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Unable to interpret supplied input as number' ).
exporting
ERROR = 'Unable to interpret supplied input as number'.
endtry. endtry.
endif. endif.
@ -4805,9 +4767,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
method SET_DEFAULT_EXCEL_DATE_FORMAT. method SET_DEFAULT_EXCEL_DATE_FORMAT.
if IP_DEFAULT_EXCEL_DATE_FORMAT is initial. if IP_DEFAULT_EXCEL_DATE_FORMAT is initial.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Default date format cannot be blank' ).
exporting
ERROR = 'Default date format cannot be blank'.
endif. endif.
DEFAULT_EXCEL_DATE_FORMAT = IP_DEFAULT_EXCEL_DATE_FORMAT. DEFAULT_EXCEL_DATE_FORMAT = IP_DEFAULT_EXCEL_DATE_FORMAT.
@ -4830,9 +4790,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
endif. endif.
if LS_MERGE-ROW_FROM > LS_MERGE-ROW_TO. if LS_MERGE-ROW_FROM > LS_MERGE-ROW_TO.
LV_ERRORMESSAGE = 'Merge: First row larger then last row'(405). LV_ERRORMESSAGE = 'Merge: First row larger then last row'(405).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endif. endif.
LS_MERGE-COL_FROM = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IP_COLUMN_START ). LS_MERGE-COL_FROM = ZCL_EXCEL_COMMON=>CONVERT_COLUMN2INT( IP_COLUMN_START ).
@ -4843,9 +4801,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
endif. endif.
if LS_MERGE-COL_FROM > LS_MERGE-COL_TO. if LS_MERGE-COL_FROM > LS_MERGE-COL_TO.
LV_ERRORMESSAGE = 'Merge: First column larger then last column'(406). LV_ERRORMESSAGE = 'Merge: First column larger then last column'(406).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endif. endif.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
@ -4856,9 +4812,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
or COL_FROM > LS_MERGE-COL_TO or COL_FROM > LS_MERGE-COL_TO
or COL_TO < LS_MERGE-COL_FROM ). or COL_TO < LS_MERGE-COL_FROM ).
LV_ERRORMESSAGE = 'Overlapping merges'(404). LV_ERRORMESSAGE = 'Overlapping merges'(404).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endloop. endloop.
@ -4885,17 +4839,13 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
try. try.
HEIGHT = IP_HEIGHT_FIX. HEIGHT = IP_HEIGHT_FIX.
if HEIGHT <= 0. if HEIGHT <= 0.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Please supply a positive number as row-height' ).
exporting
ERROR = 'Please supply a positive number as row-height'.
endif. endif.
LO_ROW->SET_ROW_HEIGHT( HEIGHT ). LO_ROW->SET_ROW_HEIGHT( HEIGHT ).
exit. exit.
catch CX_SY_CONVERSION_NO_NUMBER. catch CX_SY_CONVERSION_NO_NUMBER.
* Strange stuff passed --> raise error * Strange stuff passed --> raise error
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Unable to interpret supplied input as number' ).
exporting
ERROR = 'Unable to interpret supplied input as number'.
endtry. endtry.
endmethod. endmethod.
@ -4910,14 +4860,10 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
ROW_TO = IV_ROW_TO. ROW_TO = IV_ROW_TO.
if SY-SUBRC <> 0. if SY-SUBRC <> 0.
if IV_ROW_FROM <= 0. if IV_ROW_FROM <= 0.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'First row of outline must be a positive number' ).
exporting
ERROR = 'First row of outline must be a positive number'.
endif. endif.
if IV_ROW_TO < IV_ROW_FROM. if IV_ROW_TO < IV_ROW_FROM.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Last row of outline may not be less than first line of outline' ).
exporting
ERROR = 'Last row of outline may not be less than first line of outline'.
endif. endif.
LS_ROW_OUTLINE-ROW_FROM = IV_ROW_FROM. LS_ROW_OUTLINE-ROW_FROM = IV_ROW_FROM.
LS_ROW_OUTLINE-ROW_TO = IV_ROW_TO. LS_ROW_OUTLINE-ROW_TO = IV_ROW_TO.
@ -4931,9 +4877,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
<LS_ROW_OUTLINE>-COLLAPSED = IV_COLLAPSED. <LS_ROW_OUTLINE>-COLLAPSED = IV_COLLAPSED.
when others. when others.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( 'Unknown collapse state' ).
exporting
ERROR = 'Unknown collapse state'.
endcase. endcase.
endmethod. endmethod.
@ -5062,17 +5006,13 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
if IP_TITLE ca '/\[]*?:'. if IP_TITLE ca '/\[]*?:'.
LV_ERRORMESSAGE = 'Found illegal character in sheetname. List of forbidden characters: /\[]*?:'(402). LV_ERRORMESSAGE = 'Found illegal character in sheetname. List of forbidden characters: /\[]*?:'(402).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endif. endif.
if IP_TITLE is not initial and IP_TITLE(1) = `'`. if IP_TITLE is not initial and IP_TITLE(1) = `'`.
LV_ERRORMESSAGE = 'Sheetname may not start with &'(403). " & used instead of ' to allow fallbacklanguage LV_ERRORMESSAGE = 'Sheetname may not start with &'(403). " & used instead of ' to allow fallbacklanguage
replace '&' in LV_ERRORMESSAGE with `'`. replace '&' in LV_ERRORMESSAGE with `'`.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endif. endif.
@ -5087,9 +5027,7 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
if IP_TITLE = LO_WORKSHEET->GET_TITLE( ). " Not unique --> raise exception if IP_TITLE = LO_WORKSHEET->GET_TITLE( ). " Not unique --> raise exception
ERRORMESSAGE = 'Duplicate sheetname &'. ERRORMESSAGE = 'Duplicate sheetname &'.
replace '&' in ERRORMESSAGE with IP_TITLE. replace '&' in ERRORMESSAGE with IP_TITLE.
raise exception type ZCX_EXCEL zcx_excel=>raise_text( errormessage ).
exporting
ERROR = ERRORMESSAGE.
endif. endif.
endwhile. endwhile.
@ -5237,16 +5175,12 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
if LV_COL_FROM_INT < 1. if LV_COL_FROM_INT < 1.
LV_ERRORMESSAGE = 'Invalid range supplied for print-title repeatable columns'(401). LV_ERRORMESSAGE = 'Invalid range supplied for print-title repeatable columns'(401).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endif. endif.
if LV_COL_FROM_INT > LV_COL_TO_INT. if LV_COL_FROM_INT > LV_COL_TO_INT.
LV_ERRORMESSAGE = 'Invalid range supplied for print-title repeatable columns'(401). LV_ERRORMESSAGE = 'Invalid range supplied for print-title repeatable columns'(401).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endif. endif.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
@ -5278,16 +5212,12 @@ CLASS ZCL_EXCEL_WORKSHEET IMPLEMENTATION.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*
if IV_ROWS_FROM < 1. if IV_ROWS_FROM < 1.
LV_ERRORMESSAGE = 'Invalid range supplied for print-title repeatable rowumns'(401). LV_ERRORMESSAGE = 'Invalid range supplied for print-title repeatable rowumns'(401).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endif. endif.
if IV_ROWS_FROM > IV_ROWS_TO. if IV_ROWS_FROM > IV_ROWS_TO.
LV_ERRORMESSAGE = 'Invalid range supplied for print-title repeatable rowumns'(401). LV_ERRORMESSAGE = 'Invalid range supplied for print-title repeatable rowumns'(401).
raise exception type ZCX_EXCEL zcx_excel=>raise_text( lv_errormessage ).
exporting
ERROR = LV_ERRORMESSAGE.
endif. endif.
*--------------------------------------------------------------------* *--------------------------------------------------------------------*

View File

@ -5,9 +5,13 @@ class ZCX_EXCEL definition
*"* public components of class ZCX_EXCEL *"* public components of class ZCX_EXCEL
*"* do not include other source files here!!! *"* do not include other source files here!!!
*"* protected components of class ZCX_EXCEL
*"* do not include other source files here!!!
*"* protected components of class ZCX_EXCEL
*"* do not include other source files here!!!
public section. public section.
constants ZCX_EXCEL type SOTR_CONC value '028C0ED2B5601ED78EB6F3368B1E4F9B'. "#EC NOTEXT constants ZCX_EXCEL type SOTR_CONC value '028C0ED2B5601ED78EB6F3368B1E4F9B' ##NO_TEXT.
data ERROR type STRING . data ERROR type STRING .
data SYST_AT_RAISE type SYST . data SYST_AT_RAISE type SYST .
@ -17,15 +21,19 @@ public section.
!PREVIOUS like PREVIOUS optional !PREVIOUS like PREVIOUS optional
!ERROR type STRING optional !ERROR type STRING optional
!SYST_AT_RAISE type SYST optional . !SYST_AT_RAISE type SYST optional .
class-methods RAISE_TEXT
importing
!IV_TEXT type CLIKE
raising
ZCX_EXCEL .
class-methods RAISE_SYMSG
raising
ZCX_EXCEL .
methods IF_MESSAGE~GET_LONGTEXT methods IF_MESSAGE~GET_LONGTEXT
redefinition . redefinition .
methods IF_MESSAGE~GET_TEXT methods IF_MESSAGE~GET_TEXT
redefinition . redefinition .
*"* protected components of class ZCX_EXCEL
*"* do not include other source files here!!!
*"* protected components of class ZCX_EXCEL
*"* do not include other source files here!!!
protected section. protected section.
*"* private components of class ZCX_EXCEL *"* private components of class ZCX_EXCEL
*"* do not include other source files here!!! *"* do not include other source files here!!!
@ -37,7 +45,7 @@ ENDCLASS.
CLASS ZCX_EXCEL IMPLEMENTATION. CLASS ZCX_EXCEL IMPLEMENTATION.
method CONSTRUCTOR. method CONSTRUCTOR.
CALL METHOD SUPER->CONSTRUCTOR CALL METHOD SUPER->CONSTRUCTOR
EXPORTING EXPORTING
TEXTID = TEXTID TEXTID = TEXTID
@ -48,7 +56,7 @@ PREVIOUS = PREVIOUS
ENDIF. ENDIF.
me->ERROR = ERROR . me->ERROR = ERROR .
me->SYST_AT_RAISE = SYST_AT_RAISE . me->SYST_AT_RAISE = SYST_AT_RAISE .
endmethod. endmethod.
method IF_MESSAGE~GET_LONGTEXT. method IF_MESSAGE~GET_LONGTEXT.
@ -94,4 +102,18 @@ method IF_MESSAGE~GET_TEXT.
result = result. result = result.
ENDIF. ENDIF.
endmethod. endmethod.
method RAISE_SYMSG.
raise exception type zcx_excel
exporting
syst_at_raise = syst.
endmethod.
method RAISE_TEXT.
raise exception type zcx_excel
exporting
error = iv_text.
endmethod.
ENDCLASS. ENDCLASS.