2007 Sep 03 11:25 AM
Dear Experts,
Please help me for the following authorization related query.
For a custom report,
1 . plant field is not obligatory in the selection screen .
2. when i execute the report it should fetch only the corresponding plants
information which i have authorization.
example :
i am authorized for plants 0001 and 0003.
totals plants are 0001, 0002, 0003, 0004,...0010.
when i execute output should display 0001 , 0003 plants information only.
case 2: person x is having only authorization for plant 0002, so when he execute he should get the information regarding plant 0002 only.
output for this scenorio is 0002.
Kindly help me on this issue.
Kind Regards,
Tom.
2007 Sep 03 11:51 AM
Hi,
This code might help you.
it_plant contains all the entered plants.
then
loop at it_plant.
AUTHORITY-CHECK OBJECT 'Zxxxx'
ID 'ACTVT' FIELD '03'
ID 'plant it_plant-plant.
if sy-subrc <> 0.
delete it_plant-plant.
endif.
endloop.
if it_plant is initial.
message e000. "u r not authorised to any plants
else.
select where plants those contained in it_plant.
hope u know to create an authorisation object in SU21
reward if helpful.
2007 Sep 03 11:34 AM
Hi,
1) Get all the plants depending on the selection criteria..
SELECT werks
FROM t001w
INTO TABLE t_werks
WHERE werks IN s_werks.
2) Check for which plants user is authorized..
LOOP AT t_werks.
AUTHORITY-CHECK OBJECT 'xxxx'
ID 'yyyy' FIELD t_werks-werks
ID 'ACTVT' FIELD '03'.
IF sy-subrc NE 0.
DELETE t_werks.
ENDIF.
ENDLOOP.
Define a range
RANGES : r_werks FOR t001w-werks.
LOOP AT t_werks.
r_werks-sign = 'I'.
r_werks-high = 'EQ'.
r_werks-low = t_werks-low.
APPEND r_werks.
ENDLOOP.
Use this range to fetch the data instead of the select option.
Thanks and Best Regards,
Vikas Bittera.
2007 Sep 03 11:34 AM
HI,
try this
first get the sy-uname and go to the corresponding table
where the
sy-uname and plants are associated
and get those fields
for eg you get
abc 0001 only one record
now you have to write
for all entries in table itab in your selection query
then it will fetch the records where the plant is in the previous table....
or else.
if he enters the plant in the selection screen
check whether he is having authorization by selecting the plant
from that table by passing the uname
if sy-subrc eq 0.
go ahead
else.
message error
endif
thanks & regards,
Venkatesh
2007 Sep 03 11:51 AM
Hi,
This code might help you.
it_plant contains all the entered plants.
then
loop at it_plant.
AUTHORITY-CHECK OBJECT 'Zxxxx'
ID 'ACTVT' FIELD '03'
ID 'plant it_plant-plant.
if sy-subrc <> 0.
delete it_plant-plant.
endif.
endloop.
if it_plant is initial.
message e000. "u r not authorised to any plants
else.
select where plants those contained in it_plant.
hope u know to create an authorisation object in SU21
reward if helpful.
2007 Sep 04 11:53 AM