passing T100 message details to OO exceptions

Mike Pokraka wug at workflowconnections.com
Thu Jun 21 12:45:29 EDT 2012


Hi Paul,

You answered your own question.

How exactly is the exception supposed to magically know that the contract
is locked?

It provides the exact message you told it to:
     RAISE EXCEPTION TYPE CX_BO_TEMPORARY
        EXPORTING *TEXTID = CX_BO_TEMPORARY=>CX_BO_TEMPORARY*

The TEXTID of an exception class is the message.

As per the book, create a subclass and create your own texts with your own
messages. This is a good thing. I do find it mildly annoying that you need
to create two exception classes for an object (for permanent and temporary
exceptions), but generally this isn't a biggie as the temp errors will be
few and most functionality will be in the 'real' error class.

You could even do something like a high level ZCX_BO_TEMP_MM for all
contract/PO/PReq temporary errors if you're allergic to too many classes,
although I do prefer a temp exception class for each business class that I
need one.

You can always add the 'real' exception class as an attribute to the temp
exception if you want to use shared functionality. Bring more OO thinking
into it and it all becomes a thing of beauty :-)

Have fun,
Mike


On Tue, June 19, 2012 7:54 am, Paul.Bakker at osr.qld.gov.au wrote:
>
> Hi,
>
> Following on from my previous post, I've now successfully implemented
> temporary OO exceptions, but I do not like the generic message reported in
> the workflow log:
>
>  	'Temporary exception triggered in business class XYZ'.
>
> Is there an easy way to pass the SY- message details to the exception
> object, so that the log shows instead:
>
> 	'Contract abc is locked by user PAULB'
>
> At the moment I have this (very) simple code:
>
>   if sy-subrc = 1.
> * stop now with a temporary locking error
>     RAISE EXCEPTION TYPE CX_BO_TEMPORARY
>        EXPORTING TEXTID = CX_BO_TEMPORARY=>CX_BO_TEMPORARY
>                CLASS_NAME = 'ZCL_MR_FORM_BUNDLE'.
>
>
> Surely I don't need to create my own exception class - this must be a
> common requirement ?
>
> thanks again,
> Paul Bakker
>
>
> *********************************************************************************************
> Only an individual or entity who is intended to be a recipient of this
> e-mail may access or use the information contained in this e-mail or any
> of its attachments.  Opinions contained in this e-mail or any of its
> attachments do not necessarily reflect the opinions of Queensland
> Treasury.
>
> The contents of this e-mail and any attachments are confidential and may
> be legally privileged and the subject of copyright.  If you have received
> this e-mail in error, please notify Queensland Treasury immediately and
> erase all copies of the e-mail and the attachments.  Queensland Treasury
> uses virus scanning software.  However, it is not liable for viruses
> present in this e-mail or in any attachment.
> ***************************************************************************************************
>
> _______________________________________________
> SAP-WUG mailing list
> SAP-WUG at mit.edu
> http://mailman.mit.edu/mailman/listinfo/sap-wug
>




More information about the SAP-WUG mailing list