10-08-2010 4:40 PM
Hello Experts,
I have a requirement where i have to call the authorization object dynamically for a authorization check irrespective of how many fields the authorization object has.
can you please help how can we make it dynamic.
For example:
auth_obj = test_auth. "test auth has 2 filds for auth check.
Perform authority_check using auth_obj.
auth_obj = test_auth1. "test_auth1 has 4 fields
Perform authority_check using test_auh1.
Form authority_check using auth_obj.
AUTHORITY-CHECK OBJECT auth_obj
FOR USER sy-uname
ID 'ACTVT' FIELD '01'
ID 'AUTH_FIELD' FIELD 'field name will be passed'.
ENDFORM.
Please suggest how can we achieve this?
BR,
Rajesh
10-09-2010 4:49 PM
Hi Rajesh,
you will have to distinguish the calls according to parameter number, i.e. you should pass the number of fields as n_id
Form authority_check using auth_obj id1 field1 id2 field2 id3 field3 ... n_id.
case n_id.
when 1.
AUTHORITY-CHECK OBJECT auth_obj
ID id1 FIELD field1.
when 2.
AUTHORITY-CHECK OBJECT auth_obj
ID id1 FIELD field1
ID id2 FIELD field2.
...
endcase.
...
Regards,
Clemens
10-09-2010 5:15 AM
Create the perform at the runtime in a separate include (which should be already created and added to your main program) and then call it
10-09-2010 4:49 PM
Hi Rajesh,
you will have to distinguish the calls according to parameter number, i.e. you should pass the number of fields as n_id
Form authority_check using auth_obj id1 field1 id2 field2 id3 field3 ... n_id.
case n_id.
when 1.
AUTHORITY-CHECK OBJECT auth_obj
ID id1 FIELD field1.
when 2.
AUTHORITY-CHECK OBJECT auth_obj
ID id1 FIELD field1
ID id2 FIELD field2.
...
endcase.
...
Regards,
Clemens
04-16-2015 4:29 PM
Hi,
There is another approach possible, you can use AUTHORITY-CHECK one time with maximum of 10 fields and fill only some of them, only that fields would be checked.
You can find a complete example here:
http://www.kerum.pl/infodepot/00043
Regards,
Kris