Sie sind auf Seite 1von 31

SAP BusinessObjects EPM

How-To Guide

How To... Use the Shared Query


Engine Post Process BAdI

Applicable Releases:
SAP BusinessObjects Planning and Consolidation 7.0 , version for SAP
NetWeaver, SP04 and higher.
SAP BusinessObjects Planning and Consolidation 7.5 , version for SAP
NetWeaver, SP00 and higher.

Version 1.0
May 2010

Copyright 2010 SAP AG. All rights reserved.


No part of this publication may be reproduced or
transmitted in any form or for any purpose without the
express permission of SAP AG. The information contained
herein may be changed without prior notice.
Some software products marketed by SAP AG and its
distributors contain proprietary software components of
other software vendors.
Microsoft, Windows, Outlook, and PowerPoint are
registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, OS/2, Parallel
Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390,
OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP,
Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix,
i5/OS, POWER, POWER5, OpenPower and PowerPC are
trademarks or registered trademarks of IBM Corporation.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader
are either trademarks or registered trademarks of Adobe
Systems Incorporated in the United States and/or other
countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered
trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame,
WinFrame, VideoFrame, and MultiWin are trademarks or
registered trademarks of Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or
registered trademarks of W3C, World Wide Web
Consortium, Massachusetts Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems,
Inc., used under license for technology invented and
implemented by Netscape.
MaxDB is a trademark of MySQL AB, Sweden.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP
NetWeaver, and other SAP products and services
mentioned herein as well as their respective logos are
trademarks or registered trademarks of SAP AG in
Germany and in several other countries all over the world.
All other product and service names mentioned are the
trademarks of their respective companies. Data contained
in this document serves informational purposes only.
National product specifications may vary.

These materials are subject to change without notice.


These materials are provided by SAP AG and its affiliated
companies ("SAP Group") for informational purposes only,
without representation or warranty of any kind, and SAP
Group shall not be liable for errors or omissions with
respect to the materials. The only warranties for SAP
Group products and services are those that are set forth in
the express warranty statements accompanying such
products and services, if any. Nothing herein should be
construed as constituting an additional warranty.
These materials are provided as is without a warranty of
any kind, either express or implied, including but not
limited to, the implied warranties of merchantability,
fitness for a particular purpose, or non-infringement.
SAP shall not be liable for damages of any kind including
without limitation direct, special, indirect, or consequential
damages that may result from the use of these materials.
SAP does not warrant the accuracy or completeness of the
information, text, graphics, links or other items contained
within these materials. SAP has no control over the
information that you may access through the use of hot
links contained in these materials and does not endorse
your use of third party web pages nor provide any warranty
whatsoever relating to third party web pages.
SAP NetWeaver How-to Guides are intended to simplify
the product implementation. While specific product
features and procedures typically are explained in a
practical business context, it is not implied that those
features and procedures are the only approach in solving a
specific business problem using SAP NetWeaver. Should
you wish to receive additional information, clarification or
support, please refer to SAP Consulting.
Any software coding and/or code lines / strings (Code)
included in this documentation are only examples and are
not intended to be used in a productive system
environment. The Code is only intended better explain and
visualize the syntax and phrasing rules of certain coding.
SAP does not warrant the correctness and completeness of
the Code given herein, and SAP shall not be liable for
errors or damages caused by the usage of the Code, except
if such damages were caused by SAP intentionally or
grossly negligent.
Disclaimer
Some components of this product are based on Java. Any
code change in these components may cause unpredictable
and severe malfunctions and is therefore expressively
prohibited, as is any decompilation of these components.
Any Java Source Code delivered with this product is only
to be used by SAPs Support Services and may not be
modified or altered in any way.

Document History
Document Version

Description

1.00

First official release of this guide

Typographic Conventions

Icons

Type Style

Description

Icon

Example Text

Words or characters quoted


from the screen. These
include field names, screen
titles, pushbuttons labels,
menu names, menu paths,
and menu options.
Cross-references to other
documentation

