2008 Nov 22 12:25 PM
My requirement is:
The user of a particular plant should be able to get the dispatch details for that Plant only.
Use the Authorization object .
The filed WERKS is not used anywhere else in the list expect for select options.
2008 Nov 22 3:43 PM
Hi Madhavi
If you are using this statement :
AUTHORITY-CHECK OBJECT object
ID name1 FIELD f1
ID name2 FIELD f2
...
ID namen FIELD fn.
That statement checks the user authorization in user masters record for that particuler field and activity.
REPORT demo_authorithy_check.
PARAMETERS pa_carr LIKE sflight-carrid.
DATA wa_flights LIKE demo_focc.
AT SELECTION-SCREEN.
AUTHORITY-CHECK OBJECT 'S_CARRID'
ID 'CARRID' FIELD pa_carr
ID 'ACTVT' FIELD '03'.
IF sy-subrc = 4.
MESSAGE e045(sabapdocu) WITH pa_carr.
ELSEIF sy-subrc <> 0.
MESSAGE e184(sabapdocu) WITH text-010.
ENDIF.
START-OF-SELECTION.
SELECT carrid connid fldate seatsmax seatsocc
FROM sflight
INTO CORRESPONDING FIELDS OF wa_flights
WHERE carrid = pa_carr.
WRITE: / wa_flights-carrid,
wa_flights-connid,
wa_flights-fldate,
wa_flights-seatsmax,
wa_flights-seatsocc.
ENDSELECT.
In this example, the system checks with the authorization object S_CARRID whether or not the user has a display authorization (03) for the airline entered on a selection screen. If this is not the case, or a different error occurs,
Regards
Neha
My requirement is:
The user of a particular plant should be able to get the dispatch details for that Plant only.
Use the Authorization object .
The filed WERKS is not used anywhere else in the list expect for select options.
2008 Nov 22 12:37 PM
Hi,
Authority Objects are always applied at the level of Table. List all the table from whom you are fetching the data and look into SU22, and go into your Functional Module like Purchase, Sales Etc.
Authority Objects Nomenclature is very simple.....every 2,3,4 & 5 alphabets of the Authority Object Name represents the Table with which they belongs and hence you can make sure that whether this Authority object is meaningful for you or not.
If WERKS is there in the Selection Screen, then Put the Relevant Authority Check in PAI of selection Screen only.
2008 Nov 22 12:48 PM
First find the correct authorization object related to WERKS (There are some like M_MATE_WRK, M_EINF_WRK, M_MRES_WWA and there may be some customer ones, ask functional or perform some where-used with the data element)
Then in the PAI of the screen or in an AT SELECTION-SCREEN AT block, perform a SELECT on the WERKS field, loading the WERKS selected by user from table T001W, then perform an AUTHORITY-CHECK on each record and remove the unauthorized WERKS from the table, issue a messages to indicate this to user.
AUTHORITY-CHECK OBJECT u2018M_EINF_WRKu2019
ID u2018WERKSu2019 FIELD <werks>
ID u2018ACTVTu2019 FIELD u201803u2032.In the following code use only the authorized WERKS or directly update the RANGE/SELECT-OPTIONS of WERKS with the authorized values.
Look at this thread where you will find a code sample to adapt.
Regards
2008 Nov 22 1:03 PM
Hi
*& Form sub_check_auth_iwerk *
&----
This form checks authorization for plant. *
-
FORM sub_check_auth_iwerk .
--Constant for t code, no tcode hence value = '' (all)
CONSTANTS: lc_tcd LIKE tstc-tcode VALUE '*'.
*--Table for all the plants in selection screen. This
table will be used for authority check.
DATA: BEGIN OF li_plant OCCURS 0,
iwerk LIKE t001w-werks,
END OF li_plant.
*--Select query to pick plant from table t001w
SELECT werks "Plant
INTO TABLE li_plant
FROM t001w
WHERE werks IN s_iwerk.
LOOP AT li_plant.
AUTHORITY-CHECK OBJECT 'I_SWERK'
ID 'TCD' FIELD lc_tcd
ID 'SWERK' FIELD li_plant-iwerk.
*--Check SUBRC
IF sy-subrc NE 0.
*--No Authorization for Plant
MESSAGE e016 WITH li_plant-iwerk.
ENDIF.
ENDLOOP. "loop at li_plant
ENDFORM. "sub_check_auth_iwerk
Try this link also:
http://help.sap.com/saphelp_47x200/helpdata/en/52/67167f439b11d1896f0000e8322d00/frameset.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/ef/4aba3b3bf00152e10000000a114084/frameset.htm
go through this link hope this would help you to give the idea about authorization object,
http://help.sap.com/saphelp_nw04s/helpdata/en/9f/dbaccb35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/9f/dbacbe35c111d1829f0000e829fbfe/content.htm
http://www.guidancetech.com/people/holland/sap/abap/
Regards
Neha
2008 Nov 22 3:36 PM
thankyou for all your inputs.
where can i mention that this Plant is Authorised only for a particular user?should i create the authorisation object like that?in which t-code can i create it?
even in Neha's code-i didn't find any user validation -
please help me,
Regards
2008 Nov 22 3:43 PM
Hi Madhavi
If you are using this statement :
AUTHORITY-CHECK OBJECT object
ID name1 FIELD f1
ID name2 FIELD f2
...
ID namen FIELD fn.
That statement checks the user authorization in user masters record for that particuler field and activity.
REPORT demo_authorithy_check.
PARAMETERS pa_carr LIKE sflight-carrid.
DATA wa_flights LIKE demo_focc.
AT SELECTION-SCREEN.
AUTHORITY-CHECK OBJECT 'S_CARRID'
ID 'CARRID' FIELD pa_carr
ID 'ACTVT' FIELD '03'.
IF sy-subrc = 4.
MESSAGE e045(sabapdocu) WITH pa_carr.
ELSEIF sy-subrc <> 0.
MESSAGE e184(sabapdocu) WITH text-010.
ENDIF.
START-OF-SELECTION.
SELECT carrid connid fldate seatsmax seatsocc
FROM sflight
INTO CORRESPONDING FIELDS OF wa_flights
WHERE carrid = pa_carr.
WRITE: / wa_flights-carrid,
wa_flights-connid,
wa_flights-fldate,
wa_flights-seatsmax,
wa_flights-seatsocc.
ENDSELECT.
In this example, the system checks with the authorization object S_CARRID whether or not the user has a display authorization (03) for the airline entered on a selection screen. If this is not the case, or a different error occurs,
Regards
Neha
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |