From 7c5a0e9023d763cd3407c5157cb51f494f27addf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schm=C3=B6cker?= Date: Mon, 9 Apr 2012 09:08:48 +0000 Subject: [PATCH] Issue #158 - Enhancing exceptionclass ZCX_EXCEL git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@293 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 --- ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk | 52 +++++++++++++++++++---- ZA2X/CLAS/ZCX_EXCEL.slnk | 74 ++++++++++++++++++++++++++------- 2 files changed, 105 insertions(+), 21 deletions(-) diff --git a/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk b/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk index 5a40f28..94545e3 100644 --- a/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk +++ b/ZA2X/CLAS/ZCL_EXCEL_COMMON.slnk @@ -81,6 +81,9 @@ public section. value(IP_VALUE) type NUMERIC returning value(EP_VALUE) type ZEXCEL_CELL_VALUE . + class-methods RAISE_ZCX_EXCEL_AFTER_MESSAGE + raising + ZCX_EXCEL . class-methods RECURSIVE_CLASS_TO_STRUCT importing !I_SOURCE type ANY @@ -101,9 +104,9 @@ public section. *"* protected components of class ZCL_EXCEL_COMMON *"* do not include other source files here!!! protected section. - private section. -*"* private components of class ZCL_EXCEL_COMMON + *"* private components of class ZCL_EXCEL_COMMON *"* do not include other source files here!!! +private section. class-data C_EXCEL_COL_MODULE type INT2 value 64. "#EC NOTEXT . @@ -501,7 +504,42 @@ endmethod. ENDIF. endmethod. - + + + METHOD raise_zcx_excel_after_message. + + DATA: bapiret2 TYPE bapiret2. + +* Get message into bapiret2 + bapiret2-type = syst-msgty. + bapiret2-id = syst-msgid. + bapiret2-number = syst-msgno. + bapiret2-message_v1 = syst-msgv1. + bapiret2-message_v2 = syst-msgv2. + bapiret2-message_v3 = syst-msgv3. + bapiret2-message_v4 = syst-msgv4. + + MESSAGE ID bapiret2-id TYPE 'I' NUMBER bapiret2-number + WITH bapiret2-message_v1 bapiret2-message_v2 bapiret2-message_v3 bapiret2-message_v4 + INTO bapiret2-message. + +* And some callstackinformation at time of exception to pass down to whoever catches the exception + DATA: t_callstack TYPE abap_callstack. + + CALL FUNCTION 'SYSTEM_CALLSTACK' + IMPORTING + callstack = t_callstack. + + DELETE t_callstack INDEX 1. + + RAISE EXCEPTION TYPE zcx_excel + EXPORTING + bapiret2 = bapiret2 + callstack_when_raised = t_callstack. + +ENDMETHOD. + + @@ -560,7 +598,7 @@ endmethod. endmethod. - + @@ -620,7 +658,7 @@ endmethod. endmethod. - + method SHL01. @@ -640,7 +678,7 @@ endmethod. endmethod. - + method SHR14. @@ -667,7 +705,7 @@ endmethod. endmethod. - + method TIME_TO_EXCEL_STRING. diff --git a/ZA2X/CLAS/ZCX_EXCEL.slnk b/ZA2X/CLAS/ZCX_EXCEL.slnk index 4bb07f7..be13869 100644 --- a/ZA2X/CLAS/ZCX_EXCEL.slnk +++ b/ZA2X/CLAS/ZCX_EXCEL.slnk @@ -1,5 +1,6 @@ - - + + + class ZCX_EXCEL definition public inheriting from CX_STATIC_CHECK @@ -10,14 +11,21 @@ *"* do not include other source files here!!! public section. - constants ZCX_EXCEL type SOTR_CONC value 'DFA64849FDF4F6F1B39A000C29B7D360'. "#EC NOTEXT + constants ZCX_EXCEL type SOTR_CONC value '4F78250475E62A20E1008000995F1845'. "#EC NOTEXT data ERROR type STRING . + data BAPIRET2 type BAPIRET2 read-only . + data CALLSTACK_WHEN_RAISED type ABAP_CALLSTACK read-only . methods CONSTRUCTOR importing !TEXTID like TEXTID optional !PREVIOUS like PREVIOUS optional - !ERROR type STRING optional . + !ERROR type STRING optional + !BAPIRET2 type BAPIRET2 optional + !CALLSTACK_WHEN_RAISED type ABAP_CALLSTACK optional . + methods DISPLAY + importing + !IP_DISPLAY_LIKE type SYMSGTY optional . *"* protected components of class ZCX_EXCEL *"* do not include other source files here!!! protected section. @@ -32,18 +40,21 @@ private section. *"* implementation or private method's signature *"* use this source file for any macro definitions you need *"* in the implementation part of the class - - - - - + + + + + + - - - - - + + + + + + + method CONSTRUCTOR. CALL METHOD SUPER->CONSTRUCTOR EXPORTING @@ -54,6 +65,41 @@ PREVIOUS = PREVIOUS me->textid = ZCX_EXCEL . ENDIF. me->ERROR = ERROR . +me->BAPIRET2 = BAPIRET2 . +me->CALLSTACK_WHEN_RAISED = CALLSTACK_WHEN_RAISED . endmethod. + + + METHOD display. + DATA: msgty TYPE symsgty. + + CASE ip_display_like. + WHEN 'I' + OR 'S' + OR 'W' + OR 'E' + OR 'A' + OR 'X'. + msgty = ip_display_like. + + WHEN OTHERS. + IF me->bapiret2-type IS NOT INITIAL. + msgty = me->bapiret2-type. + ELSE. + msgty = 'I'. + ENDIF. + ENDCASE. + + IF me->bapiret2 IS NOT INITIAL. + MESSAGE ID me->bapiret2-id TYPE msgty NUMBER me->bapiret2-number + WITH me->bapiret2-message_v1 me->bapiret2-message_v2 me->bapiret2-message_v3 me->bapiret2-message_v4. + ELSEIF me->error IS NOT INITIAL. + MESSAGE me->error TYPE msgty. + ELSE. + MESSAGE 'Unknown error' TYPE msgty. + ENDIF. + +ENDMETHOD. +