Example text

Emphasized words or
phrases in body text, graphic
titles, and table titles

Example text

File and directory names and


their paths, messages,
names of variables and
parameters, source text, and
names of installation,
upgrade and database tools.

Example text

User entry texts. These are


words or characters that you
enter in the system exactly as
they appear in the
documentation.

<Example
text>

Variable user entry. Angle


brackets indicate that you
replace these words and
characters with appropriate
entries to make entries in the
system.

EXAMPLE TEXT

Keys on the keyboard, for


example, F2 or ENTER.

Description
Caution
Note or Important
Example
Recommendation or Tip

Table of Contents
1.

Business Scenario ..........................................................................................................1

2.

Background Information .................................................................................................2

3.

Prerequisites....................................................................................................................2

4.

Step-by-Step Procedure ..................................................................................................3


4.1
4.2

5.

Create a BAdI Implementation ..................................................................................3


Test the BAdI Implementation .................................................................................14

Appendix........................................................................................................................ 20
5.1

Source Code for BAdI Implementation ....................................................................20

How To... Use the Shared Query Engine Post Process BAdI

1.

Business Scenario

Note: This guide is not intended to assist in fully implementing a matrix security model in BPC. It is
intended to demonstrate how to use the SQE BAdI to implement custom code to fill gap requirements.
In this guide, we use the Matrix Security business scenario as an example only. The code associated
with this guide is not supported in any way by SAP, and is not guaranteed to work in all cases.
Remember, this guide is to demonstrate the use of the SQE BAdI only.
Currently, BPC only supports controlling authorization to read and write data using individual
dimension members and nodes. In this business scenario, the business wants to implement matrix
type or intersectional security using multiple dimensions. Consider the following example.
You want to give a user access to see personal costs for the US and advertising costs for EMEA only,
but you want to prevent the user from seeing Personal Costs for EMEA and advertising costs for the
US.

Desired Security

Personal Costs

Advertising Costs

US
EMEA

X
X

Standard BPC Security cannot accomplish this task because Account and Entity are two different
dimensions. Giving a user access to Entity nodes US and EMEA and to account Personal and
Advertising Costs results in the user being able to see also Personal Costs in EMEA and Advertising
Costs in the US(the union of values across dimension), which is not desired.
Hence, giving authorization by individual dimensions is not sufficient. In order to achieve
intersectional or matrix security, you need to be able to grant access by a combination of values
linked together from different dimensions( by tuples or vectors of member values from multiple
dimension ).
In the case of our example, we have to give access to 2 pairs of values
US, Personal Costs
EMEA, Advertising Costs
But simply creating two member access profiles in BPC with these pairs will still result in a union of
values, not an intersection, and thus the user will still be able to see all four values as shown in the
figure below.

Standard Security

Personal Costs

Advertising Costs

US
EMEA

To overcome this limitation of standard BPC security, this How-To Guide demonstrates how you can
use the Shared Query Engine(SQE) BAdI to enhancement how data is read in BPC. Using this BAdI,
we can insert ABAP code to accomplish matrix security.
May 2010

How To... Use the Shared Query Engine Post Process BAdI

The SQE BAdI is well suited because you can implement these custom security controls before the
data is displayed to the end user. This would give you the ability to apply a special matrix or
intersectional filter at the time of query execution on the dimensions you have used to drive your
security model.

2.

Background Information

SAP Business Add-Ins (BAdIs) are one of the most important technologies used to adapt SAP
software to specific requirements. As of Release 7.0 of the SAP NetWeaver Application Server ABAP,
BAdIs are part of the Enhancement Framework, where they represent explicit enhancement options.
BAdIs are the basis for Object Plug-Ins that can enhance the functions in ABAP programs without
having to make core software modifications. As such, BAdI calls can be integrated into customer
applications (like BusinessObjects Planning and Consolidation, version for SAP NetWeaver for
example) to allow enhanced customization of standard application functionality.
This How-To Guide (HTG) describes the procedure for creating and configuring the Shared Query
Engine (SQE) BAdI to implement matrix or intersectional security within BPC. The Step By Step
section will outline the steps needed in order to create the BAdI itself in addition to the configuration
required within BPC to actually execute the BAdI. The Appendix section contains the example ABAP
code that goes along with this guides Business Scenario. This code is only meant as an example and
while it will perform the actions described in this guide it may not match the exact needs of your own
particular Business Scenario it is only intended to guide you in the creation of your own BAdI
Implementation.

