how to use the shared query engine post process...

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

Upload: buihuong

Post on 11-Feb-2018

269 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

SAP BusinessObjects EPMHow-To Guide

How To... Use the Shared QueryEngine Post Process BAdI

Applicable Releases:

SAP BusinessObjects Planning and Consolidation 7.0 , version for SAPNetWeaver, SP04 and higher.

SAP BusinessObjects Planning and Consolidation 7.5 , version for SAPNetWeaver, SP00 and higher.

Version 1.0

May 2010

Page 2: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

© Copyright 2010 SAP AG. All rights reserved.

No part of this publication may be reproduced ortransmitted in any form or for any purpose without theexpress permission of SAP AG. The information containedherein may be changed without prior notice.

Some software products marketed by SAP AG and itsdistributors contain proprietary software components ofother software vendors.

Microsoft, Windows, Outlook, and PowerPoint areregistered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, OS/2, ParallelSysplex, 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 aretrademarks or registered trademarks of IBM Corporation.

Adobe, the Adobe logo, Acrobat, PostScript, and Readerare either trademarks or registered trademarks of AdobeSystems Incorporated in the United States and/or othercountries.

Oracle is a registered trademark of Oracle Corporation.

UNIX, X/Open, OSF/1, and Motif are registeredtrademarks of the Open Group.

Citrix, ICA, Program Neighborhood, MetaFrame,WinFrame, VideoFrame, and MultiWin are trademarks orregistered trademarks of Citrix Systems, Inc.

HTML, XML, XHTML and W3C are trademarks orregistered trademarks of W3C®, World Wide WebConsortium, 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 andimplemented by Netscape.

MaxDB is a trademark of MySQL AB, Sweden.

SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAPNetWeaver, and other SAP products and servicesmentioned herein as well as their respective logos aretrademarks or registered trademarks of SAP AG inGermany and in several other countries all over the world.All other product and service names mentioned are thetrademarks of their respective companies. Data containedin 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 affiliatedcompanies ("SAP Group") for informational purposes only,without representation or warranty of any kind, and SAPGroup shall not be liable for errors or omissions withrespect to the materials. The only warranties for SAPGroup products and services are those that are set forth inthe express warranty statements accompanying suchproducts and services, if any. Nothing herein should beconstrued as constituting an additional warranty.

These materials are provided “as is” without a warranty ofany kind, either express or implied, including but notlimited to, the implied warranties of merchantability,fitness for a particular purpose, or non-infringement.

SAP shall not be liable for damages of any kind includingwithout limitation direct, special, indirect, or consequentialdamages that may result from the use of these materials.

SAP does not warrant the accuracy or completeness of theinformation, text, graphics, links or other items containedwithin these materials. SAP has no control over theinformation that you may access through the use of hotlinks contained in these materials and does not endorseyour use of third party web pages nor provide any warrantywhatsoever relating to third party web pages.

SAP NetWeaver “How-to” Guides are intended to simplifythe product implementation. While specific productfeatures and procedures typically are explained in apractical business context, it is not implied that thosefeatures and procedures are the only approach in solving aspecific business problem using SAP NetWeaver. Shouldyou wish to receive additional information, clarification orsupport, please refer to SAP Consulting.

Any software coding and/or code lines / strings (“Code”)included in this documentation are only examples and arenot intended to be used in a productive systemenvironment. The Code is only intended better explain andvisualize the syntax and phrasing rules of certain coding.SAP does not warrant the correctness and completeness ofthe Code given herein, and SAP shall not be liable forerrors or damages caused by the usage of the Code, exceptif such damages were caused by SAP intentionally orgrossly negligent.

Disclaimer

Some components of this product are based on Java™. Anycode change in these components may cause unpredictableand severe malfunctions and is therefore expressivelyprohibited, as is any decompilation of these components.

Any Java™ Source Code delivered with this product is onlyto be used by SAP’s Support Services and may not bemodified or altered in any way.

Page 3: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

Document HistoryDocument Version Description

1.00 First official release of this guide

Page 4: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

Typographic ConventionsType Style Description

Example Text Words or characters quotedfrom the screen. Theseinclude field names, screentitles, pushbuttons labels,menu names, menu paths,and menu options.Cross-references to otherdocumentation

Example text Emphasized words orphrases in body text, graphictitles, and table titles

Example text File and directory names andtheir paths, messages,names of variables andparameters, source text, andnames of installation,upgrade and database tools.

Example text User entry texts. These arewords or characters that youenter in the system exactly asthey appear in thedocumentation.

<Exampletext>

Variable user entry. Anglebrackets indicate that youreplace these words andcharacters with appropriateentries to make entries in thesystem.

EXAMPLE TEXT Keys on the keyboard, forexample, F2 or ENTER.

IconsIcon Description

Caution

Note or Important

Example

Recommendation or Tip

Page 5: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

Table of Contents

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

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

3. Prerequisites....................................................................................................................2

4. Step-by-Step Procedure ..................................................................................................34.1 Create a BAdI Implementation ..................................................................................34.2 Test the BAdI Implementation ................................................................................. 14

5. Appendix ........................................................................................................................ 205.1 Source Code for BAdI Implementation .................................................................... 20

Page 6: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 1

1. Business Scenario

Note: This guide is not intended to assist in fully implementing a matrix security model in BPC. It isintended 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 associatedwith 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 individualdimension members and nodes. In this business scenario, the business wants to implement matrixtype 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 theUS.

Desired Security Personal Costs Advertising Costs

US X

EMEA X

Standard BPC Security cannot accomplish this task because Account and Entity are two differentdimensions. Giving a user access to Entity nodes US and EMEA and to account Personal andAdvertising Costs results in the user being able to see also Personal Costs in EMEA and AdvertisingCosts 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 valueslinked together from different dimensions( by “tuples” or vectors of member values from multipledimension ).

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 ofvalues, not an intersection, and thus the user will still be able to see all four values as shown in thefigure below.

