Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Authority Check on the Transaction Code

Former Member
0 Likes
5,551

Hi Gurus,

My requirement is that i need authority check on field WERKS for a transaction code which is having SM30 as Transaction and the view name a table.

Hi Gurus,

My requirement is that i need authority check on field WERKS for a transaction code which is having SM30 as Transaction and the view name a table.

9 REPLIES 9
Read only

Former Member
0 Likes
2,024

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.

Regards,

SG

Read only

0 Likes
2,024

Hi,

A method is to put the authority check in the table maintainance generator.

In the table maintainance generator you can change code either by modifying the screen or adding the events as required. Over here you can try to put your authority check because u want the authority at data level.

Please note that there is a risk involved in this method.

Incase the table maintainance generator is regenerated then your code changes will be lost.

So you will have to take a backup incase you regenerate the table maintainance generator.

Regards,

Ankur Parab

Read only

Former Member
0 Likes
2,024

Hi. I have just done the same thing. I tried a few ways but found problems with most of them. You seem to end up with loads of blank lines and things like that if you use the PBO / PAI.

What I did was create a custom include (ZAUTHCHECK for example).

Then go to include LSVIMFTX and copy form TABLEPROC and put it in your custom include and call it ZTABLEPROC. Then find form TABLE_GET_DATA in include LSVIMFTX and copy it into your custom include and call it ZTABLE_GET_DATA.

Then in your custom include find the line that says "PERFORM table_get_data' and change it to "PERFORM ztable_get_data.".

Then in ZTABLE_GET_DATA find the line that says "SELECT * FROM (x_header-maintview) INTO TABLE <primtab>.". At this point <primtab> has your raw data in, so just loop through it assigning a new field symbol and do the auth check that you need and delete <primtab> if the auth check fails. This means the non authorised data will never get passed to the screen.

Finally go to the function group that the table view belongs to and in the main program add your custom include then find the function module called "TABLEPROC_Zxxxxxxxxx" and change the 1 line in there to read "PERFORM ZTABLEPROC".

The good thing about this is that I do not think it will get reset if the tableview regenerates, as the custom includes do not get overridden. I tried changing a view and it did not get lost.

The bad thing obvisouly is that we have created Z versions of 2 standard subroutines, so if any notes come out for them we will not get them.

I hope this is of some help.

Regards,

Dave.

Read only

0 Likes
2,024

HI,

So, after we copy and paste those coding to our new customised include, all the variable that are used should be declared again or no necessary?

Thanks in advance.

Read only

0 Likes
2,024

Hi. There is no need to declare anything except any new variables you may want to use as part of your authority check.

Because the new include is declared in the same top include of your original function group all the original variables will be there already.

Regards,

Dave.

Read only

0 Likes
2,024

Hi, David Barber,

Thanks for ur reply.

But after I try to copy the two forms TABLEPROC and TABLE_GET_DATA into my new customised include program which i created in my main program in my function group, those variable in the two forms just now keep saying unknown variable.

Do you have any idea to overcome this issue?

Thanks in advance.

Read only

Former Member
0 Likes
2,024

hi

check out the function module 'AUTHORITY_CHECK_TCODE'

Read only

Former Member
0 Likes
2,024

Hi,

Please check in FM 'AUTH_CHECK_TCODE' if exception is ok then there is authority check .

Please check this.

call 'AUTH_CHECK_TCODE'

id 'TCODE' field tcode.

if sy-subrc = 0.

raise ok.

else.

message i077(s#) with tcode raising not_ok.

endif.

Aswarth

Read only

Former Member
0 Likes
2,024

Hi,

Hope this helps you.

authority-check object 'S_TCODE'

id 'TCD'

field 'SM30'.

if sy-subrc ne 0.

  • User does not have authority for transaction SM30!

endif.

Another way is you can use the FM AUTHORITY_CHECK_TCODE.