3.

Prerequisites

Required/recommended expertise or prior knowledge


SAP BusinessObjects Planning and Consolidation 7.0, version for SAP NetWeaver, SP4 and
higher
SAP BusinessObjects Planning and Consolidation 7.5, version for SAP NetWeaver, SP0 and
higher
ABAP programming skills
Access to SAP NetWeaver transaction codes: SE20, SE18, SE19, SE38, SE80, SE24, STMS
Additional Documentation
RKT Online Knowledge Product
http://service.sap.com/rkt On the left hand side, navigate to SAP Ramp-Up Knowledge
Transfer -> SAP BusinessObjects EPM Solutions -> SAP BO PC 7.5, version for SAP
NetWeaver
Other EPM How-To Guides
http://wiki.sdn.sap.com/wiki/display/BPX/Enterprise+Performance+Management+%28EP
M%29+How-to+Guides
SAP Help Library Business Add Ins
http://help.sap.com/saphelp_nw70/helpdata/en/8f/f2e540f8648431e10000000a1550b0/fr
ameset.htm

May 2010

How To... Use the Shared Query Engine Post Process BAdI

4.

Step-by-Step Procedure

A BAdI implementation is the term used in the Enhancement Framework for an enhancement
implementation element. A BAdI implementation consists of a BAdI implementation class that
implements the BAdI interface. The BAdI implementation also contains a filter condition which is
specified in the BAdI definition. This filter condition can be used to execute the BAdI implementation at
runtime.

4.1

Create a BAdI Implementation

...1

1. Log on to the NetWeaver system via SAPgui. Enter transaction SE18 and press Enter.

2. In the initial screen, enter the name of the corresponding enhancement spot. Enter
UJQ_SHARED_QUERY, and click Display.

May 2010

How To... Use the Shared Query Engine Post Process BAdI

3. On the left side of the screen, expand the BAdI definition tree by clicking on the
should then see the following nodes.

icon. You

Interf

Interface
Filter
Implementations

4. Right-click on the Implementations node, and choose Create BAdI Implementation.

May 2010

How To... Use the Shared Query Engine Post Process BAdI

5. In some cases, a developer may have already created an enhancement implementation for this
enhancement spot for a different BAdI definition. If an enhancement implementation already
exists, a dialog listing all implementations will be displayed. Click the Create button in the
lower right hand corner. If this dialog is not displayed, continue to step 6.

6. In this dialog, enter the name of the enhancement implementation and the short description.
Name it as ZUJ_SQE_POST_PROCESS_EX. Then click the green check to continue.

7. Enter the name of a package name for transporting this BAdI to another system in your
landscape, or click Local Object if you do not plan to transport this BAdI.

May 2010

How To... Use the Shared Query Engine Post Process BAdI

8. If you are presented with this dialog, then select your enhancement implementation which was
just created in step 6, and click the green check. If there are no other previous
implementations, go directly to the dialog box shown in step 9.

9. In this dialog, enter the name of the BAdI Implementation as


ZUJ_SQE_POST_PROCESS_EX_IMP, and enter the description. Also, enter the name of the
implementing class as ZCL_UJQ_POST_PROCESS_EX.

10. Enter the name of a package name for transporting this BAdI to another system in your
landscape, or click Local Object if you do not plan to transport this BAdI.

May 2010

How To... Use the Shared Query Engine Post Process BAdI

11. The BAdI Implementation will then be saved. Notice it is not yet active.

12. Click on the icon next to the name of the BAdI Implementation. This will expose the following
nodes below.
Implementing Class
Filter Values

May 2010

How To... Use the Shared Query Engine Post Process BAdI

13. Double click on the Filter Val. Node.

14. Click the Change icon.

15. Click on the Combination button from the filter values screen.

May 2010

How To... Use the Shared Query Engine Post Process BAdI

16. Select both APPSET_ID and APPLICATION_ID, or click the Select All button, and then click
the Green Check button to continue.

17. Now double click on the APPLICATION_ID line of the combination.

18. Enter the name of the application, which will use this BAdI implementation, into the Value 1
field. In this example, the PLANNING application id used. Next set the drop down box for
Comparator 1 to =. Finally click the Green Check to continue.

May 2010

How To... Use the Shared Query Engine Post Process BAdI

19. Next, double click on the APPSET_ID line of the combination.

20. In the Value 1 field, enter the name of the application set, in which this BAdI implementation
will be used, In this example, APSHELL_HTG is used. . Next set the drop down box for
Comparator 1 to =. Finally click the Green Check to continue.

21. Finally, save and activate by clicking the appropriate buttons.

May 2010

10

How To... Use the Shared Query Engine Post Process BAdI

22. In the following dialog, first click the Select All button, and then the Green Check button. All
objects should then be active.

23. Finally, the code which will be executed by the BAdI implementation can be inserted into the
implementing class. Double click on the Implementing Class node from the left side of the
screen.

May 2010

11

How To... Use the Shared Query Engine Post Process BAdI

24. Now double-click on the implementing class name.

25. Due to forward navigation, the implementing class is displayed in the class builder tool. Click on
the Change icon. Then double-click on the POST_PROCESS method.

26. An empty method implementation will be shown. Notice, the method signature is displayed at
the top. If the method signature is not displayed, click the Signature button on the application
toolbar.

May 2010

12

How To... Use the Shared Query Engine Post Process BAdI

27. Copy and paste the source code from Appendix 5.1 into the POST_PROCESS method.

28. Save and activate the class by clicking the appropriate buttons.

May 2010

13

How To... Use the Shared Query Engine Post Process BAdI

4.2

Test the BAdI Implementation

In this how-to guide, we use a simple example of a matrix security model to further restrict what the
user can see in a short report. The user CC_MGR has specific member access profiles, US_MAP and
EMEA_MAP, assigned to it. The CC_MGR user should only be allowed to see data for the US where
the account is Personal Costs(CE0004000) and data for EMEA where the account is Advertising
Costs(CE0004200). The following table illustrates these rules.

P_CC \P_ACCT

CE0004000

US
EMEA

CE0004200
X

Within the matrix security model, which has been implemented by the BAdI implementation, the user
should receive an error if he tries to view data under US for account CE0004200. The following
screenshots show how the member access profiles are set up.
Member Access Profile: US_MAP

Member Access Profile: EMEA_MAP

May 2010

14

How To... Use the Shared Query Engine Post Process BAdI

The image below shows what a report would look like for CC_MGR user with both member access
profiles, if the standard BPC security model is used and not the matrix security model implemented by
the BAdI. Notice that the two member access profiles are unioned together. As a result all four
values are shown as the user has access to Personal and Advertising Costs for both US and EMEA.

We will see how this report changes after the matrix security BAdI Implementation.
1. Go to the BPC Excel Client and log on to the application set with the user which has the correct
security model, for example CC_MGR. In this example, a copy of APSHELL called
APSHELL_HTG is used. In the previous steps we implemented the the matrix security model
via the SQE BAdI for this application set. Set the current view as shown in the image below.
For this example, it is important to set Cost Center(P_CC) to US and Account(P_ACCT) to
Personal Costs(CE0004000). Remember, the CC_MGR user currently has authorization to both
the US_MAP and EMEA_MAP member access profiles. The matrix security model implemented
in the BAdI will further restrict this member access.

