Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancing ZCX_EXCEL #156

Closed
ivanfemia opened this issue Dec 27, 2013 · 4 comments
Closed

Enhancing ZCX_EXCEL #156

ivanfemia opened this issue Dec 27, 2013 · 4 comments
Labels
Milestone

Comments

@ivanfemia
Copy link
Collaborator

Discussion https://cw.sdn.sap.com/cw/message/76534#76534 didn't spawn any comments and thus no objections. So I am going to start on this enhancement.

i) Enhance Exceptionclass and provide a method to raise ZCX_EXCEL with additional information
ii) Create new messageclass
iii) Sift through current coding and replace raises found with the method proposed in the discussion. Create messages in messageclass on the fly where needed.

@ivanfemia
Copy link
Collaborator Author

i) is finished and will be commited in a moment.
ii) I'd like to receive some feedback on the name of the messageclass.
iii) To be done when ii) is decided upon.

ad i) The following testreport can be used to see how the extended functionality works out.

REPORT.
*----------------------------------------------------------------------*
*       CLASS test DEFINITION
*----------------------------------------------------------------------*
CLASS test DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS: test  RAISING zcx_excel.
ENDCLASS.                    "test DEFINITION
*----------------------------------------------------------------------*
*       CLASS test IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS test IMPLEMENTATION.
  METHOD test.
    MESSAGE e398(00) WITH 'Hugo' INTO sy-lisel.
    zcl_excel_common=>raise_zcx_excel_after_message( ).
  ENDMETHOD.                    "test
ENDCLASS.                    "test IMPLEMENTATION
END-OF-SELECTION.
  DATA: cx_error TYPE REF TO zcx_excel.
  FIELD-SYMBOLS:  LIKE LINE OF zcx_excel=>callstack_when_raised.  " Why is this actually allowed????  That is no static or constant.  Need to read some documentation I fear
  TRY.
      test=>test( ).
    CATCH zcx_excel INTO cx_error.
* We can display errors to the user of the program - including longtext if maintained
      cx_error->display( 'I' ).
* And for the programmer we are able to pass down
* - the errormessage
      WRITE:/ 'Errormessage:',
              cx_error->bapiret2-number NO-GAP,
              '(' NO-GAP,
              (2) cx_error->bapiret2-id NO-GAP,
              ')'.
      READ CURRENT LINE.
* - and the callstack
      LOOP AT cx_error->callstack_when_raised ASSIGNING .
        WRITE:/ -mainprogram, sy-vline,
                -include,     sy-vline,
                -line,        sy-vline,
                -blocktype,   sy-vline,
                -blockname  .
      ENDLOOP.
* for specific errorhandling
  ENDTRY.

@ivanfemia
Copy link
Collaborator Author

Had to put the "raise"-method into class ZCL_EXCEL_COMMON because SE24 doesn't quite allow everything that can be done in standard coding when handling exceptionclasses.

@ivanfemia
Copy link
Collaborator Author

Hi Stefan,

I didn't reply to your suggestion due Easter holidays.

Some comments:

ii) Message class could be named 'ZA2X'

i) I don't like the usage:

MESSAGE e398(00) WITH 'Hugo' INTO sy-lisel.
zcl_excel_common=>raise_zcx_excel_after_message( ).

What is the advantage of having a static method?

I would prefer something like:
MESSAGE e398(00) WITH 'Hugo' INTO lv_message.
RAISE EXCEPTION TYPE zcx_excel
EXPORTING
error = lv_message.

or better something like below it will be more class oriented (all the parameters are optional)
IF 1=2. MESSAGE e398(ZA2X) WITH 'Foo'. ENDIF. " to allow where used
RAISE EXCEPTION TYPE zcx_excel
EXPORTING
ID = 'ZA2X'
NUMBER = '398'

  •    MESSAGE = ' '
    MESSAGE_V1 = 'Foo'
    
  •    MESSAGE_V2 = ' '
    
  •    MESSAGE_V3 = ' '
    
  •    MESSAGE_V4 = ' '
    
    .

Exception will be always an error, I don't understand the usage of exception for Info message as in the test report.

Regards,
Ivan

@ivanfemia
Copy link
Collaborator Author

Invalidate this issue and continue on [[url:discussion thread |https://cw.sdn.sap.com/cw/message/76534]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant