Applies to: SAP BI 7.0 and above. For more information, visit the Business Intelligence Homepage. Summary It is a common reporting requirement to display duplicate entries based on a characteristic. This document gives an alternative way to achieve this requirement by use of a customer exit variable. Author: Rahul Rajagopalan Nair Company: Infosys Technologies Ltd Created on: 09 Feb 2010 Author Bio Rahul Rajagopalan Nair has been working for Infosys technologies limited for past 2.2 years and has experience in SAP BI 7.0 implementations. 2010 SAP AG 1
Table of Contents Scenario... 3 Employee Master Data... 3 STEP 1: Create Customer Exit Variable... 5 STEP 2: ABAP Code for Variable.... 6 Before you start... 6 STEP 3: Global Restriction... 8 Related Content... 9 Disclaimer and Liability Notice... 10 2010 SAP AG 2
Scenario Every employee in an organization has a National Insurance Number for identification. It is mandatory for an organization to maintain a record of this information for all its employees. It is a serious offence if two employees in an organization have the same National Insurance Number. The task of the BW reporting team is to generate a report that identifies the employees that have duplicate NI Numbers. Employee Master Data The report has to be generated on the Employee Master Data. The employee master data contains various details of the employee Name, Age, Date of Joining, Job and Location etc. The National Insurance Number is one of the master data navigational attributes. 2010 SAP AG 3
The below query is used to report the employees along with their NIN details. Query: Report: Duplicates Duplicates It can be observed that the report has two sets of duplicate NI Numbers, DS345677F and TR234567Y. 2010 SAP AG 4
To create a report that displays duplicates, the following steps need to be carried out: Create Customer Exit Variable ABAP Code for Variable. Global Restriction STEP 1: Create Customer Exit Variable Create a variable of type Customer exit on NI Number. Description Technical Name Customer Exit The variable must be of type Multiple Single Values and should not be ready for user input. Multiple Single Values Optional Not Ready for Input 2010 SAP AG 5
STEP 2: ABAP Code for Variable. Before you start Ensure you have ABAP development rights Identify the Project/Enhancement Component used for Customer Exit Variables The below code is used to populate the Customer exit variable built on characteristic NI Number. "Structure TYPES : BEGIN OF TY_EMPLOYEE, /BIC/ION_EMPL TYPE /BIC/PION_EMPL-/BIC/ION_EMPL, /BIC/ION_NIN TYPE /BIC/PION_EMPL-/BIC/ION_NIN, END OF TY_EMPLOYEE. DATA : "Internal Table IT_EMPLOYEE TYPE STANDARD TABLE OF TY_EMPLOYEE. DATA : "Work Area WA_EMPLOYEE TYPE TY_EMPLOYEE. DATA : "Previous NI Number LV_PR_NI TYPE /BIC/PION_EMPL-/BIC/ION_NIN, "Current NI Number LV_CR_NI TYPE /BIC/PION_EMPL-/BIC/ION_NIN. CASE I_VNAM. WHEN 'ZDUP_NIN'. "Variable Name CASE I_STEP. WHEN 1. "Pre Processing "Read Master Data Table "Select all valid NI Numbers SELECT /BIC/ION_EMPL /BIC/ION_NIN FROM /BIC/PION_EMPL INTO TABLE IT_EMPLOYEE WHERE /BIC/ION_NIN NE '' AND OBJVERS EQ 'A'. "Sort by Internal table by NI Number SORT IT_EMPLOYEE BY /BIC/ION_NIN ASCENDING "Important Step /BIC/ION_EMPL ASCENDING. "Clear Variables CLEAR LV_PR_NI. "Previous NI Number CLEAR LV_CR_NI. "Current NI Number LOOP AT IT_EMPLOYEE INTO WA_EMPLOYEE. "Store the current NI Number LV_CR_NI = WA_EMPLOYEE-/BIC/ION_NIN. "Check if the Current and previous NI IF LV_CR_NI EQ LV_PR_NI. "Set the filter values L_S_RANGE-SIGN = 'I'. L_S_RANGE-OPT = 'EQ'. L_S_RANGE-LOW = LV_CR_NI. APPEND L_S_RANGE TO E_T_RANGE. ENDIF. 2010 SAP AG 6
"Store the current NI Number as previous value LV_PR_NI = WA_EMPLOYEE-/BIC/ION_NIN. ENDLOOP. ENDCASE. ENDCASE. 2010 SAP AG 7
STEP 3: Global Restriction Include the Customer Exit Variable in the query definition as shown below: Query Structure: Output: Duplicates Only 2010 SAP AG 8
Related Content Customer Exit Variables Alternative method to Report Duplicate Entries Reporting Duplicate Records For more information, visit the Business Intelligence homepage. 2010 SAP AG 9
Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document. 2010 SAP AG 10