************************************************************************ * Author: Manuel Gallardo * * Date: February, 2007 * * Description: * Sample ABAP code for CATS user-exits CATS0002, CATS0003, CATS0004, * CATS0006, CATS0009 and CATS0010. Please note that the code for * these user exits is only intended as a very simple example of how * the user exit works. ************************************************************************ ************************************************************************ ** CATS0002 - Supplement Recorded Data ************************************************************************ *&---------------------------------------------------------------------* *& Include ZXCATU02 *&---------------------------------------------------------------------* *" User exit parameters: *" IMPORTING *" VALUE(SAP_TCATS) LIKE TCATS STRUCTURE TCATS OPTIONAL *" TABLES *" ENRICH_TABLE STRUCTURE CATS_COMM *&---------------------------------------------------------------------* LOOP AT ENRICH_TABLE. IF ENRICH_TABLE-RAUFNR IS NOT INITIAL AND ENRICH_TABLE-VORNR IS INITIAL. ENRICH_TABLE-VORNR = '0010'. MODIFY ENRICH_TABLE. ENDIF. ENDLOOP. ************************************************************************ ** CATS0003 - Validate Recorded Data ************************************************************************ *&---------------------------------------------------------------------* *& Include ZXCATU03 *&---------------------------------------------------------------------* *" User exit parameters: *" IMPORTING *" VALUE(FIELDS) LIKE CATS_COMM STRUCTURE CATS_COMM *" VALUE(SAP_TCATS) LIKE TCATS STRUCTURE TCATS OPTIONAL *" VALUE(OLD_DATA) TYPE BOOLEAN OPTIONAL *" TABLES *" I_MESSAGES STRUCTURE CATS_MESG *&---------------------------------------------------------------------* REFRESH I_MESSAGES. IF FIELDS-VORNR = '0030'. I_MESSAGES-MSGTY = 'E'. I_MESSAGES-MSGID = 'PG'. I_MESSAGES-MSGNO = '016'. I_MESSAGES-MSGV1 = 'The message for your custom check'. I_MESSAGES-MSGV2 = 'will appear here'. APPEND I_MESSAGES. ENDIF. ************************************************************************ ** CATS0004 - Deactivate Functions in the user interface ************************************************************************ *&---------------------------------------------------------------------* *& Include ZXCATU04 *&---------------------------------------------------------------------* *" User exit parameters: *" IMPORTING *" VALUE(DYNNR) LIKE SY-DYNNR *" VALUE(TCATS) LIKE TCATS STRUCTURE TCATS *" VALUE(MODE) LIKE TC10-TRTYP *" VALUE(PERNO) LIKE CATSDB-PERNR OPTIONAL *" TABLES *" T_CUAFC STRUCTURE CUAFCODE *&---------------------------------------------------------------------* t_cuafc-fcode = 'TRAV'. APPEND t_cuafc. "Travel Expenses t_cuafc-fcode = 'WITH'. APPEND t_cuafc. "Material Withdrawal t_cuafc-fcode = 'FREE'. APPEND t_cuafc. "Release view t_cuafc-fcode = 'STAT'. APPEND t_cuafc. "Variable view *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -* * The following functions only need to be hidden if user exit * CATS0004 has been activated. Here you can hide additional * functions you do not need *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -* * t_cuafc-fcode = '+CU2'. APPEND t_cuafc."Customer Function +CU2 t_cuafc-fcode = '+CU3'. APPEND t_cuafc. "Customer Function +CU3 t_cuafc-fcode = '+CU4'. APPEND t_cuafc. "Customer Function +CU4 t_cuafc-fcode = '+CU5'. APPEND t_cuafc. "Customer Function +CU5 t_cuafc-fcode = '+CU6'. APPEND t_cuafc. "Customer Function +CU6 t_cuafc-fcode = '+CU7'. APPEND t_cuafc. "Customer Function +CU7 ************************************************************************ ** CATS0006 - Validate entire time sheet ************************************************************************ *&---------------------------------------------------------------------* *& Include ZXCATU05 *&---------------------------------------------------------------------* *" User exit parameters: *" IMPORTING *" VALUE(DATEFROM) LIKE CATSFIELDS-DATEFROM *" VALUE(DATETO) LIKE CATSFIELDS-DATETO *" VALUE(SAP_TCATS) LIKE TCATS STRUCTURE TCATS OPTIONAL *" TABLES *" CHECK_TABLE STRUCTURE CATS_COMM *" I_MESSAGES STRUCTURE CATS_MESG *&---------------------------------------------------------------------* * Do not allow Time codes 'OT' (Overtime) and 'ABS' Absence to be * entered on the same date *&---------------------------------------------------------------------* LOOP AT check_table WHERE workdate BETWEEN datefrom AND dateto. IF check_table-awart EQ 'OT'. "Overtime LOOP AT check_table WHERE pernr EQ check_table-pernr AND workdate EQ check_table-workdate AND awart EQ 'ABS'. "Absence EXIT. ENDLOOP. IF sy-subrc NE 0. CLEAR i_messages. i_messages-msgty = 'E'. i_messages-msgid = 'PG'. i_messages-msgno = '016'. i_messages-pernr = check_table-pernr. i_messages-catsdate = check_table-workdate. APPEND i_messages. ENDIF. ENDIF. ENDLOOP. ************************************************************************ ** CATS0009 - Customer-Specific Text Fields in Data Entry Screen ************************************************************************ *&---------------------------------------------------------------------* *& Include ZXCATU09 *&---------------------------------------------------------------------* *" User exit parameters: *" IMPORTING *" VALUE(TCATS_IMP) LIKE TCATS STRUCTURE TCATS *" VALUE(CATSD_IMP) LIKE CATSD_EXT STRUCTURE CATSD_EXT *" VALUE(DISPTEXT1_IMP) LIKE CATSFIELDS-DISPTEXT1 *" VALUE(DISPTEXT2_IMP) LIKE CATSFIELDS-DISPTEXT2 *" EXPORTING *" VALUE(DISPTEXT1_EXP) LIKE CATSFIELDS-DISPTEXT1 *" VALUE(DISPTEXT2_EXP) LIKE CATSFIELDS-DISPTEXT2 *&---------------------------------------------------------------------* * See the code for subroutine GET_NETWORK_TEXT at the bottom * of this document *&---------------------------------------------------------------------* IF CATSD_IMP-RNPLNR NE SPACE. PERFORM GET_NETWORK_TEXT USING CATSD_IMP-RNPLNR “Network number DISPTEXT_EXP. “Text ENDIF. ************************************************************************ ** CATS0010 - Customer-Specific Text Fields in Worklist ************************************************************************ *&---------------------------------------------------------------------* *& Include ZXCATU10 *&---------------------------------------------------------------------* *" User exit parameters: *" IMPORTING *" VALUE(TCATS_IMP) LIKE TCATS STRUCTURE TCATS *" VALUE(CATSW_IMP) LIKE CATSW STRUCTURE CATSW *" VALUE(DISPTEXTW1_IMP) LIKE CATSFIELDS-DISPTEXTW1 *" VALUE(DISPTEXTW2_IMP) LIKE CATSFIELDS-DISPTEXTW2 *" EXPORTING *" VALUE(DISPTEXTW1_EXP) LIKE CATSFIELDS-DISPTEXTW1 *" VALUE(DISPTEXTW2_EXP) LIKE CATSFIELDS-DISPTEXTW2 *&---------------------------------------------------------------------* * See the code for subroutine GET_NETWORK_TEXT at the bottom * of this document *&---------------------------------------------------------------------* IF CATSW_IMP-RNPLNR NE SPACE. PERFORM GET_NETWORK_TEXT USING CATSW_IMP-RNPLNR “Network number DISPTEXTW1_EXP. “Description ENDIF. ************************************************************************ ** Data declarations and code for subroutine GET_NETWORK_TEXT ************************************************************************ *----------------------------------------------------------------------* * INCLUDE ZXCATTOP * *----------------------------------------------------------------------* * Data fields/strings data: int_caufv like caufv. * Internal tables data: begin of temp_aufnr occurs 0, aufnr like caufv-aufnr, ktext like caufv-ktext, end of temp_aufnr. *----------------------------------------------------------------------* * INCLUDE ZXCATF01 * *----------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form GET_NETWORK_TEXT *&---------------------------------------------------------------------* * Retrieve the network description *----------------------------------------------------------------------* FORM GET_NETWORK_TEXT USING network text. LOOP AT temp_aufnr WHERE aufnr EQ network. exit. ENDLOOP. IF sy-subrc EQ 0. text = temp_aufnr-ktext. EXIT. ELSE. CALL FUNCTION 'CO_DB_HEADER_READ' EXPORTING aufnr = network IMPORTING caufvwa = int_caufv EXCEPTIONS not_found = 1 OTHERS = 2. IF sy-subrc = 0. text = int_caufv-ktext. ELSE. text = '** Network description not found **'. ENDIF. temp_aufnr-aufnr = network. temp_aufnr-ktext = text. APPEND temp_aufnr. ENDIF. "Is description already in buffer? ENDFORM. " GET_NETWORK_TEXT