The following code demonstrates how to check that a user has the correct authority for a particular transaction code. Useful to check if a user has the correct authority before executing a transaction via BDC input.
authority-check object 'S_TCODE' id 'TCD' field 'SM35'. if sy-subrc ne 0. * User does not have authority for transaction SM35!!! endif.