May 2010

15

How To... Use the Shared Query Engine Post Process BAdI

2. From the action pane, click on Report & Analysis. We are going to recreate the report shown
above.

3. Next, click on Open a blank workbook.

4. In the excel sheet, enter =EVDRE() into the A1 cell and hit enter.

May 2010

16

How To... Use the Shared Query Engine Post Process BAdI

5. Then click on the Refresh workbook button on the Planning & Consolidation tab.

6. First, remove the TIME dimension by selecting it from the In columns box on the right and
clicking the appropriate arrow button. Next, move the P_CC dimension to the In columns box
by selecting P_CC from the box on the left and clicking the appropriate arrow button. Then click
Ok.

May 2010

17

How To... Use the Shared Query Engine Post Process BAdI

7. The report is then generated and displayed.

8. Click the Expand button.

9. Hardcode the member values into the EXPANSION 1 and EXPANSION 2 fields as shown in the
image below. This will force the report to show these intersections.

May 2010

18

How To... Use the Shared Query Engine Post Process BAdI

10. Click the Expand All button on the Planning & Consolidation tab.

11. The report is then displayed. Notice that the values have been restricted by the matrix security
implementation.

May 2010

19

How To... Use the Shared Query Engine Post Process BAdI

5.

Appendix

5.1

Source Code for BAdI Implementation

METHOD if_ujq_sqe_post_process~post_process.

TYPE-POOLS: abap.

TYPES: t_range TYPE STANDARD TABLE OF rsrange


WITH DEFAULT KEY INITIAL SIZE 1.

TYPES: BEGIN OF t_profile,


dimension

TYPE uje_s_memaccess-dimension,

access

TYPE t_range,

success

TYPE abap_bool,

all

TYPE abap_bool,

rwd

TYPE uj_rwd,

END OF t_profile.

TYPES: BEGIN OF t_profiles,


id

TYPE uje_s_memaccess-profile_id,

profile

TYPE TABLE OF t_profile WITH DEFAULT KEY INITIAL SIZE 1,

success

TYPE abap_bool,

END OF t_profiles.

DATA: lo_model

TYPE REF TO if_uj_model.

DATA: lo_dim

TYPE REF TO if_uja_dim_data.

DATA: lo_hier

TYPE REF TO if_uja_hier.

DATA: lo_tabdef

TYPE REF TO cl_abap_tabledescr.

DATA: lo_datadef

TYPE REF TO cl_abap_datadescr.

DATA: lo_strucdef

TYPE REF TO cl_abap_structdescr.

DATA: lo_profile

TYPE REF TO cl_uje_profile_memaccess.

DATA: lo_user

TYPE REF TO cl_uje_user.

DATA: lt_mprof_id

TYPE

DATA: ls_mprof_id

TYPE uje_s_profile_id_act.

DATA: lt_messages

TYPE uj0_t_message.

DATA: ls_memaccess

TYPE uje_s_memaccess.

May 2010

uje_t_profile_id.

20

How To... Use the Shared Query Engine Post Process BAdI

DATA: lt_profiles

TYPE TABLE OF t_profiles.

DATA: ls_profiles

TYPE t_profiles.

DATA: ls_profiles_tmp

TYPE t_profiles.

DATA: lt_profile

TYPE TABLE OF t_profile.

DATA: ls_profile

TYPE t_profile.

DATA: lt_range

TYPE t_range.

DATA: ls_range

TYPE rsrange.

DATA: lt_base_mems

TYPE uja_t_dim_member.

DATA: lt_memaccess

TYPE uje_t_memaccess.

DATA: lt_memaccess_tmp

TYPE uje_t_memaccess.

DATA: ls_details

TYPE uje_s_user_detail.

DATA: lv_obj_id

TYPE string.

DATA: lv_member

TYPE uj_dim_member.

DATA: lv_tabix

TYPE sy-tabix.

DATA: lv_priorprofileid

TYPE uje_s_memaccess-profile_id.

