Need help in writng User Exit
Hello Experts i have the below fields in my report. All these fields are not authorization relavant.( I mean while creating the Infoobjects, we didnt check the authorization relavant tab)
1. EmployeeNo (Zempno)
2. Suprvisorno (zspno)
3. Employee First Name (Zempfnm)
4. Employee Last Name (Zempltnm)
5. Employee Userid (Zempuid)
6. Supervisor Name (Zspnm)
7. Courses taken (Zcrst)
8. Region (Zregion)
Now i need to restrict my data based on who logs into the application. Lets say if the employee logs in he has to get his relavant data and if the supervisor logs in he has to get all the employees data under him.
what I know is, I need to create a Customer exit variable on Zempno( if not correct me) is this the only thing i need to create the customer exit or there any other variables.
Can some one tell me the ABAP code for this, to write in CMOD.
Gova Mabbu replied
here is the modified code. DO NOT DELETE YOUR CODE. INSTEAD COMMENT EERYTHING and then use this code... there can be syntax errors in it or errors in select statements, but the logic will work. Fix any errors and test it.
*& Include ZXRSRU01
DATA: L_S_RANGE TYPE RSR_S_RANGESID,
LOC_VAR_RANGE LIKE RRRANGEEXIT. " This is Global
data : itab like /BIC/AZHRPE00100 occurs 0 with header line,
temp_zempno type /BIC/AZHRPE00100-/bic/zempno,
region type /BIC/OIZCDOTREG1,
itab_empno type standard table of temp_zempno.
IF I_STEP = 2. "After the popup
select single /bic/zempno from /BIC/AZHRPE00100 INTO temp_zempno
where /bic/zuserid = sy-uname.
Check if he is the supervisor for any other employees
add them to the internal table
Check the syntax below.
if sy-subrc = 0 .
select /bic/zempno from /bic/azhrpe00100
into table itab_empno
where /bic/zspnm = temp_zempno.
*Add Own Employee number to the internal table
*Check the syntax below
Append temp_zempno to itab_empno.
*By now, all the employee numbers are added
to the internal tabe
*now loop at itab_empno and return all the values.
loop at itab_empno into temp_zempno
L_S_RANGE-LOW = temp_zempno.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE.