01-04-2014 10:37 AM
Hi Experts,
I'm trying to trigger a error message. I have debugged the code and ofcourse the respective message class is called with type of error.
But the error message is not triggering. Am I missing some thing. Please help me.
FUNCTION ZFM_ZFE_0057_REQ4_RK.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(DATEFROM) TYPE CATSFIELDS-DATEFROM
*" REFERENCE(DATETO) TYPE CATSFIELDS-DATETO
*" TABLES
*" CHECK_TABLE STRUCTURE CATS_COMM
*" I_MESSAGES STRUCTURE CATS_MESG
DATA: lt_CHECK_TABLE TYPE TABLE OF CATS_COMM ,
lw_CHECK_TABLE type cats_comm,
lt_msg TYPE STANDARD TABLE OF CATS_MESG,
lw_msg TYPE CATS_MESG,
lt_ztable TYPE STANDARD TABLE OF ZTABLE_RK,
lw_ztable TYPE ZTABLE_RK,
lv_land1 TYPE land1,
lv_max_hr_day TYPE catshours.
CONSTANTS: lv_msgid TYPE MSGID value 'ZCHECK_MSG_RK',
lv_msgno TYPE msgno VALUE '005',
lv_msgtye TYPE MSGTY VALUE 'E'.
CLEAR: lv_land1,
lv_max_hr_day.
LOOP AT CHECK_TABLE INTO lw_CHECK_TABLE.
SELECT SINGLE land1
INTO lv_land1
FROM T001
WHERE bukrs = 'DE10' . "lw_CHECK_TABLE-bukrs
* IF sy-subrc = 0.
SELECT SINGLE MAX_HR_DAY
INTO lv_max_hr_day
FROM ZTABLE_RK
WHERE LAND1 = lv_land1. " land1 = lv_land1.
IF sy-subrc = 0.
IF lw_CHECK_TABLE-catshours gt lv_max_hr_day.
lw_msg-MSGID = lv_msgid.
lw_msg-MSGNO = lv_msgno.
lw_msg-MSGTY = lv_msgtyE.
lw_msg-MSGV1 = lv_max_hr_day.
lw_msg-MSGV2 = lw_CHECK_TABLE-catshours.
APPEND lw_msg to lt_msg.
ENDIF. "End of catshours_day check
ENDIF. "End of ztable
ENDIF. "End of T001
ENDLOOP. "End of lw_CHECK_TABLE
ENDFUNCTION.
01-04-2014 11:53 AM
Just replace your (local) lt_msg with interface parameter I_MESSAGES.
That was it.
Regards
Clemens
01-04-2014 10:43 AM
Hi dilip,
Your messages are stored in internal table it_msg.
You can display message using function module.
Arivazhagan S
01-04-2014 10:56 AM
Hi Arivazhagan,
Am sorry, I didn't get your point.
Right, as of now my messages are in lt_msg. But how can I display it?
Thanks,
Dilip.
01-04-2014 10:59 AM
01-04-2014 11:15 AM
Hi Dilip,
Yes, You are storing the messages in the it_msg, But where you want to display this messages and how you want to display?
Just the BAPI will return the error messages and it wont display any where! Can You clear your requirement or issue?
01-04-2014 11:22 AM
Hi Kiran,
I'm using UserExit - CATS0006.
If I call the message as " MESSAGE e005(ZCHECK_MSG_RK) WITH lv_max_hr_day lw_CHECK_TABLE-CATSHOURS lw_CHECK_TABLE-WORKDATE.", error message is displaying in CATS transaction.
But if I follows the above said logic, am not getting the errror message in CATS transaction. But anyways my error message should be of declared message structure.
01-04-2014 11:10 AM
Hi Dilip,
as you have got your messages in it_msg,
so you use its work area as you have declared in lw_msg
to show error messages. You can declare a variable of type string
and use LOOP AT it_msg INTO lw_msg, and populate the error messages
in that variable.
Then you show the output as that variable, containing error messages.
01-04-2014 11:24 AM
Hi Sanjeev,
I have already got my lw_msg values and appended it to lt_msg. Now the problem is, I don't know how to display the message.
01-04-2014 11:31 AM
Ok,
Dilip messages are displayed as shown below
MESSAGE '&value where messages have&' TYPE 'I'.
If you have any predefined Messages, then you can use
MESSAGE 'Your Messages' TYPE 'I'.
You can use type 'E', type 'W' etc also there.
01-04-2014 11:35 AM
If you wants to define different messages then , you can create a message class in SE91.
And can use it after assigning different three digit no. in it,
Then you can use it as
MESSAGE 'A001' TYPE 'I'.
where A will be your message class name.
01-04-2014 11:58 AM
Hi,
You need append all the messages to the internal table " I_MESSAGES" which is specified as table in the function module.
Check the below code which I have used for CATS0006 user exit.
IF wa_pdpsp-ftkla NE '3'.
ls_cats_mesg-msgid = 'ZHR_XSS'.
ls_cats_mesg-msgty = 'E'.
ls_cats_mesg-msgno = '035'.
ls_cats_mesg-pernr = ls_check_table-pernr.
ls_cats_mesg-catsdate = ls_check_table-workdate.
APPEND ls_cats_mesg TO i_messages.
ENDIF.
Regards,
Jyothi
01-04-2014 11:53 AM
Just replace your (local) lt_msg with interface parameter I_MESSAGES.
That was it.
Regards
Clemens
01-04-2014 12:06 PM
01-04-2014 12:09 PM
hi,
Create exceptions in the FM like E1,E2,E3.... (Raising exceptions inside FM)
add this code where the error want to throw...
MESSAGE 'MINIMUM HALF/FULL DAY IS REQUIRED' TYPE 'E' RAISING E1.
or
message 'Your Work Area ' type 'E' raising E2.
Hope it solve ur problem...
Rgds,
Vijay SR