10-03-2007 9:19 AM
Check that the plant entered on the selection screen is valid and that the user has the appropriate authorisation to view records for that plant. First select an entry from the Plants/Branches table (T001W).
T001W-WERKS (Plant) = Plant (selection screen)
Select Fields
WERKS (Plant) Plant
NAME1 (Name) Plant Description
If no records are found in the table an error message should be displayed and the report should not be produced. If a record is found the user needs to be authorised to view entries from the corresponding plant. Check Authorisation object M_MATE_WRK.
HOW TO CHECK AUTHORIZTION CHECK.
CAN U PROVIDE ANY PSEUDOCODE???
10-03-2007 9:33 AM
hi madhan
see below code
SELECT werks
FROM t001w
INTO TABLE i_t001w
WHERE werks IN s_werks.
if Success
IF sy-subrc EQ 0.
SORT i_t001w BY werks.
ELSE.
MESSAGE e001(00) WITH text-m03.
ENDIF.
AUTHORITY-CHECK OBJECT 'M_MATE_WRK'
ID 'ACTVT' FIELD 'c_a'
ID 'WERKS' FIELD 's_werks' .
if sy-subrc = 0.
if s_werks-low eq c_val.
message 'its valid' type 'E'.
else.
message 'its not valid' type 'E'.
endif.
endif.
it will be usefull.
kk.
10-03-2007 9:23 AM
Hi
program an AUTHORITY-CHECK.
AUTHORITY-CHECK OBJECT <authorization object>
ID <authority field 1> FIELD <field value 1>.
ID <authority field 2> FIELD <field value 2>.
...
ID <authority-field n> FIELD <field value n>.
The OBJECT parameter specifies the authorization object.
The ID parameter specifies an authorization field (in the authorization object).
The FIELD parameter specifies a value for the authorization field.
The authorization object and its fields have to be suitable for the transaction. In most cases you will be able to use the existing authorization objects to protect your data. But new developments may require that you define new authorization objects and fields.
http://help.sap.com/saphelp_nw04s/helpdata/en/52/67167f439b11d1896f0000e8322d00/content.htm
To ensure that a user has the appropriate authorizations when he or she performs an action, users are subject to authorization checks.
Authorization : An authorization enables you to perform a particular activity in the SAP System, based on a set of authorization object field values.
You program the authorization check using the ABAP statement AUTHORITY-CHECK.
AUTHORITY-CHECK OBJECT 'S_TRVL_BKS'
ID 'ACTVT' FIELD '02'
ID 'CUSTTYPE' FIELD 'B'.
IF SY-SUBRC <> 0.
MESSAGE E...
ENDIF.
'S_TRVL_BKS' is a auth. object
ID 'ACTVT' FIELD '02' in place 2 you can put 1,2, 3 for change create or display.
The AUTHORITY-CHECK checks whether a user has the appropriate authorization to execute a particular activity.
Regards
Anji
10-03-2007 9:31 AM
Authority check for Plant
AUTHORITY-CHECK OBJECT 'M_MATE_WRK'(Authority check object)
ID 'ACTVT' FIELD '03'
ID 'WERKS' FIELD P_WERKS(Selection parameter)
IF sy-subrc NE 0.
MESSAGE e000 WITH
'No authorization'
i_spart.
ENDIF.
Regards
Vasu
10-03-2007 9:32 AM
Hi,
Authority-Check is used to check User authorizations. You can use an AUTHORITY-CHECK in your program, if you have a requirement where only specific users can have access to the program.
One can have several validations in Authority-Check. For e.g. only selected Users can run a particular transaction, only selected Users can run a report for a specific plant & if any other user tries to execute the report, then the Authority-check would fail & will raise a message that 'The User doesn't have access for a specific plant'.
One has to create a authorization object & assign authorization fields to it. Only those fields are validated.
AUTHORITY-CHECK OBJECT 'ZABC'
ID 'BUKRS' FIELD ITAB-BUKRS
ID 'VKORG' FIELD ITAB-VKORG.
Here the user authorization is done for two fields i.e. BUKRS & VKORG. If for a particular value of BUKRS or VKORG, the User executing the program doesn't have authorization, then that record won't be executed.
Now, if in another program, developer doesn't want to have validation on two fields but only validation on VKORG. Then he can use the same Authorization Object with following changes :-
AUTHORITY-CHECK OBJECT 'ZABC'
ID 'BUKRS' DUMMY
ID 'VKORG' FIELD ITAB-VKORG.
So here the BUKRS field won't be validated & only VKORG would be validated.
Hope this clears the doubts.
<b>Kindly reward POints if it helps</b>
Thanks and Regards
Tanweer
10-03-2007 9:33 AM
hi madhan
see below code
SELECT werks
FROM t001w
INTO TABLE i_t001w
WHERE werks IN s_werks.
if Success
IF sy-subrc EQ 0.
SORT i_t001w BY werks.
ELSE.
MESSAGE e001(00) WITH text-m03.
ENDIF.
AUTHORITY-CHECK OBJECT 'M_MATE_WRK'
ID 'ACTVT' FIELD 'c_a'
ID 'WERKS' FIELD 's_werks' .
if sy-subrc = 0.
if s_werks-low eq c_val.
message 'its valid' type 'E'.
else.
message 'its not valid' type 'E'.
endif.
endif.
it will be usefull.
kk.