cancel
Showing results for 
Search instead for 
Did you mean: 

Need help in writng User Exit

Former Member
0 Kudos

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.

Thanks,

Kris

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Gova,

Thanks for responding. I have created a Customer exit on Employee number(ZEMPNO), Technical name of the Customer Exit is ZEMPNUM.

You asked what is 'ZREG1133' for, this is the standard content i got when trying to enhance ZXRSRU01. I tried to make it as a comment but it is giving me an error saying there should be when followed by Case. So i made some modifications, can you please look into the code now.

When i am trying to execute the query i am getting the below error.

Error: Error for variable in customer enhancement ZEMPNUM

Diagnosis:

This internal error is a deliberate termination, since a program status has arisen, that is not allowed to occur.

The error has arisen for variable ZEMPNUM in the customer enhancement .

Procedure:

Please check your customer enhancement.

Procedure for System Administration

Notification Number BRAIN 649

Below is my code

&----


*& Include ZXRSRU01

&----


data : itab like /BIC/AZHRPE00100 occurs 0 with header line .

data : zuid like /BIC/AZHRPE00100-/bic/zempno.

data region type /BIC/OIZCDOTREG1.

break-point.

case I_VNAM.

WHEN 'ZEMPNUM'.

DATA: L_S_RANGE TYPE RSR_S_RANGESID.

DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.

IF I_STEP = 1. "before the popup

DATA username(20) type c.

username = sy-uname.

break-point.

select single /bic/zempno from /BIC/AZHRPE00100 INTO zuid where /bic/zuserid = username.

if sy-subrc = 0 .

select * from /bic/azhrpe00100 into table itab where /bic/zempno = zuid.

endif.

CLEAR L_S_RANGE.

L_S_RANGE-LOW = ZUID."low value, e.g.200001

L_S_RANGE-SIGN = 'I'.

L_S_RANGE-OPT = 'eq'.

APPEND L_S_RANGE TO E_T_RANGE.

EXIT.

ENDIF.

ENDCASE.

Former Member
0 Kudos

Kris,

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.

break-point.

case I_VNAM.

WHEN 'ZEMPNUM'.

IF I_STEP = 2. "After the popup

break-point.

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.

endif.

*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.

CLEAR L_S_RANGE.

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.

EXIT.

ENDLOOP.

ENDIF.

ENDCASE.

Answers (10)

Answers (10)

Former Member
0 Kudos

Gova,

Thank you for your help.

Kris

Former Member
0 Kudos

Gova,

Thank you so much, it worked out, but it is getting only employee specific data, i mean even the supervisor logs into it, it is searching him under employee and getting his record.

It is not getting all the records under him. Can you suggest me a solution for this.

Thank You,

Kris.

Former Member
0 Kudos

Kris,

So its not getting the employees for a supervisor.

Please check the Select statement that we have in the code that reads the master data. Put a break point there and debug it using the RSRT. Once it passed the select statement, the internal table shoule be filled with his subordinate values also... IF not, then fix the select statement.

Good Luck

Gova

Former Member
0 Kudos

Gova,

Below is the code, now it code is syntactically correct. But when i execute the report it is giving me an error : Error for variable in customer enhancement ZEMPNUM

Diagnosis

This internal error is a deliberate termination, since a program status has arisen, that is not allowed to occur.

The error has arisen for variable ZEMPNUM in the customer enhancement .

Procedure

Please check your customer enhancement.

Procedure for System Administration

Notification Number BRAIN 649

Below is the code.......

&----


*& 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.

data : temp_zempno like /BIC/AZHRPE00100-/bic/zempno.

*region type /BIC/OIZCDOTREG1,

data : itab_empno like standard table of temp_zempno.

*itab_empno like /BIC/AZHRPE00100-/bic/zempno.

break-point.

case I_VNAM.

WHEN 'ZEMPNUM'.

IF I_STEP = 2. "After the popup

break-point.

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.

endif.

*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.

CLEAR L_S_RANGE.

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.

EXIT.

ENDLOOP.

ENDIF.

ENDCASE.

Former Member
0 Kudos

Kris,

Can you run the query in transaction RSRT in 'debug' mode and step through the user exit code and check which part of the code is causing the error.

Former Member
0 Kudos

Gova,

I made some changes, chnages are below ....

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.

data : temp_zempno like /BIC/AZHRPE00100-/bic/zempno.

*region type /BIC/OIZCDOTREG1,

data : itab_empno like standard table of temp_zempno.

.

.

.

