Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

user restriction for report data

Former Member
0 Likes
713

hii,

i want to put restriction on user to view data of other plant in my z report.

for example

user of plant 100 can view details of plant 100 only

if he enter plant 200 in report ..error msg pop up..or no data found.

Thanks

1 ACCEPTED SOLUTION
Read only

GauthamV
Active Contributor
0 Likes
664

You have to create an authorization object and use in your program

amd maintain authorization values in user profiles.


  TABLES : PA0001,pa0034.
   SELECT-OPTIONS:  S_WERKS FOR PA0001-WERKS , "Personnel Area
                   S_BTRTL FOR PA0001-BTRTL , "Personnel Subarea
                   S_PERSG FOR PA0001-PERSG , "Employee Group
                   S_PERSK FOR PA0001-PERSK . "Employee Subgroup
 SELECT-OPTIONS: S_FUNKT   FOR PA0034-FUNKT.
 AT SELECTION-SCREEN.
  DATA: h_werks LIKE t500p OCCURS 0 WITH HEADER LINE ,
        h_funkt LIKE t591a OCCURS 0 WITH HEADER LINE .
  REFRESH :h_werks[] , h_funkt .
  CLEAR :h_werks , h_funkt .
  SELECT * FROM t500p INTO TABLE h_werks WHERE persa IN s_werks .
  SELECT * FROM t591a INTO TABLE h_funkt WHERE infty = '0034' AND subty IN s_funkt.

  LOOP AT h_werks .
    LOOP AT h_funkt .
      AUTHORITY-CHECK OBJECT 'Z_HR_AUTH'
               ID 'PERSA' FIELD h_werks-persa
               ID 'FUNKT' FIELD h_funkt-subty.
      IF sy-subrc NE 0.
        MESSAGE e001(zhrrep) WITH h_werks-persa h_funkt-subty .
      ENDIF.
    ENDLOOP.
  ENDLOOP.

You have to create an authorization object and use in your program

amd maintain authorization values in user profiles.


  TABLES : PA0001,pa0034.
   SELECT-OPTIONS:  S_WERKS FOR PA0001-WERKS , "Personnel Area
                   S_BTRTL FOR PA0001-BTRTL , "Personnel Subarea
                   S_PERSG FOR PA0001-PERSG , "Employee Group
                   S_PERSK FOR PA0001-PERSK . "Employee Subgroup
 SELECT-OPTIONS: S_FUNKT   FOR PA0034-FUNKT.
 AT SELECTION-SCREEN.
  DATA: h_werks LIKE t500p OCCURS 0 WITH HEADER LINE ,
        h_funkt LIKE t591a OCCURS 0 WITH HEADER LINE .
  REFRESH :h_werks[] , h_funkt .
  CLEAR :h_werks , h_funkt .
  SELECT * FROM t500p INTO TABLE h_werks WHERE persa IN s_werks .
  SELECT * FROM t591a INTO TABLE h_funkt WHERE infty = '0034' AND subty IN s_funkt.

  LOOP AT h_werks .
    LOOP AT h_funkt .
      AUTHORITY-CHECK OBJECT 'Z_HR_AUTH'
               ID 'PERSA' FIELD h_werks-persa
               ID 'FUNKT' FIELD h_funkt-subty.
      IF sy-subrc NE 0.
        MESSAGE e001(zhrrep) WITH h_werks-persa h_funkt-subty .
      ENDIF.
    ENDLOOP.
  ENDLOOP.

5 REPLIES 5
Read only

Former Member
0 Likes
664

Create the authorization object and use them in ur program.

Read only

GauthamV
Active Contributor
0 Likes
665

You have to create an authorization object and use in your program

amd maintain authorization values in user profiles.


  TABLES : PA0001,pa0034.
   SELECT-OPTIONS:  S_WERKS FOR PA0001-WERKS , "Personnel Area
                   S_BTRTL FOR PA0001-BTRTL , "Personnel Subarea
                   S_PERSG FOR PA0001-PERSG , "Employee Group
                   S_PERSK FOR PA0001-PERSK . "Employee Subgroup
 SELECT-OPTIONS: S_FUNKT   FOR PA0034-FUNKT.
 AT SELECTION-SCREEN.
  DATA: h_werks LIKE t500p OCCURS 0 WITH HEADER LINE ,
        h_funkt LIKE t591a OCCURS 0 WITH HEADER LINE .
  REFRESH :h_werks[] , h_funkt .
  CLEAR :h_werks , h_funkt .
  SELECT * FROM t500p INTO TABLE h_werks WHERE persa IN s_werks .
  SELECT * FROM t591a INTO TABLE h_funkt WHERE infty = '0034' AND subty IN s_funkt.

  LOOP AT h_werks .
    LOOP AT h_funkt .
      AUTHORITY-CHECK OBJECT 'Z_HR_AUTH'
               ID 'PERSA' FIELD h_werks-persa
               ID 'FUNKT' FIELD h_funkt-subty.
      IF sy-subrc NE 0.
        MESSAGE e001(zhrrep) WITH h_werks-persa h_funkt-subty .
      ENDIF.
    ENDLOOP.
  ENDLOOP.

Read only

Former Member
0 Likes
664

HI,

After collecting all the desired data into final internal table.

use If condition and restrict use to view data.

e.g.

IF sy-uname = First user.

delete it_final where werks = '100'.

elseif sy-uname = Second_user.

delete it_final where werks = '200'.

endif.

Hope this will help you.

Regards,

Vijay

Read only

Former Member
0 Likes
664

/SPE/CONS_GET_PLANTS_USER

will this FM help?

Read only

Former Member
0 Likes
664

thank u ppl..

let me try..