Brief description of SAP Security Table Names. USR. table contains user master information. AGR. tables contains data about roles. USH. table has change documents information. AGR1251: Authorization data for the activity group: AGR1252: Organizational. ” Internal Table DATA: ltroles TYPE TABLE OF ltyroles, ltagr1251 TYPE TABLE OF agr1251, lsagr1251 TYPE agr1251, ltlog TYPE TABLE OF ltylog, lslog TYPE ltylog. ” Selecting the Roles Assigned to the User SELECT agrname FROM agrusers INTO TABLE ltroles.
What is AMDP, How to declare an AMDP class, How to identify an AMDP method? We also consumed the AMDP Class method is our Program and displayed the output.
If you have not visited the earlier article or if you have not worked in AMDP earlier, we would sincerely suggest you have a glance of that topic so that you can understand this and appreciate this article.
In the example demonstrated in the earlier article, all the selection screen elements were PARAMETERS. Using the PARAMETERS in AMDP Method SELECTs were straight forward. Today we would show how we can pass SELECT OPTIONs of the screen to AMDP Methods and use them. Please note, we cannot directly pass SELECT options as is it to AMDP Methods. This is one limitation of AMDP. We need to select the data from the database and then APPLY the Filter using the function APPLY_FILTER.
Let us hit it hard again. AMDP Class-Methods cannot take SELECT OPTIONS as input. So SELECT OPTIONS need to be converted to FILTER STRING using some way and then pass the FILTER STRING as an input PARAMETER of the of the AMDP Method.
The actual syntax to filter the selected data would look like below:
EX_IT_TCODE_ROLE would have all the data and APPLY_FILTER would keep the subset using IP_FILTERS value.
How do we pass IP_FILTERS?
Ans: It has to be passed as STRING.
How do we generate the filter string from SELECT OPTIONS?
Ans: You are the programmer, you find your way to generating the filter. It should act as the WHERE clause. Or like the FILTER using RANGE table.
Do not worry, we would show you an easy way.
If S_TCODE and S_ROLE are two SELECT OPTIONS of a program, then the string for AMDP filter can be generated using the class CL_SHDB_SELTAB method COMBINE_SELTABS as shown below.
If the above syntax is little confusing, then check the alternative for the same syntax.
Feeling better now?
Add class CL_SHDB_SELTAB method COMBINE_SELTABS on your cheat sheet.
What does the above class method do?
Ans: See it yourself in debug mode.
I am sure by now you are curious to know how we use it in the Program (after all you are a programmer by heart).
Real Time working Program to show handling of SELECT OPTION in AMDP:
Real AMDP Class Method showing usage of APPLY_FILTER for SELECT OPTIONS:
Some point for the explorers.
1. If you do not want to use CL_SHDB_SELTAB=>COMBINE_SELTABS to build your Filter String, you can do it yourself using CONCATENATE function.
Agr_1251 Table In Sap Stand
It is same as ( AUGDT = ‘00000000’ OR AUGDT = ‘20161129’ ).
2. If you think the below syntax to generate the dynamic WHERE CLAUSE string is bit complex, then try to use the alternative.
This alternative shown below is a lengthy approach but might be simple and easy to understand for some of us. After all, everyone has the right to be different.
Let us see in debug mode, how lty_named_dref look like.
No brainer: Output of lv_where need to be the same.
Huh!! I am sure by now you are convinced that you would rather spend some time understanding new syntax at the top of this article than writing this bunch of redundant codes shown above. Our job was to place all the MENU, it is up to you to decide which one you like.
3. If you observe the code for APPLY_FILTER closely, you would notice, filtering is done after we select a bunch of unwanted data and apply the Filter. Doesn’t it impact the performance negatively?
See, we selected everything here.
Then we applied the Filter.
Experts suggest wherever possible, we should apply the filter to the DB table directly and then play around with the resultant data set.
For example, if ip_code_where_clause has S_TCODE select option, then we can directly apply the filter on the database table AGR_1251.
Agr_1251 Table In Sap Sql
Thus, APPLY_FILTER function can be applied to DB Tables and also it can be applied to Internal Tables.
After the epic is over, let us introduce the main character of our today’s story, i.e. APPLY_FILTER. The function APPLY_FILTER expect two PARAMETERS.
i – Dataset (example AGR_1251 (DB table, CDS View); :ex_it_tcode_role (Internal table)) which needs to be filtered.
ii – Generated WHERE clause which is passed to AMDP method as String.
Agr_1251 Table In Sap Table
4. After going through the above information one would have a doubt. Why did SAP not allow SELECT OPTIONS to be directly used in AMDP as in normal ABAP?
Ans: We would request experts to provide some explanation to this query.
We feel SAP deliberately chose this path to push down the select option to database level in accordance with its code to data paradigm shift strategy. AMDPs are executed directly on the database, hence the select options in the form of filter string would be executed on the database. On the other hand SELECT OPTION is just an ABAP language construct which cannot be directly executed on database level