Inicio del área de contenido

Este gráfico es explicado en el texto respectivo Locking a Cost Center (Example) Localizar documento en árbol de navegación

You want to prevent times being recorded for the receiver cost center 0000000777 for the employee with the EmployeeId 00004711. You want the system to issue an error message if the user records times for this cost center.

Este gráfico es explicado en el texto respectivo

If you want to add the customer-specific check described below to CATS notebook, you must implement the check with equal thoroughness in SAP R/3. To do so, use the General SAP Enhancements for the Cross-Application Time Sheet.

Proceed as follows (for technical details, see the source code below):

  1. Define a separate class, ZTimeSheetChecker. This class must implement the ITimeSheetChecker interface.
  2. Implement the checkRecord method. Use this method to define all customer-specific checks.
  3. Create an instance of the MessageContainer class.
  4. Check whether times have been recorded for the receiver cost center 0000000777 for the employee with the EmployeeId 00004711. If this is the case, use the AddMessage method to generate an appropriate message and to transfer it to the MessageContainer.

Java Source Code

package com.sap.mycats.customer.examples;

 

import com.sap.mycats.customer.businessLogic.*;

import com.sap.mycats.basics.tools.badi.IRecordReadOnly;

 

public class ZTimeSheetChecker

    implements ITimeSheetChecker

{

    private final static String ZMSGID = "ZZ";

    private final static String MSG_NO_WRONG_COST_CENTER = "001";

 

    private final static String FIELD_NAME_COST_CENTER = "RKOSTL";

    private final static String FIELD_NAME_EMPLOYEE_ID = "PERNR";

 

 

    public IMessageContainer checkRecord (String anOperation,

                 IRecordReadOnly aRecord,

                 ITimeSheetReader aTimeSheetReader) {

        IMessageContainer result

           = MessageContainerFactory.createIMessageContainer();

        try {

            result.addMessages(checkCostCenter(anOperation,

                               aRecord, aTimeSheetReader));

            // insert further checks here

        } catch (MessageNotDefinedException e) {

            e.printStackTrace();

            throw new Error(e.toString());

        }

        return result;

    }

 

 

    private IMessageContainer checkCostCenter (String anOperation,

                 IRecordReadOnly aRecord,

                   ITimeSheetReader aTimeSheetReader)

        throws MessageNotDefinedException {

        String costCenter =

           aRecord.getFieldAsString(FIELD_NAME_COST_CENTER);

        String employeeId =

            aRecord.getFieldAsString(FIELD_NAME_EMPLOYEE_ID);

        if (costCenter.equals("0000000777") &

              employeeId.equals("00004711")) {

            IMessageContainer result

           = MessageContainerFactory.createIMessageContainer();

            result.addMessage(ZMSGID, IMessageContainer.TYPE_ERROR,

                                      MSG_NO_WRONG_COST_CENTER);

             return result;

    }

        return null;

    }

}

 

 

Fin del área de contenido