on 10-13-2014 2:00 PM
Hi all,
I would like to handle exceptions thrown in CRM_ORDER_MAINTAIN Function Module. My requirement is changing the system status . Whenever I change status from one state say 'A' to another say 'B' then based on some conditions , CRM_ORDER_STATUS Badi has to raise exceptions. I am doing it using the program. in debugging, I am able to trigger the Badi( from CRM_ORDER_MAINTAIN Function Module in debugging), which is throwing an exception, which is fine. But while the control returns to CRM_ORDER_MAINTAIN Function Module sy-subrc is not equal to zero and also nothing is there in importing parameter( exceptions table).
I am correctly passing values /parameters to IT_STATUS(exporting ) and CT_INPUT_FIELDS( changing ) to CRM_ORDER_MAINTAIN Function Module. I heard that we have to pass reference handle parameter, which I am not sure where and how to pass. I tried to pass 100 to ref_handle parameter in ct_input_fields but its not working.
My final requirement is to display some message after catching the exception thrown in BADI.
Your valuable help is highly appreciated.
Thanks in advance.
Here's the steps to read exceptions/error messages.
After calling function module “CRM_ORDER_MAINTAIN” we first need to determine the currently existing log handles. Function module “CRM_MESSAGES_GET_LOG_HANDLES” can be used to read these log handles.
DATA:
lt_log_handle TYPE bal_t_logh.
* Get Log Handle(s)
CALL FUNCTION 'CRM_MESSAGES_GET_LOG_HANDLES'
IMPORTING
et_log_handle = lt_log_handle.
Step 2 : Get messages and exceptions
Once we have determined the log handles, we can search for messages and exceptions within these log handles, using function module “CRM_MESSAGES_GET_EXCEPTIONS”.
The code below reads the exceptions for the log handles, determined in step 1.
DATA:
lt_exception TYPE crmt_exception_t.
FIELD-SYMBOLS:
<lfs_log_handle> TYPE balloghndl.
* Get Exception(s)
LOOP AT lt_log_handle ASSIGNING <lfs_log_handle>.
CALL FUNCTION 'CRM_MESSAGES_GET_EXCEPTIONS'
EXPORTING
iv_log_handle = <lfs_log_handle>
iv_from_regmsg = abap_true
IMPORTING
et_exception = lt_exception
EXCEPTIONS
parameter_error = 1
not_found = 2
OTHERS = 3.
ENDLOOP.
Step 3 : Get message
Within step 2 we determined the exception messages within a log handle. Once we have the exceptions, we can read the corresponding messages using function module “CRM_MESSAGES_GET_MSG_INFO”. The code below processes all exceptions, determined in step 2.
DATA:
ls_msg TYPE bal_s_msg.
FIELD-SYMBOLS:
<lfs_exception> TYPE crmt_exception.
* Get Exception Message(s)
LOOP AT lt_exception ASSIGNING <lfs_exception>.
CLEAR ls_msg.
CALL FUNCTION 'CRM_MESSAGES_GET_MSG_INFO'
EXPORTING
is_msg_handle = <lfs_exception>-msg_handle
IMPORTING
es_msg = ls_msg
EXCEPTIONS
not_found = 1
wrong_context_structure = 2
data_error = 3
OTHERS = 4.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.