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 for multiple objects

Former Member
0 Likes
5,635

Dear all,

I understand how to perform authority check for 1 plant, which the code is given below.

authority-check object 'ZXXX'

id 'ACTVT' field actvt

id 'WERKS' field xwerks.

Here XWERKS is just one filed. But what i am supposed to do, if this XWERKS need to be replace by a internal table which stores, a collection of plants.

something like:

loop at it_werks.

authority-check object 'ZXXX'

id 'ACTVT' field actvt

id 'WERKS' field it_werks-werks.

if sy-subrc ne '0'.

exit.

endif.

endloop.

Is this a good way of doing.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,711

Or for a select option:

select-options: db_werks for marc-werks memory id wrk obligatory.

loop at db_werks.

authority-check object 'ZXXX'

id 'ACTVT' field actvt

id 'WERKS' field db_werks-werks.

if sy-subrc ne '0'.

exit.

endif.

endloop.

Is this best way of programing.

Edited by: vinay k on Feb 18, 2010 5:15 PM

9 REPLIES 9
Read only

Former Member
0 Likes
3,712

Or for a select option:

select-options: db_werks for marc-werks memory id wrk obligatory.

loop at db_werks.

authority-check object 'ZXXX'

id 'ACTVT' field actvt

id 'WERKS' field db_werks-werks.

if sy-subrc ne '0'.

exit.

endif.

endloop.

Is this best way of programing.

Edited by: vinay k on Feb 18, 2010 5:15 PM

Read only

0 Likes
3,711

Hi,

your code with selection option is wrong. You don't check for intervals and also you don't check for operator and sign in selection criteria. For example you can have line for interval from plant 1000 to 2000 but your code will check only if the user has an authorization for plant 1000. You can also have different operator such as less than.If you want to check authorization for all plants you need to get a table with all plants and do it one by one as you wrote in your first comment.

Cheers

Read only

0 Likes
3,711

Hi VInay,

When you have selct option you need to consider ranges and exclusions also. If you simply loop, it won't work. Try with below code.


AT SELECTION-SCREEN  ON db_werks. "Assuming db_werks is your select option.
SELECT werks INTO TABLE i_t001w FROM t001w WHERE werks IN db_werks.

loop at i_t001w INTO wa_t001w.
authority-check object 'ZXXX'
id 'ACTVT' field actvt
id 'WERKS' field wa_t001w-werks.
if sy-subrc ne '0'.
"Here you need to display the error. If you simply exit it wont work.
MESSAGE 'No authorization' TYPE 'E'.
endif.
endloop.

Thanks,

Vinod.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,711

Hello,

I will take Vinod's code as reference because the basic idea is absolutely correct. But i do not agree with the error handling

Suppose out of the 10 plants selected from T001W (for e.g., only) the user has auth. for 7. Is it ok to stop the user from executing the report or let him proceed with the 7 & for the 3 plants he does not have auth., display display a log.

Awaiting responses from fellow SDNers

cheers,

Suhas

Read only

0 Likes
3,711

Hi Suhas,

Yes. You are correct. But it completely depends on the requirement. I have come across both the requirements in my experience.

1. Don't allow the user to proceed even if he/she don't have access to at least one. (Above code works for this scenario)

2. Proceed with the one he/she has the access.

In this case we should collect the plants where authorization is failed, delete that record from i_t001w and consider i_t001w for further processing.

Hope i am making some sense:-)

Thanks,

Vinod.

Read only

Former Member
0 Likes
3,711

Sorry friends,

Above code didnot work i just checked. it said there is no component called werks in db_werks.

but it seems to give out put if i put directly as:

select-options: db_werks for marc-werks memory id wrk obligatory.

authority-check object 'ZXXX'

id 'ACTVT' field '02'

id 'WERKS' field db_werks.

Can someone please let meknow, if this is right way doing the thing.

It will be help full if some one responds.

Thanks.

Read only

0 Likes
3,711

Why is no one responding...

Read only

matt
Active Contributor
0 Likes
3,711

>

> Why is no one responding...

Presumably because you obviously don't understand what a select-option is, and how information is stored in it. People are, quite rightly, reluctant to post basic stuff. These are not training forums. I propose you read the ABAP help before using any statement for the first time. What you do is put your cursor within the keyword you're interested in, and press F1.

Anyway- you've got lots of responses now.

Read only

0 Likes
3,711

Hi everyone,

Thanks a ton for your responses. I really appreciate it. They helped me get an understanding.

Matt,

Yes, i did F1 help, i could not correlate to my scenario, so, i posted. Thank you for your suggestion. Next time i will make sure, i do thorough research through F1 before posting.