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

Authorizations

Former Member
0 Likes
904

Hello Friends,

I am having an Z report and to which I need to provide authorizations Plant wise.

how can i do this as an ABAPER

regards

7 REPLIES 7
Read only

Former Member
0 Likes
878

You can call the authority check inside the program. it is preferred to call it in INITIALIZATION event.

Read only

Former Member
0 Likes
878

hi,

for authorization u had to code in your program .

just do copy and paste and try , it will work.

TYPES : BEGIN OF stype_buffer,

werks LIKE t001w-werks,

bukrs LIKE t001-bukrs,

subrc LIKE syst-subrc,

END OF stype_buffer,

stab_buffer TYPE STANDARD TABLE OF

stype_buffer

WITH DEFAULT KEY.

TYPES : BEGIN OF stype_organ,

werks LIKE t001w-werks,

bwkey LIKE t001w-bwkey,

name1 LIKE t001w-name1,

bukrs LIKE t001-bukrs,

waers LIKE t001-waers,

END OF stype_organ,

stab_organ TYPE STANDARD TABLE OF

stype_organ

WITH DEFAULT KEY.

DATA: g_t_organ TYPE stab_organ WITH HEADER LINE,

g_s_organ TYPE stype_organ.

AT SELECTION-SCREEN.

SELECT DISTINCT werks name1 bwkey

INTO CORRESPONDING FIELDS OF TABLE g_t_organ

FROM t001w

WHERE werks IN s_werks.

LOOP AT g_t_organ.

AUTHORITY-CHECK OBJECT 'M_MATE_WRK'

ID 'WERKS' FIELD g_t_organ-werks

ID 'ACTVT' FIELD '03'.

IF sy-subrc <> 0.

MESSAGE 'NO AUTHORIZATION' TYPE 'E'.

ENDIF.

ENDLOOP.

if it works do grant faourable points

priya.

Read only

Former Member
0 Likes
878

Hi,

You can use Authority Check for the necessary Authorizations.

Pls have a luk at the below sample code which might be useful.

Data: user TYPE sy-uname.

INITIALIZATION.

user = sy-uname.

*Invalidates any user other than OPTIMA-ADMN from executing the report.

DEFINE check_authority.

if user ne 'xxxxx'.

message 'You are not authorized to run this program' type 'W'.

stop.

endif.

END-OF-DEFINITION.

check_authority.

You may mention the respective user for xxxx for the necesary authorizations.

For this code except the user "XXXX" rest are not authorized to execute this report.

Pls reward if useful.

Thanks.

Read only

Former Member
0 Likes
878

Hi Sushmitha,

INITIALIZATION.

PERFORM initialize_plant.

AT SELECTION-SCREEN.

----


  • Validation

----


PERFORM authority_check.

(FORM authority_check.

IF pa_werks NE (your choice)

*Select plant as -


MESSAGE .

ENDIF.

  • Checking Whether the User has authorization for the Plant.

AUTHORITY-CHECK OBJECT 'Z' ID 'WERKS' FIELD pa_werks.

IF sy-subrc <> 0.

  • NO AUTHORIZATION FOR PLANT.

MESSAGE e

ENDIF.

ENDFORM. " authority_check)

Please check this code and use accordingly

Cheers

Mohinder Singh Chauhan

Read only

Former Member
0 Likes
878

Please find the below code.

data: user TYPE sy-uname.

INITIALIZATION.

user = sy-uname.

DEFINE check_authority.

if user ne 'ADMN'.

message 'You are not authorized to run this program' type 'W'.

stop.

endif.

END-OF-DEFINITION.

This may be of some use.

Reward if helpful.

Thanks,

Imran.

Read only

Former Member
0 Likes
878

Write this code in initilisation.

AUTHORITY-CHECK OBJECT 'Z_PP_PLANT'

ID 'WERKS' FIELD p_werks

ID 'ACTVT' FIELD '03'

ID 'TCD' FIELD w_tcode.

IF sy-subrc NE 0.

MESSAGE e014 WITH p_werks.

ENDIF.

check for the authority object z_pp_plant your orgnisation may have custome defined one.

Read only

Former Member
0 Likes
878

Hi,

if the authorization object and authorization id are created and authorization values are assigned to ur user role then only u can check the authorizations in ur program.

tcodes:

authorization object SU21.

authorization id SU20.

user roles maintainance PFCG.

as a developer u don't have access to all these tcodes

for more info please go through this link

http://help.sap.com/saphelp_nw70/helpdata/en/9f/dbacbe35c111d1829f0000e829fbfe/content.htm

rgds,

bharat.