DATA: lv_access_granted

TYPE abap_bool.

DATA: lv_access_denied

TYPE abap_bool.

DATA: lv_errormsg

TYPE string.

DATA: lv_flg

TYPE uj_flg.

FIELD-SYMBOLS: <lv_dim>

TYPE ANY.

FIELD-SYMBOLS: <ls_array>

TYPE ANY.

FIELD-SYMBOLS: <ls_message> TYPE uj0_s_message.

* If no user is supplied, do nothing.


IF is_user-user_id IS INITIAL.
RETURN.
ENDIF.

TRY.
* get user details, task profile, member profiles, teams.
lv_obj_id = is_user-user_id.
lo_user ?= cl_uje_user_mgr=>create_obj( i_appset_id
i_object_id

= i_appset_id
= lv_obj_id

i_object_type = 'CL_UJE_USER' ).
lo_user->get_details( IMPORTING es_details = ls_details ).
lt_mprof_id = ls_details-t_mprofile_id.
CATCH cx_static_check.

May 2010

21

How To... Use the Shared Query Engine Post Process BAdI

ENDTRY.

LOOP AT lt_mprof_id INTO ls_mprof_id.


* Get profile object
lv_obj_id = ls_mprof_id-profile_id.
lo_profile ?= cl_uje_user_mgr=>create_obj(

i_appset_id

= i_appset_id

i_object_id

= lv_obj_id

i_object_type = 'CL_UJE_PROFILE_MEMACCESS' ).
* Get memaccess data
REFRESH lt_memaccess_tmp .
lo_profile->get_memaccess( IMPORTING et_memaccess = lt_memaccess_tmp ).
APPEND LINES OF lt_memaccess_tmp

TO lt_memaccess.

ENDLOOP.

* describe CT_ARRAY
lo_tabdef ?= cl_abap_typedescr=>describe_by_data( ct_array ).
lo_datadef = lo_tabdef->get_table_line_type( ).
lo_strucdef ?= lo_datadef.

* Get appset model


lo_model = cl_uj_model=>get_model( i_appset_id ).
IF lo_model IS NOT BOUND.
RETURN.
ENDIF.

SORT lt_memaccess BY profile_id dimension ASCENDING.


ls_range-sign

= 'I'.

ls_range-option = 'EQ'.
CLEAR lv_priorprofileid.

LOOP AT lt_memaccess INTO ls_memaccess.

IF lv_priorprofileid IS INITIAL.
lv_priorprofileid = ls_memaccess-profile_id.
ELSEIF lv_priorprofileid NE ls_memaccess-profile_id.
* profile changed so add prior profile to profiles table
APPEND ls_profiles TO lt_profiles.
lv_priorprofileid = ls_memaccess-profile_id.
CLEAR ls_profiles.
ENDIF.

lv_tabix = sy-tabix.
ls_profiles-id = ls_memaccess-profile_id.

May 2010

22

How To... Use the Shared Query Engine Post Process BAdI

ls_profile-rwd = ls_memaccess-rwd.

AT NEW dimension.
lo_dim = lo_model->get_dim_data( i_dim_name = ls_memaccess-dimension ).
ls_profile-dimension = ls_memaccess-dimension.
ENDAT.

IF ls_memaccess-member NE '[ALL]'.
lo_hier = lo_dim->get_hier_of_mbr( i_member = ls_memaccess-member ).

IF lo_hier IS BOUND.
ls_range-low = ls_memaccess-member.
INSERT ls_range INTO TABLE ls_profile-access.
lv_flg =

lo_hier->check_base_member( i_member = ls_memaccess-member ).

IF lv_flg EQ abap_false. "This is a base member collect children


lo_hier->get_children( EXPORTING i_member
if_self

= ls_memaccess-member
= abap_false

if_only_base_mbr = abap_true
IMPORTING et_mbr_name

= lt_base_mems ).

LOOP AT lt_base_mems INTO lv_member.


