Function module Z_ERROR_HANDLING
with parameters:
- Title - (string) appears as title in the inbox of administrators, please put identifyable data on this title, such as a purchase order number or a vendor number.
- Message - has 2 functions: this is a stucture like
BAPIRET1
which holds a field calledMESSAGE
(string). The contents of this field will be displayed in the "preview pane" of the message. This text should briefly describe the problem with potential action to solve it. Other fields of the Message parameter are message number and message application area, which should be filled in with a message that has a suitable longtext. This longtext is very important and should explain clearly what the problem is and what could be done to solve it. When the work item is executed, this longtext is displayed. Please note: the setup is for identifying the problem, not (automatically) fixing it! PO_NUMBER, PREQ_NUMBER, OUTL_AGR_NUMBER, GOODS_REC_MATNR
andGOODS_REC_YEAR
are all optional parameters that can be passed on. These parameters will be instantiated to their business object and placed on the work item as attachment. Please note: if e.g. a purchase order number is passed on and it doesn't exist, no attachment will be available. It's allowed to add more than one attachments to the worl item.
Please use this functionality carefully: if a batch program runs and encounters 5 or 6 problems, please call the above function module only once.
FUNCTION Z_ERROR_HANDLING. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" REFERENCE(TITLE) LIKE BAPIRET1-MESSAGE *" REFERENCE(MESSAGE) TYPE BAPIRET1 *" REFERENCE(PO_NUMBER) LIKE EKKO-EBELN OPTIONAL *" REFERENCE(PREQ_NUMBER) LIKE EBAN-BANFN OPTIONAL *" REFERENCE(OUTL_AGR_NUMBER) LIKE EKKO-EBELN OPTIONAL *" REFERENCE(GOODS_REC_MATNR) LIKE MKPF-MBLNR OPTIONAL *" REFERENCE(GOODS_REC_YEAR) LIKE MKPF-MJAHR OPTIONAL *" EXCEPTIONS *" CONFIG *"---------------------------------------------------------------------- *----------------------------------------------------------------------* * Function mod. - Z_ERROR_HANDLING * * Description - This function module must be called when an error * * occurs. * * * * Developer - Wim Maasdam * * Date - 27-05-2003 * * SAP version - 4.7 - 620 * *----------------------------------------------------------------------* * The program has the following steps: * * - Includes * * - Data Declaration * * - Authorization check * * - Check if message number is filled * * - Create the container entries * *----------------------------------------------------------------------* * Amendment History * * ----------------- * * Date Developer Ref Description * * ======== =========== ======== ====================================== * * dd-mm-yy sap userid DR num desc * * * *----------------------------------------------------------------------* * Includes INCLUDE <cntain>. * Data Declaration data: l_result_object type SWC_OBJECT, l_OBJTYPE LIKE SWETYPECOU-OBJTYPE value 'ZERRORS', l_OBJKEY LIKE SWEINSTCOU-OBJKEY value space, l_EVENT LIKE SWETYPECOU-EVENT value 'ZSTART', begin of l_increc, MBLNR like mkpf-MBLNR, MJAHR like mkpf-MJAHR, end of l_increc. * Authorization check. This check is not needed in this case. This * module is used in different parts of the code and does NOT need a * check. * Check if message number is filled IF MESSAGE-ID IS INITIAL OR MESSAGE-NUMBER IS INITIAL. RAISE CONFIG. ENDIF. * Check if Goods receipt values are correctly filled. if ( GOODS_REC_MATNR is initial and GOODS_REC_YEAR is not initial ) or ( GOODS_REC_MATNR is not initial and GOODS_REC_YEAR is initial ). RAISE CONFIG. endif. * Create the container entries swc_container container. swc_create_container container. * Title and error message swc_set_element container 'MESSAGE' MESSAGE. swc_set_element container 'TitleText' TITLE. * Purchase Order number if PO_NUMBER is not initial. SWC_CREATE_OBJECT l_result_object 'BUS2012' PO_NUMBER. swc_set_element container 'BUS2012' l_result_object. endif. * Outline agreement number if OUTL_AGR_NUMBER is not initial. SWC_CREATE_OBJECT l_result_object 'BUS2014' OUTL_AGR_NUMBER. swc_set_element container 'BUS2014' l_result_object. endif. * Goods Receipt if GOODS_REC_MATNR is not initial. l_increc-MBLNR = GOODS_REC_MATNR. l_increc-MJAHR = GOODS_REC_YEAR. SWC_CREATE_OBJECT l_result_object 'MKPF' l_increc. swc_set_element container 'MKPF' l_result_object. endif. * Purchase Requisition number if PREQ_NUMBER is not initial. SWC_CREATE_OBJECT l_result_object 'BUS2105' PREQ_NUMBER. swc_set_element container 'BUS2105' l_result_object. endif. * Create the event CALL FUNCTION 'SWE_EVENT_CREATE' EXPORTING OBJTYPE = l_OBJTYPE OBJKEY = l_OBJKEY EVENT = l_EVENT TABLES EVENT_CONTAINER = CONTAINER EXCEPTIONS OTHERS = 1. If sy-subrc eq 0. commit work. else. RAISE CONFIG. endif. ENDFUNCTION.