CLEAR L_S_RANGE.

loop at itab_empno into temp_zempno.

Now it is syntactically correct, but when i execute a report it is saying as : Error for variable in customer enhancement ZEMPNUM

Thank You,

Kris

Former Member
0 Kudos

Gova,

I tried that too, when i tried that the error is : The type "TEMP_ZEMPNO" is unknown.

Thanks,

Kris.

Former Member
0 Kudos

can you post the complete code please...

Former Member
0 Kudos

Gova,

One last thing, i tried my own ways, but still i couldnt fix the syntax. I am pasting a part of the code and this is the error message : Statement "ITAB_EMPNO" is not defined. Check your spelling. spelling.

&----


*& 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.

data : temp_zempno type /BIC/AZHRPE00100-/bic/zempno.

*region type /BIC/OIZCDOTREG1,

itab_empno type standard table of temp_zempno.

*itab_empno like /BIC/AZHRPE00100-/bic/zempno.

break-point.

Thank You,

Kris

Former Member
0 Kudos

change this line...

itab_empno type standard table of temp_zempno.

to this

data: itab_empno type standard table of temp_zempno.

Former Member
0 Kudos

Hi experts,

Can you please check the below code, when i am trying to run from Bex, the data is not getting filtered based on logon, i am getting all the information, irrespective of who logged into it.

&----


*& Include ZXRSRU01

&----


data : itab like /BIC/AZHRPE00100 occurs 0 with header line .

data : zuid like /BIC/AZHRPE00100-/bic/zempno.

data region type /BIC/OIZCDOTREG1.

break-point.

case I_VNAM.

when 'ZREG1133'.

DATA: L_S_RANGE TYPE RSR_S_RANGESID.

DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.

WHEN 'ZSPNUM'.

IF I_STEP = 1. "before the popup

DATA username(20) type c.

username = sy-uname.

break-point.

select single /bic/zempno from /BIC/AZHRPE00100 INTO zuid where /bic/zuserid = username.

if sy-subrc = 0 .

select * from /bic/azhrpe00100 into table itab where /bic/zspno = zuid.

*endselect.

endif.

*loop at itab

LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE

WHERE VNAM = 'ZEMPNO'.

CLEAR L_S_RANGE.

L_S_RANGE-LOW = itab-/bic/ZSPNO."low value, e.g.200001

*L_S_RANGE-LOW+4(3) = '001'.

*L_S_RANGE-HIGH = itab-/bic/ZSPNO. "high value = input

L_S_RANGE-SIGN = 'I'.

L_S_RANGE-OPT = 'eq'.

APPEND L_S_RANGE TO E_T_RANGE.

EXIT.

ENDLOOP.

ENDIF.

ENDCASE.

Former Member
0 Kudos

Kris,

What is the variable in question?

What is 'ZREG1133' and why do you have two variables for ZSPNUM and ZEMPNO. YOu only need ZEMPNO for employee. You do not need any variable for Supervisor. Also, to clear your earlier question whether it works also if employee logs in, YES, it'll work... If he is an employee there there wont be any data returned from the master data table.

You need to do this in I_STEP = 2. Please make these changes and post it again.

Also, can you please tell us why you have this?

LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE

WHERE VNAM = 'ZEMPNO'.

Also, once you select the data from the master data, you need to add himself to the list returned.

Good Luck

Gova

Former Member
0 Kudos

HI Gova Mabbu,

Thank You for responding and can you be more clear about the part we do from CMOD. In the descption you gave, it am assuming that it gets the data for only supervisor. what if the employee logs in and want to check his data only. will the logic work this one too.

Can you please, be more clear about the coding part what i should do and what steps i need to include. Apprecite your help if you cna do this. I need to complete this by today.

Thanks,

kris.

Former Member
0 Kudos

Kris,

Check some sample user exits from service.sap.com/bi

infoindex under exits.

-Doodle

Former Member
0 Kudos

Kris,

As I see it, your data is very sensitive. Although we can do the user exit variable to come up with the user list, there will still be a lot of loop holes. What if someone (those who have access to query dev)creates a query without the vaiable. A Better method to solve this would be to create authorizations. Just a thought.

That being said, For your user exit variable, You only need to create it using ZEMPNO. It should be defined as "MUltiple single values".

Use the following psuedocode to build your code.

When "Your Variable",

Get the userID who is currently logged in.

From the Employee Master data M table, get the Employee ID.

Get all the employee numbers who has this user as their Supervisor.

Now add all these employee values to the output...

Good Luck

Gova