ls_range-low = lv_member.
INSERT ls_range INTO TABLE ls_profile-access.
ENDLOOP.
ENDIF.

ELSE.
"ERROR
CLEAR ct_array.
CONCATENATE 'ERROR: get_hier_of_mbr ' ls_memaccess-member INTO lv_errormsg.
APPEND INITIAL LINE TO lt_messages ASSIGNING <ls_message>.
<ls_message>-msgid

= '00'.

<ls_message>-msgty

= 'E'.

<ls_message>-msgno

= '001'.

<ls_message>-msgv1

= lv_errormsg.

<ls_message>-message = cl_uj_utl_message=>get_message_text(
i_language = sy-langu

is_message = <ls_message> ).

et_message = lt_messages. " Return messages.


RETURN.
ENDIF.
ELSE.
ls_profile-all = abap_true.
ENDIF.

May 2010

23

How To... Use the Shared Query Engine Post Process BAdI

AT END OF dimension.
APPEND ls_profile TO ls_profiles-profile.
CLEAR ls_profile.
CLEAR lt_base_mems.
ENDAT.

ENDLOOP.

* final step add new profile to profiles table


IF NOT ls_profiles IS INITIAL.
APPEND ls_profiles TO lt_profiles.
ENDIF.

lv_access_denied = abap_false.
SORT lt_profiles BY id ASCENDING.

LOOP AT ct_array ASSIGNING <ls_array>.

lv_access_granted = abap_false.
LOOP AT lt_profiles INTO ls_profiles.

"RESET SUCCESS INDICATORS


CLEAR ls_profile.
MODIFY ls_profiles-profile FROM ls_profile TRANSPORTING success
WHERE success = abap_true.

"LOOP AT DIMENSIONS
LOOP AT ls_profiles-profile INTO ls_profile.
READ TABLE lo_strucdef->components
WITH KEY name = ls_profile-dimension TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
IF ls_profile-all = abap_true.
ls_profile-success = abap_true.
MODIFY ls_profiles-profile FROM ls_profile TRANSPORTING success.
CONTINUE.
ELSE.
ASSIGN COMPONENT ls_profile-dimension OF STRUCTURE <ls_array> TO <lv_dim>.
IF <lv_dim> IN ls_profile-access.
ls_profile-success = abap_true.
MODIFY ls_profiles-profile FROM ls_profile TRANSPORTING success.
CONTINUE.
ENDIF.
ENDIF.

May 2010

24

How To... Use the Shared Query Engine Post Process BAdI

ELSE.
ls_profile-success = abap_true.
MODIFY ls_profiles-profile FROM ls_profile TRANSPORTING success.
CONTINUE.
ENDIF.
ENDLOOP.

MOVE ls_profiles TO ls_profiles_tmp.


"WHEN FINISHED ANALYZING A MAP - CHECK IF IT SUCCEEDED
AT END OF id.
READ TABLE ls_profiles_tmp-profile
WITH KEY success = abap_false TRANSPORTING NO FIELDS.
IF sy-subrc NE 0. "ALL SUCCESS
lv_access_granted = abap_true.
EXIT.
ENDIF.
ENDAT.

ENDLOOP.

IF lv_access_granted EQ abap_false.
lv_access_denied = abap_true.
DELETE ct_array.
CONTINUE.
ENDIF.
ENDLOOP.

IF lv_access_denied = abap_true.
APPEND INITIAL LINE TO lt_messages ASSIGNING <ls_message>.
<ls_message>-msgid

= '00'.

<ls_message>-msgty

= 'E'.

<ls_message>-msgno

= '001'.

<ls_message>-msgv1

= 'Some values are rejected (authorization)'.

<ls_message>-message = cl_uj_utl_message=>get_message_text(
i_language = sy-langu

is_message = <ls_message> ).

ENDIF.

* Finally, export messages


et_message = lt_messages.

ENDMETHOD.

May 2010

25

www.sdn.sap.com/irj/sdn/howtoguides