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

Plant wise Authirization

Former Member
0 Likes
1,527

Dear All,

My client having 15 user licenses, each user belong to one particular plant (werks). Example: Coimbatore user belongs to 1000, Chennai user belongs to 1100, and Calcutta user belongs to 1200 u2026etc up to 15 users.

Here I developed one ALV report for territory wise sales report, my client requirement is they need to restrict the report plant viceu2026plant 1000 user want to see plant 1100 user report means it wont allow, Only I have to give authorization to see for 1000 user. I already declared plant in my selection screen .pls give me input to address this issue..

Thanks and regards

Murugesh

Dear All,

My client having 15 user licenses, each user belong to one particular plant (werks). Example: Coimbatore user belongs to 1000, Chennai user belongs to 1100, and Calcutta user belongs to 1200 u2026etc up to 15 users.

Here I developed one ALV report for territory wise sales report, my client requirement is they need to restrict the report plant viceu2026plant 1000 user want to see plant 1100 user report means it wont allow, Only I have to give authorization to see for 1000 user. I already declared plant in my selection screen .pls give me input to address this issue..

Thanks and regards

Murugesh

5 REPLIES 5
Read only

Former Member
0 Likes
1,007

Hi,

Validate the Plant value on Selection screen using At Selection-Screen event. For this you can fetch the current plant value then Compare the selection screen field value.

Otherwise check is there any authorized object has been created previously for validate the user belongning to any plant.

Read only

Former Member
0 Likes
1,007

Hi

Create a z-table with the names of authorized people and at the beginning of the report check for the existence of the user running that report through the sy-uname selection in that Z-table.

or you can look for any authorization object from plant.

Edited by: ankit harjai on Apr 28, 2009 2:18 PM

Read only

GauthamV
Active Contributor
0 Likes
1,007

You have to create an authorization object for the fields you required

and add the logic in your porgram.

Also the values for that authorization object has to be maintained in the

roles or profiles of user which will be done by basis people.



 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

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
1,007

Thanks Gowtham

Read only

Former Member
0 Likes
1,007

You can try by using authorization check on the PLANT(WERKs) field and also you can display an information message for which user has no authorization.

Try by using below code-

AT SELECTION-SCREEN.

IF NOT p_plant IS INITIAL.

REFRESH: it_werks,

it_werks1.

*Fetch data from master table of plant (T001W)

SELECT werks FROM t001w

INTO TABLE it_werks

WHERE werks = p_plant.

IF sy-subrc EQ 0.

LOOP AT it_werks INTO wa_werks.

*check authorization for plant

AUTHORITY-CHECK OBJECT 'M_MATE_WRK'

ID 'ACTVT' FIELD '03' "FOR DISPLAY THE DATA

ID 'WERKS' FIELD wa_werks-werks.

IF sy-subrc EQ 0.

*Plants with authorization

wa_rwerks1-sign = 'I'.

wa_rwerks1-option = 'EQ'.

wa_rwerks1-low = wa_werks-werks .

APPEND wa_rwerks1 TO r_werks1.

ELSE.

*Plants without authorization

APPEND wa_werks TO it_werks1.

ENDIF.

CLEAR wa_werks.

ENDLOOP.

*No plant is authorized

IF r_werks1[] IS INITIAL.

MESSAGE e011 WITH text-039.

*Display all the plant in an information message

*for which user has no authorization

ELSEIF it_werks1 IS NOT INITIAL.

LOOP AT it_werks1 INTO wa_werks1.

CONCATENATE wa_werks1-werks ',' gv_text INTO gv_text.

CLEAR wa_werks1.

ENDLOOP.

MESSAGE i011 WITH text-040 gv_text.

ENDIF.

ENDIF.

ENDIF.

This works for me.

thanks,

Khush