Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

issues about using T100_MSG in Exception Class

qingda_niu
Explorer
0 Kudos

I find that if i raise an exception and the importing-parameter 'T100_MSG' is used, the messages which in 'T100_MSG' will not be got by method exceptionClass->get_text( ).

I will get the message ‘Exception CX_SWF_EVT_INVALID_OBJTYPE occurred (program: ZCL_DEMO======================CP, include: ZCL_DEMO======================CM004, line: 25).’

after i run the report.

But what i want to get is 'Invalid Object Type ZCL_WF'.

I debugged the SAP Original Standard Program, i found that in method

CL_MESSAGE->CREATE_FOR_EXCEPTION (Line 43)  the exporting parameter subst_table does not contain the T100_MSG informations. And i debugged into method cl_instance_descriptoin->get_attribute_values, at line 16 it only returned the values of those attributes whose type_kind is one of 'NDPTXCFIsbwgy', but the type_kind of T100_MSG is U. So ...

Is it a bug or there something wrong with my own code?!


My Environment is ECC6.0

The following is my code:

REPORT  ZDEMO_12.

data: lo_demo   type ref to zcl_demo,
     lo_cx_wf 
type ref to cx_swf_evt_exception,
     lv_text  
type string.

start-of-selection.

create object lo_demo.

try.
  
call method lo_demo->end_workflow.
catch cx_swf_evt_exception into lo_cx_wf.
   lv_text
= lo_cx_wf->get_text( ).
  
write lv_text.
endtry.

method END_WORKFLOW.

TRY.
CALL METHOD CL_SWF_EVT_EVENT=>RAISE
  
EXPORTING
     IM_OBJCATEG       
= 'CL'
     IM_OBJTYPE        
= 'ZCL_WF'       " This object type does not exist
     IM_EVENT          
= 'JUST_A_EVENT' " This event does not exist
     IM_OBJKEY         
= '1110'
*       IM_EVENT_CONTAINER =
.
CATCH cx_swf_evt_invalid_objtype.
**-- using t100 msg
   ls_t100
-msgid = 'SWF_CST'.
   ls_t100
-msgno = '006'.
   ls_t100
-msgty = 'E'.
   ls_t100
-msgv1 = 'Invalid Object Type'.
   ls_t100
-msgv2 = 'ZCL_WF'.
*      ls_t100-msgv3 =
*      ls_t100-msgv4 =
  
raise exception type cx_swf_evt_invalid_objtype
    
exporting
       t100_msg
= ls_t100.

  ENDTRY.

endmethod.

Best Regards,

qingda.

1 ACCEPTED SOLUTION

alex_campbell
Contributor
0 Kudos

I believe you misunderstand the purpose of the GET_TEXT method of an exception class.

The text returned by GET_TEXT is defined statically in the exception class itself, on the 'Texts' tab in SE24. It is not specified at runtime. These are intended to be developer-facing messages that are tecnical in nature (as they are displayed during a short-dump).

The message in attribute T100_MSG is intended to be application-specific. This method can be displayed to the user, or stored in a log, but it's up to each application to do that explicitly. If you want to use this message, you must write logic to raise it yourself.

So instead of calling:

lo_cx_wf->get_text( )

you should be calling:

ls_t100 = lo_cx_wf->t100_msg.

MESSAGE ID ls_t100-msgid TYPE ls_t100-msgty NUMBER ls_t100-msgno

      WITH ls_t100-msgv1 ls_t100-msgv2 ls_t100-msgv3 ls_t100-msgv4

      INTO lv_text.

2 REPLIES 2

alex_campbell
Contributor
0 Kudos

I believe you misunderstand the purpose of the GET_TEXT method of an exception class.

The text returned by GET_TEXT is defined statically in the exception class itself, on the 'Texts' tab in SE24. It is not specified at runtime. These are intended to be developer-facing messages that are tecnical in nature (as they are displayed during a short-dump).

The message in attribute T100_MSG is intended to be application-specific. This method can be displayed to the user, or stored in a log, but it's up to each application to do that explicitly. If you want to use this message, you must write logic to raise it yourself.

So instead of calling:

lo_cx_wf->get_text( )

you should be calling:

ls_t100 = lo_cx_wf->t100_msg.

MESSAGE ID ls_t100-msgid TYPE ls_t100-msgty NUMBER ls_t100-msgno

      WITH ls_t100-msgv1 ls_t100-msgv2 ls_t100-msgv3 ls_t100-msgv4

      INTO lv_text.

0 Kudos

Thank you very much, Campbell.

yeah, i misunderstood the method 'exceptionClass->get_text', i thought it also can return the message in T100_MSG.

I get the T100_MSG by using the attribute T100_MS of exceptionClass like you said.

Best Regards

qingda