12
SAP NetWeaver How-To Guide How to... Build a Planning Function that Deletes Comments in BW Applicable Releases: SAP NetWeaver BW 7.01 Topic Area: Business Information Management Version 1.0 July 2012

How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

  • Upload
    others

  • View
    40

  • Download
    2

Embed Size (px)

Citation preview

Page 1: How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

SAP NetWeaver

How-To Guide

SAP NetWeaver

How-To Guide

How to... Build a Planning Function

that Deletes Comments in BW

Applicable Releases:

SAP NetWeaver BW 7.01

Topic Area:

Business Information Management

Version 1.0

July 2012

Page 2: How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

© Copyright 2012 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 SAP’s Support Services and may not be

modified or altered in any way.

Page 3: How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

Document History

Document Version Description

1.00 First official release of this guide

Page 4: How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

Typographic Conventions

Type Style Description

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.

Icons

Icon Description

Caution

Note or Important

Example

Recommendation or Tip

Page 5: How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

How to... Build a Planning Function that Deletes Comments in BW

October 2012 1

Table of Contents

1. Scenario ................................................................................................................................ 2

2. General Description of the Solution .................................................................................. 2

3. Create an Example in the System ...................................................................................... 2

3.1 Create the Class for the Plan Function......................................................................... 2

3.2 Create the Planning Function Type .............................................................................. 3

3.3 Create and Test a Planning Function ........................................................................... 4

4. Appendix .............................................................................................................................. 5

4.1 Method INIT_EXECUTION ........................................................................................... 5

4.2 Method EXECUTION .................................................................................................... 5

Page 6: How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

How to... Build a Planning Function that Deletes Comments in BW

October 2012 2

1. Scenario

