‎2009 Apr 07 12:10 PM
Hi Gurus,
I have created authorization object code for company code validation.i have given code.
data : c_actvt(2) type c value '03'.
SELECT bukrs FROM t001 INTO TABLE i_bukrs WHERE bukrs IN s_bukrs.
IF sy-subrc EQ 0.
LOOP AT i_bukrs INTO wa_bukrs.
AUTHORITY-CHECK OBJECT 'F_LFA1_BUK'
ID 'BUKRS' FIELD wa_bukrs-bukrs
ID 'ACTVT' FIELD c_actvt.
IF sy-subrc <> 0.
MESSAGE 'You do not have authorization for Company code' TYPE c_error.
ENDIF.
ENDLOOP.
ENDIF.
In this code excuted without any error..but its not giving proper answer..In run time i have changed some wrong company code like wa_bukrs-bukrs = 'ABCD' but its not giving the Error like "'You do not have authorization for Company code'".Please Help on this..
Regards
P.Senthil Kumar
Moved to correct forum
Edited by: Rob Burbank on Apr 7, 2009 11:12 AM
‎2009 Apr 07 12:16 PM
Your code is only performing authorization check for existant records (i_bukrs).
Put an exception message on else of if sy-subrc eq 0 like "No valid company code informed".
It's not common to check each valued informed by the user on s_bukrs, but if you wish you can perform a LOOP on s_bukrs (range is internal table too) and check if any s_bukrs-low is found on internal table i_bukrs. This is not work for all cases, due to user can inform values in ranges (A to Z) and with wildcards (BR*).
I hope it help you
Fernando Da Ró
‎2009 Apr 07 12:18 PM
HI,
If you are chaning the value of the BUKRS after the authority check process is done then ..you will not get the any error messages.
If you want to test you need to change the value before it is passed to the AUthority Check Object.
‎2009 Apr 07 12:22 PM
Hi Avinash Kodarapu ,
I have changed the BUKRS value before executing 'authority check'..
Please provide me the solution
Regradrs
P.Senthil Kumar
Edited by: senthil kumar on Apr 7, 2009 3:51 PM
Edited by: senthil kumar on Apr 7, 2009 3:52 PM
‎2009 Apr 07 5:01 PM
Hello,
Not sure how you have defined your auth object but my guess is that you have used * for the value of
bukrs and activity 03.. Which if I understand authorizations means that you have granted display auth to
all company codes, inlcuding ABCD.
If I have assumed correctly then the auth check is not the place to expect to validate your company code value. That is more appropriately done by your select for t001 which should only retrieve company codes on that table. If if in fact someone enters ABCD in the select option as the only value then the auth check in your sample code will never be executed since you itab will be empty.
Hope that helps a bit.
Regards
Greg Kern
‎2009 Apr 08 6:01 AM
Hi,
You have to give the message when sy-subrc not equal to 0. (ie, when authorization fails)
IF sy-subrc 0. -> change this to IF SY-SUBRC NE 0.
MESSAGE 'You do not have authorization for Company code' TYPE c_error.
ENDIF.
Regards,
Soumya.
Edited by: Soumya Jose on Apr 8, 2009 7:08 AM
‎2009 Apr 08 6:24 AM
Hi .
pls try this.
initialization.
perform check_tcode_authority.
form check_tcode_authority .
authority-check object 'ZPRCHK_NEW' :
id 'TCD' field sy-tcode
id 'BUKRS' dummy
id 'PRCTR' dummy
id 'SPART' dummy
id 'WERKS' dummy
id 'VKORG' dummy
id 'EKORG' dummy.
if sy-subrc ne 0.
message text-137 type 'E'.
leave program.
endif.
endform.
Regards
‎2009 Apr 08 6:26 AM