Skip to Content

Restrict User to Company Code

Dear All

I have some requirement viz.

1. Restrict one company code data from other company users.

2. There are some common code (user exits) that should be executed for certain company code only.

So based on user id logged in is there any way to get the company code.

Your guidance will help me a lot.

PS: We have HCM system in place. But I need a solution without depending upon the HCM system.

Regards,

Venkat

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Mar 30, 2016 at 01:18 PM

    Hi Venkat,

    Filter BADI/enhancement won't available in all the case. Can you try the Authority-check statement for company code condition statement like below inside enhancement/exit.

    CONSTANTS: C_BUK1 LIKE REGUP-BUKRS VALUE '1234',

    C_BUK2 LIKE REGUP-BUKRS VALUE '2345',

    "First company code

    AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'

    ID 'ACTVT' FIELD '03'

    ID 'BUKRS' FIELD C_BUK1.

    IF SY-SUBRC = 0.

    <STATEMENTS>

    ENDIF.

    "Second company code

    AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'

    ID 'ACTVT' FIELD '03'

    ID 'BUKRS' FIELD C_BUK2.

    IF SY-SUBRC = 0.

    <STATEMENTS>

    ENDIF.

    Note: Assign the authorization object and authorization field correctly.

    Regards

    Rajkumar Narasimman

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 30, 2016 at 01:48 PM

    The usual way is to use authority checks to restrict users. I hope you have a field where the company code is contained. Depending on your module you can use the authority object mentioned by @Rajkumar Narasimman or create your own.

    The filter functionality of kernal BADIs works very well for those requirements to execute different coding for a different value (in your case company code). If your used user exits havn't those filter you could simply use the factory pattern (the filter functionality works the same way).

    Add comment
    10|10000 characters needed characters exceeded

    • Hi

      Thank you for the reply. Actually I need for the following case specifically..

      I have an user exit return in MV45AFZZ - upon saving event.

      This user exit validation should be executed only for one company and for other company it should not.

      So, I was planning to modify the user exit based on company code from where the user logged in.

      Kindly advice

      Regards,

      Venkat