Standard Security Personal Costs Advertising Costs

US

EMEA

To overcome this limitation of standard BPC security, this How-To Guide demonstrates how you canuse 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.

Page 7: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 2

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

2. Background Information

SAP Business Add-Ins (BAdIs) are one of the most important technologies used to adapt SAPsoftware 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 withouthaving to make core software modifications. As such, BAdI calls can be integrated into customerapplications (like BusinessObjects Planning and Consolidation, version for SAP NetWeaver forexample) to allow enhanced customization of standard application functionality.

This How-To Guide (HTG) describes the procedure for creating and configuring the Shared QueryEngine (SQE) BAdI to implement matrix or intersectional security within BPC. The Step By Stepsection will outline the steps needed in order to create the BAdI itself in addition to the configurationrequired within BPC to actually execute the BAdI. The Appendix section contains the example ABAPcode that goes along with this guide’s Business Scenario. This code is only meant as an example andwhile it will perform the actions described in this guide it may not match the exact needs of your ownparticular Business Scenario – it is only intended to guide you in the creation of your own BAdIImplementation.

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 KnowledgeTransfer -> SAP BusinessObjects EPM Solutions -> SAP BO PC 7.5, version for SAPNetWeaver

Other EPM How-To Guideshttp://wiki.sdn.sap.com/wiki/display/BPX/Enterprise+Performance+Management+%28EPM%29+How-to+Guides

SAP Help Library – Business Add Inshttp://help.sap.com/saphelp_nw70/helpdata/en/8f/f2e540f8648431e10000000a1550b0/frameset.htm

Page 8: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 3

4. Step-by-Step Procedure

A BAdI implementation is the term used in the Enhancement Framework for an enhancementimplementation element. A BAdI implementation consists of a BAdI implementation class thatimplements the BAdI interface. The BAdI implementation also contains a filter condition which isspecified in the BAdI definition. This filter condition can be used to execute the BAdI implementation atruntime.

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. EnterUJQ_SHARED_QUERY, and click “Display“.

Page 9: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 4

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

Interf

Interface Filter Implementations

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

Page 10: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 5

5. In some cases, a developer may have already created an enhancement implementation for thisenhancement spot for a different BAdI definition. If an enhancement implementation alreadyexists, a dialog listing all implementations will be displayed. Click the “Create” button in thelower 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 yourlandscape, or click “Local Object” if you do not plan to transport this BAdI.

Page 11: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 6

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

9. In this dialog, enter the name of the BAdI Implementation asZUJ_SQE_POST_PROCESS_EX_IMP, and enter the description. Also, enter the name of theimplementing class as ZCL_UJQ_POST_PROCESS_EX.

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

Page 12: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 7

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 followingnodes below.

Implementing Class Filter Values

Page 13: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 8

13. Double click on the “Filter Val.” Node.

14. Click the “Change” icon.

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

Page 14: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 9

16. Select both APPSET_ID and APPLICATION_ID, or click the “Select All” button, and then clickthe “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.

Page 15: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 10

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 implementationwill 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.

Page 16: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 11

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

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

Page 17: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 12

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 onthe “Change” icon. Then double-click on the POST_PROCESS method.

26. An empty method implementation will be shown. Notice, the method signature is displayed atthe top. If the method signature is not displayed, click the “Signature” button on the applicationtoolbar.

Page 18: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 13

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.

Page 19: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 14

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

P_CC \P_ACCT CE0004000 CE0004200

US X

EMEA X

Within the matrix security model, which has been implemented by the BAdI implementation, the usershould receive an error if he tries to view data under US for account CE0004200. The followingscreenshots show how the member access profiles are set up.

Member Access Profile: US_MAP

Member Access Profile: EMEA_MAP

Page 20: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 15

The image below shows what a report would look like for CC_MGR user with both member accessprofiles, if the standard BPC security model is used and not the matrix security model implemented bythe BAdI. Notice that the two member access profiles are “unioned” together. As a result all fourvalues 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 correctsecurity model, for example CC_MGR. In this example, a copy of APSHELL calledAPSHELL_HTG is used. In the previous steps we implemented the the matrix security modelvia 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) toPersonal Costs(CE0004000). Remember, the CC_MGR user currently has authorization to boththe US_MAP and EMEA_MAP member access profiles. The matrix security model implementedin the BAdI will further restrict this member access.

Page 21: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 16

2. From the action pane, click on “Report & Analysis”. We are going to recreate the report shownabove.

3. Next, click on “Open a blank workbook”.

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

Page 22: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 17

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 andclicking the appropriate arrow button. Next, move the P_CC dimension to the “In columns” boxby selecting P_CC from the box on the left and clicking the appropriate arrow button. Then click“Ok”.

Page 23: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 18

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 theimage below. This will force the report to show these intersections.

Page 24: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 19

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 securityimplementation.

Page 25: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 20

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 uje_t_profile_id.

DATA: ls_mprof_id TYPE uje_s_profile_id_act.

DATA: lt_messages TYPE uj0_t_message.

DATA: ls_memaccess TYPE uje_s_memaccess.

Page 26: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 21

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_appset_id

i_object_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.

Page 27: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 22

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.

Page 28: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 23

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 = ls_memaccess-member

if_self = 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.

Page 29: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 24

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.

Page 30: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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

May 2010 25

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.

Page 31: How To Use the Shared Query Engine Post Process BAdIa248.g.akamai.net/n/248/420835/74e2b4b1579357edfd16b59fab25b6e1… · Use the Shared Query Engine Post Process BAdI ... 4.1 Create

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