Application Development 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: 

Dynamic authorization object call in a program

styrolution_accenture
Participant
0 Kudos

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

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

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

3 REPLIES 3

Former Member
0 Kudos

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

Clemenss
Active Contributor
0 Kudos

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

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