In How to Paper…Build a Fast and Flexible Comment Solution for BEx Web Applications ( see

http://scn.sap.com/docs/DOC-16133) we have introduced a concept for comments in SAP NetWaver

BW BEx Web applications.

In the current paper we introduce a planning function that can be used to delete records together with

the comments create with the above mentioned solution.

2. General Description of the Solution

In our paper we describe how to create a planning function that deletes records together with the

corresponding comments. Thus this planning function can only be used on a realtim InfoCube and the

current solution is not suitable for mass deletion of comments in a pure reporting scenario.

In our planning function we assume that we only have comments for existing records and thus use the

existing records to determine the key for the comments to be deleted. Thus our planning function

would for example not delete comments on totals level. You have different options to solve this

situation:

Do not use comments on (sub-)totals (see remark in How to Paper…Build a Fast and Flexible

Comment Solution for BEx Web Applications)

Adapt the coding of the planning function in such a way that for each possible combination in

the selection there is an entry in the table <l_to_comments>.

In some cases you might as well execute the planning function again on a level of aggregation

with fewer characteristics (and thus logically being the level of aggregation of the total).

The planning function can be used in BW-IP as well as in PAK. Please remember that the planning

function does not store the deletion of the records but only updates the comment buffer. Thus also a

save for the comments has to be executed before leaving the application (see How to Paper…Build a

Fast and Flexible Comment Solution for BEx Web Applications)

3. Create an Example in the System

In this chapter we describe how the necessary underlying objects are creates in the backend. The

source code can be found in the appendix.

3.1 Create the Class for the Plan Function

Please go to transaction se24 and create a new class called ‘ZCL_DEL_COM’. Include the following

two interfaces:

IF_RSPLFA_SRVTYPE_IMP_CHECK

IF_RSPLFA_SRVTYPE_IMP_EXEC.

Page 7: How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

How to... Build a Planning Function that Deletes Comments in BW

October 2012 3

On the attributes tab create the attribute ‘G_R_INFOPROV_DESC’ of type ref to

‘IF_RSPLFA_INFOPROV_DESC’ as shown in the screen shot.

Now go to the methods tab. Please implement the methods

IF_RSPLFA_SRVTYPE_IMP_EXEC~INIT_EXECUTION and

IF_RSPLFA_SRVTYPE_IMP_EXEC~EXECUTE using the coding from the appendix. All other methods

should only have a trivial implementation just containing the statement ‘exit.’.

When done please activate the class.

3.2 Create the Planning Function Type

Now we create the new planning function type. Call transaction RSPLAN and then the button ‘Maintain

Function Type’.

Enter the name of the new planning function type (here ‘Z_DEL_COM’) and choose the button

‘Create’.

Enter a description for the planning function type and paste the name of the class you just have

created. Also set the flag ‘Process empty records’ and the flag ‘Hide Column of Chars. To Be

Changed’.

Page 8: How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

How to... Build a Planning Function that Deletes Comments in BW

October 2012 4

You do not have to enter anything on the parameter tab.

Now activate your planning function type. The new planning function type can now be used.

3.3 Create and Test a Planning Function

Please go to the transaction RSPLAN and create a new planning function on the aggregation level

used for your planning. In BW 7.30 you can also do this via RSA1.

Page 9: How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

How to... Build a Planning Function that Deletes Comments in BW

October 2012 5

Our delete function follows the same logic as the standard delete function. You cannot specify any

fields to be changed (as it is not necessary) but you can create some conditions.

Now you can either test the planning function in a planning sequence or use it in a planning

application in the web.

4. Appendix

4.1 Method INIT_EXECUTION

METHOD IF_RSPLFA_SRVTYPE_IMP_EXEC~INIT_EXECUTION.

g_r_infoprov_desc = i_r_infoprov_desc.

ENDMETHOD.

4.2 Method EXECUTION

method IF_RSPLFA_SRVTYPE_IMP_EXEC~EXECUTE.

DATA: l_partprov type rsinfoprov,

l_partprov2 type rsinfoprov.

DATA: l_r_to_comments_line TYPE REF TO data,

l_r_s_comments_line TYPE REF TO data,

l_r_datadesc TYPE REF TO cl_abap_datadescr,

l_handle TYPE GUID_32,

l_t_kyfnm type RSPLF_T_KEYFNM,

l_kyf type RSIOBJNM,

l_t_charnm type RSPLF_T_charNM,

l_char type RSIOBJNM,

l_fieldname TYPE FIELDNAME.

FIELD-SYMBOLS: <l_to_comments> TYPE INDEX TABLE,

<l_s_comments> TYPE ANY.

FIELD-SYMBOLS: <s_data> TYPE ANY,

<ratio> TYPE ANY,

<kyfnm> type any,

<value1> type any,

<value2> type any.

* get the name of the single infoprovider

CALL METHOD G_R_INFOPROV_DESC->GET_INFOPROV

RECEIVING

R_INFOPROV = l_partprov.

* get the list of key figures

CALL METHOD G_R_INFOPROV_DESC->GET_T_KEYFNM

RECEIVING

R_T_KEYFNM = l_t_kyfnm.

* get the list of characteristics

Page 10: How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

How to... Build a Planning Function that Deletes Comments in BW

October 2012 6

CALL METHOD g_r_infoprov_desc->get_t_charnm

RECEIVING

R_T_CHARNM = l_t_charnm.

* check the infoprov

CALL FUNCTION 'Z_RETURN_PARTPROV'

EXPORTING

i_infoprov = l_partprov

IMPORTING

e_partprov = l_partprov2

EXCEPTIONS

not_unique = 1

OTHERS = 2.

IF sy-subrc <> 0.

* we are not on a single infoprov and cannot go on

* send an error

exit.

ENDIF.

* Get Structure and Table Types

CALL FUNCTION 'Z_CREATE_DATAREF'

EXPORTING

i_infoprov = l_partprov2

i_type = zco_tt_comments_line

IMPORTING

e_o_datadesc = l_r_datadesc.

CREATE DATA l_r_to_comments_line TYPE HANDLE l_r_datadesc.

ASSIGN l_r_to_comments_line->* TO <l_to_comments>.

CALL FUNCTION 'Z_CREATE_DATAREF'

EXPORTING

i_infoprov = l_partprov2

i_type = zco_ty_comments_line

IMPORTING

e_o_datadesc = l_r_datadesc.

CREATE DATA l_r_s_comments_line TYPE HANDLE l_r_datadesc.

ASSIGN l_r_s_comments_line->* TO <l_s_comments>.

* get the handle for the comments

CALL FUNCTION 'Z_RETURN_HANDLE'

IMPORTING

E_HANDLE = l_handle.

* go over the data records -

delete the existing records and fill the comemnts table

LOOP AT c_th_data ASSIGNING <s_data>.

* fill all characteristics into the comemnts structure

loop at l_t_charnm into l_char.

CALL FUNCTION 'Z_COMNTS_FIELDS_CONVERT'

EXPORTING

I_IOBJNM = l_char

IMPORTING

Page 11: How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

How to... Build a Planning Function that Deletes Comments in BW

October 2012 7

E_FIELDNAME = l_fieldname.

ASSIGN COMPONENT l_char of structure <s_data> to <value1>.

if sy-subrc <> 0.

continue.

endif.

ASSIGN COMPONENT l_fieldname of STRUCTURE <l_s_comments> to <value2>.

if sy-subrc <> 0.

continue.

endif.

* we have a special treatment for initial value in comment DB

if zco_use_hash is not initial and <value1> = ' '.

<value2> = '#'.

else.

<value2> = <value1>.

endif.

endloop.

* delete and fill in the key figures

LOOP AT l_t_kyfnm INTO l_kyf.

assign component l_kyf of structure <s_data> to <ratio>.

clear <ratio>.

* now fill the comment table structure

assign component 'KYFNM' of STRUCTURE <l_s_comments> to <kyfnm>.

<kyfnm> = l_kyf.

insert <l_s_comments> INTO table <l_to_comments>.

ENDLOOP.

ENDLOOP.

* delete the comments

CALL FUNCTION 'Z_DELETE_COMMENTS'

EXPORTING

I_TO_COMMENTS = <l_to_comments>

I_HANDLE = l_handle

I_INFOPROV = l_partprov2.

endmethod.

Page 12: How to Build a Planning Function that Deletes Comments in BWa248.g.akamai.net/n/248/420835/59fc86a0e8cbbee7d6cf4aad4db9ee41b2072e… · SAP NetWeaver How-To Guide SAP NetWeaver How-To

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