Built a Plannign Function Copy

Download as pdf or txt
Download as pdf or txt
You are on page 1of 90

H o w t o ...

B u i l d a Pl a n n i n g Fu n c t i o n
t h a t Co p i e s Co m m e n t s a n d Da t a
Re c o r d s i n B W

A p p l i c a b l e Re l e a s e s :
SA P N e t We a v e r B W 7 .0 1 a n d h i g h e r

Topic Area:
B u s i n e s s I n f o r m a t i o n Ma n a g e m e n t

V e r s i o n 1 .0
Novem ber 2012
© Copyright 2012 SAP AG. All rights reserved. These materials are subject to change without notice.
No part of this publication may be reproduced or These materials are provided by SAP AG and its affiliated
transmitted in any form or for any purpose without the companies ("SAP Group") for informational purposes only,
express permission of SAP AG. The information contained without representation or warranty of any kind, and SAP
herein may be changed without prior notice. Group shall not be liable for errors or omissions with
Some software products marketed by SAP AG and its respect to the materials. The only warranties for SAP
distributors contain proprietary software components of Group products and services are those that are set forth in
other software vendors. the express warranty statements accompanying such
products and services, if any. Nothing herein should be
Microsoft, Windows, Outlook, and PowerPoint are
construed as constituting an additional warranty.
registered trademarks of Microsoft Corporation.
These materials are provided “as is” without a warranty of
I BM, DB2, DB2 Universal Database, OS/ 2, Parallel
any kind, either express or implied, including but not
Sysplex, M VS/ ESA, AI X, S/ 390, AS/ 400, OS/ 390,
limited to, the implied warranties of merchantability,
OS/ 400, iSeries, pSeries, xSeries, zSeries, z/ OS, AFP,
fitness for a particular purpose, or non-infringement.
I ntelligent Miner, WebSphere, Netfinity, Tivoli, I nformix,
i5/ OS, POWER, POWER5, OpenPower and PowerPC are SAP shall not be liable for damages of any kind including
trademarks or registered trademarks of I BM Corporation. without limitation direct, special, indirect, or consequential
damages that may result from the use of these materials.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader
are either trademarks or registered trademarks of Adobe SAP does not warrant the accuracy or completeness of the
Systems I ncorporated in the United States and/ or other information, text, graphics, links or other items contained
countries. within these materials. SAP has no control over the
information that you may access through the use of hot
Oracle is a registered trademark of Oracle Corporation.
links contained in these materials and does not endorse
UNI X, X/ Open, OSF/ 1, and Motif are registered
your use of third party web pages nor provide any warranty
trademarks of the Open Group.
whatsoever relating to third party web pages.
Citrix, I CA, Program Neighborhood, MetaFrame,
SAP NetWeaver “How-to” Guides are intended to simplify
WinFrame, VideoFrame, and MultiWin are trademarks or
the product implementation. While specific product
registered trademarks of Citrix Systems, I nc.
features and procedures typically are explained in a
HTML, XM L, XH TML and W3C are trademarks or practical business context, it is not implied that those
registered trademarks of W3C® , World Wide Web features and procedures are the only approach in solving a
Consortium, Massachusetts I nstitute of Technology. specific business problem using SAP NetWeaver. Should
Java is a registered trademark of Sun Microsystems, I nc. you wish to receive additional information, clarification or
JavaScript is a registered trademark of Sun Microsystems, support, please refer to SAP Consulting.
I nc., used under license for technology invented and Any software coding and/ or code lines / strings (“Code”)
implemented by Netscape. included in this documentation are only examples and are
MaxDB is a trademark of MySQL AB, Sweden. not intended to be used in a productive system
SAP, R/ 3, mySAP, mySAP.com, xApps, xApp, SAP environment. The Code is only intended better explain and
NetWeaver, and other SAP products and services visualize the syntax and phrasing rules of certain coding.
mentioned herein as well as their respective logos are SAP does not warrant the correctness and completeness of
trademarks or registered trademarks of SAP AG in the Code given herein, and SAP shall not be liable for
Germany and in several other countries all over the world. errors or damages caused by the usage of the Code, except
All other product and service names mentioned are the if such damages were caused by SAP intentionally or
trademarks of their respective companies. Data contained grossly negligent.
in this document serves informational purposes only. Disclaimer
National product specifications may vary. 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.
Do c u m e n t H i s t o r y
Document Version Description

1.00 First official release of this guide


T y p o g r a p h i c Co n v e n t i o n s Ic ons
Type Style Description Icon Description
Example Text Words or characters quoted Caution
from the screen. These
include field names, screen Note or Important
titles, pushbuttons labels, Example
menu names, menu paths,
and menu options. Recommendation or Tip
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 Variable user entry. Angle
text> 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.
How to... Build a Planning Function that Copies Comments and Data Records in BW

T a b l e o f Co n t e n t s
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 .............................................................................. 5
3.3 Create and Test a Planning Function ........................................................................... 9

4. Appendix ............................................................................................................................ 10
How to... Build a Planning Function that Copies Comments and Data Records in BW

1. Sc e n a r i o
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 a second paper we have described a planning function that can be used
to delete records together with the comments created with the above mentioned solution (see
https://scn.sap.com/docs/DOC-30197).
In the current paper we now introduce a planning function that can be used to copy data records
together with the comments created with the comment solution.

2. Ge n e r a l De s c r i p t i o n o f t h e So l u t i o n
In our paper we describe how to create a planning function that copies records together with the
corresponding comments. Thus this planning function can only be used on a realtime InfoCube and
the current solution is not suitable for mass copying of comments in a pure reporting scenario.
As with the delete function in the above mentioned How to Paper we assume that we only have
comments for existing records and use the existing records to determine the key for the comments to
be copied. Thus our planning function would for example not copy 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. But as we need a list of all existing
records in order to determine the selection for the comments we cannot execute the planning function
in memory. Thus when using this planning function in PAK the planning function itself would run but
would be executed in ABAP.
Please remember that the planning function does not store the copied comments 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. Cr e a t e a n Ex a m p l e i n t h e Sy s t e m
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 Cr e a t e t h e Cl a s s f o r t h e Pl a n Fu n c t i o n
Please go to transaction se24 (or transaction se80) and create a new class called ‘ZCL_COPY_COM’ .
If you are in a BW 7.30 system you can easily copy and paste the class with all properties and
methods and their implementations.
Switch to the source code based mode of the class.
How to... Build a Planning Function that Copies Comments and Data Records in BW

You now can simply copy and paste the class definition with all its coding from the appendix.
When you are done just switch back to the form-based (normal) mode and activate the class.

If you are working on an earlier version on SAP NetWeaver BW you have to create the single
components of the class individually:

Include the following three interfaces:


IF_RSPLFA_SRVTYPE_IMP_CHECK,
IF_RSPLFA_SRVTYPE_IMP_EXEC,
IF_RSPLFA_SRVTYPE_TREX_EXEC_R.
How to... Build a Planning Function that Copies Comments and Data Records in BW

On the attributes tab create the attribute ‘P_TH_KYF’ of type ‘RSPLF_TH_IOBJ’ as shown in the
screen shot.

Now go to the methods tab. Please implement the following methods:


IF_RSPLFA_SRVTYPE_TREX_EXEC_R~INIT_AND_CHECK
IF_RSPLFA_SRVTYPE_TREX_EXEC_R~TREX_EXECUTE
IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~INIT_EXECUTION
IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~GET_REF_DATA_SEL
IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~ADD_NEW_BLOCKS
IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~EXECUTE
IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~FINISH_EXECUTION
IF_RSPLFA_SRVTYPE_IMP_CHECK~INIT_CHECK
IF_RSPLFA_SRVTYPE_IMP_CHECK~CHECK_CHAR_USAGE
IF_RSPLFA_SRVTYPE_IMP_CHECK~CHECK_PARAM_SET
CREATE_TO_VALUES
COPY_TO_VALUES
CREATE_RULES
MSG_WITH_CONTEXT
How to... Build a Planning Function that Copies Comments and Data Records in BW

The coding can be found in the appendix. Please scroll to the part starting with
‘CLASS ZCL_COPY_COM I MPLEMENTATI ON. ’ Here you can find the different methods with their
implementation and interface definition.
Please activate the class once you have done the implementation.

3 .2 Cr e a t e t h e Pl a n n i n g Fu n c t i o n T y p e
Now we create the new planning function type. Call transaction RSPLAN, choose ‘Goto’ from the
menu, and then select ‘Maintain Planning Function Types’.

Enter the name of the new planning function type (here ‘Z_COPY_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 following flags ‘Reference Data’, ‘Process empty records’, and ‘Hierarchy Nodes
Selections Supported’.
How to... Build a Planning Function that Copies Comments and Data Records in BW

Now switch to the parameter tab. We create the same parameters as the standard copy function
(function type 0RSPL_COPY).
Click on ‘Parameter’ and choose ‘Create Parameter’ from the context menu. First create a parameter
for the key figure selection. Please choose the settings as shown in the screen shot:

Now we create the ‘From-‘table which specifies the selection the planning function is copying from.

Again use the context menu to create a new parameter. The settings can be taken from the screen
shot.
How to... Build a Planning Function that Copies Comments and Data Records in BW

Now use the context menu on the newly created parameter to create the different fields in the
structure. Use the context menu ‘Create Component’ for this. Create two parameter fields as shown in
the two screen shots:

We now need to create a table for the targets of the copy function. Create a new structural parameter
for this table
How to... Build a Planning Function that Copies Comments and Data Records in BW

Within this structure create two components as shown below:

The final result should look like follows:


How to... Build a Planning Function that Copies Comments and Data Records in BW

You can now go ahead and activate the planning function type. The new planning function type can
now be used.

3 .3 Cr e a t e a n d T e s t a Pl a n n i n g Fu n c t i o n

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.

The copy function follows the same logic as the standard copy function and will copy the records in the
very same way. In addition it will also copy the corresponding comments.
Now you can either test the planning function in a planning sequence or use it in a planning
application in the web.
How to... Build a Planning Function that Copies Comments and Data Records in BW

4. Appendix
class ZCL_COPY_COM definition
public
create public .

public section.
*"* public components of class ZCL_COPY_COM
*"* do not include other source files here!!!

interfaces IF_RSPLFA_SRVTYPE_IMP_CHECK .
interfaces IF_RSPLFA_SRVTYPE_IMP_EXEC_REF .
interfaces IF_RSPLFA_SRVTYPE_TREX_EXEC_R .

class-methods CREATE_TO_VALUES
importing
!I_T_CHARSEL type RSPLF_T_CHARSEL
!I_TH_CHA type RSPLF_TH_IOBJ
!I_R_MSG type ref to IF_RSPLFA_MSG
returning
value(R_T_CHARSEL) type RSPLF_T_CHARSEL .
class-methods COPY_TO_VALUES
importing
value(I_INDEX) type I
!I_R_STORE_MANAGER type ref to CL_RSPLS_SESSION_STORE_MANAGER
!I_TH_CHA type RSPLF_TH_IOBJ
!I_TH_REQ_C type RSPLS_TH_REQ_C
!I_T_CHARSEL type RSPLF_T_CHARSEL
!I_VIEW_REF type TREXD_PLAN_VIEW
value(I_TH_ATTR_CONST_MAPPING) type TREXT_MAP_ATTRIBUTE_CONST
changing
!C_BASE_VIEW type TREXD_PLAN_VIEW
raising
CX_RS_FAILED .
protected section.
*"* protected components of class ZCL_COPY_COM
*"* do not include other source files here!!!

types:
BEGIN OF t_s_rule,
rulepos TYPE rsplf_rulepos,
seqnr TYPE rsplf_seqnr,
t_from_sel TYPE rspls_ts_sel,
t_to_sel TYPE rspls_ts_sel,
tsx_seldr_repr_of_to type rsdd_tsx_seldr,
to_sel_is_single type rs_bool,
index_from TYPE i,
index_local_to type i,
r_work_area TYPE REF TO cl_rsplfu_work_area,
END OF t_s_rule .
types:
How to... Build a Planning Function that Copies Comments and Data Records in BW

t_ts_rule TYPE SORTED TABLE OF t_s_rule WITH NON-


UNIQUE KEY rulepos seqnr .

data P_R_TH_CHAS type ref to DATA .


data P_T_CHAR_USAGE type RSPLF_T_CHAR_USAGE .
data P_INFOPROV type RSINFOPROV .
data P_TS_RULE type T_TS_RULE .
data P_R_OBJECT_CREATION type ref to CL_RSPLFC_OBJECT_CREATION .

methods CREATE_RULES
importing
!I_R_MSG type ref to IF_RSPLFA_MSG_PARAM_CHECK
!I_R_PARAM_SET type ref to IF_RSPLFA_PARAM_SET
returning
value(R_TS_RULE) type T_TS_RULE .
methods MSG_WITH_CONTEXT
importing
!I_R_MSG_SRC type ref to CL_RSPLFU_MSG
!I_S_RULE type T_S_RULE
changing
!C_R_MSG_TRGT type ref to CL_RSPLFU_MSG .
private section.
*"* private components of class ZCL_COPY_COM
*"* do not include other source files here!!!

data P_R_SRV type ref to IF_RSPLFA_SRV .


data P_T_CHARSEL type RSPLF_T_CHARSEL .
data P_X_SOURCE_CHECK type XSTRING .
data P_X_TARGET_CHECK type XSTRING .
data P_X_SOURCE_CREATE type XSTRING .
data P_X_TARGET_CREATE type XSTRING .
data P_TH_KYF type RSPLF_TH_IOBJ .

TYPE-POOLS: rsdm, ZCO, RZX0.


ENDCLASS.

CLASS ZCL_COPY_COM IMPLEMENTATION.

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Static Public Method ZCL_COPY_COM=>COPY_TO_VALUES
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_INDEX TYPE I
* | [---
>] I_R_STORE_MANAGER TYPE REF TO CL_RSPLS_SESSION_STORE_MANAGE
R
* | [--->] I_TH_CHA TYPE RSPLF_TH_IOBJ
How to... Build a Planning Function that Copies Comments and Data Records in BW

* | [--->] I_TH_REQ_C TYPE RSPLS_TH_REQ_C


* | [--->] I_T_CHARSEL TYPE RSPLF_T_CHARSEL
* | [--->] I_VIEW_REF TYPE TREXD_PLAN_VIEW
* | [---
>] I_TH_ATTR_CONST_MAPPING TYPE TREXT_MAP_ATTRIBUTE_CONST
* | [<-->] C_BASE_VIEW TYPE TREXD_PLAN_VIEW
* | [!CX!] CX_RS_FAILED
* +------------------------------------------------------------------------
--------------</SIGNATURE>
method COPY_TO_VALUES.
raise exception type cx_rsr_x_message
exporting
text = 'COPY_TO_VALUES-01-'.
endmethod.

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Instance Protected Method ZCL_COPY_COM->CREATE_RULES
* +------------------------------------------------------------------------
-------------------------+
* | [---
>] I_R_MSG TYPE REF TO IF_RSPLFA_MSG_PARAM_CHECK
* | [--->] I_R_PARAM_SET TYPE REF TO IF_RSPLFA_PARAM_SET
* | [<-()] R_TS_RULE TYPE T_TS_RULE
* +------------------------------------------------------------------------
--------------</SIGNATURE>
METHOD CREATE_RULES.
DATA: l_s_rule TYPE t_s_rule,
l_t_from_tab TYPE rsplfa_t_param_struc,
l_r_from_tab_wa TYPE REF TO if_rsplfa_param_struc,
l_t_to_tab TYPE rsplfa_t_param_struc,
l_r_to_tab_wa TYPE REF TO if_rsplfa_param_struc,
l_r_param_sel TYPE REF TO if_rsplfa_param_data_sel,
l_r_param_elem TYPE REF TO if_rsplfa_param_elem,
l_r_param_keyf_sel TYPE REF TO if_rsplfa_param_keyf_sel,
l_t_keyfnm TYPE rsplf_t_keyfnm,
l_iobjnm TYPE rsiobjnm,
l_t_charsel TYPE rsplf_t_charsel,
l_th_iobj TYPE rsplf_th_iobj,
l_s_iobjnm TYPE rsplf_s_iobjnm,
l_infoprov TYPE rsinfoprov,
l_seqnr LIKE l_s_rule-seqnr,
l_old_seqnr LIKE l_s_rule-seqnr,
l_rulepos TYPE rsplf_rulepos,
l_index TYPE i,
l_index_local_to TYPE i,
l_dummy TYPE c, "#EC NEEDED
l_bool TYPE rsbool,
l_s_sel TYPE rspls_s_sel,
l_s_rng TYPE rspls_s_rng,
l_s_char_usage TYPE rsplf_s_char_usage.
How to... Build a Planning Function that Copies Comments and Data Records in BW

FIELD-SYMBOLS: <s_rule> TYPE t_s_rule.

l_rulepos = i_r_param_set->get_rulepos( ).
l_t_from_tab = i_r_param_set->get_tab_param_struc( 'FROMTAB' ).

l_r_param_keyf_sel = i_r_param_set->get_param_keyf_sel( 'KYFSEL' ).


l_t_keyfnm = l_r_param_keyf_sel->get_t_keyfnm( ).
CLEAR l_th_iobj.
LOOP AT l_t_keyfnm INTO l_iobjnm.
l_s_iobjnm-iobjnm = l_iobjnm.
INSERT l_s_iobjnm INTO TABLE l_th_iobj.
ENDLOOP.
l_infoprov = p_r_srv->get_infoprov( ).

IF LINES( l_th_iobj ) = 0.
* Bitte Kennzahlen auswählen
MESSAGE e031(rsplf) INTO l_dummy.
i_r_msg->add_msg_with_param_context( i_parnm = 'KYFSEL' ).
ENDIF.

CLEAR l_s_rule.
CLEAR l_index.
LOOP AT l_t_from_tab INTO l_r_from_tab_wa.
l_index = l_index + 1.
l_s_rule-rulepos = l_rulepos.
l_s_rule-index_from = l_index.
l_r_param_sel = l_r_from_tab_wa->get_comp_data_sel( 'FROMSEL' ).
l_t_charsel = l_r_param_sel->get_t_sel( ).
l_s_rule-t_from_sel = cl_rsplfu_charsel=>charsel_2_sel( l_t_charsel ).
l_r_param_elem = l_r_from_tab_wa->get_comp_elem( 'FROMSEQNR' ).
l_r_param_elem->get_value( IMPORTING e_value = l_s_rule-seqnr ).
l_s_rule-
r_work_area = cl_rsplfu_work_area=>instance_get( i_infoprov = l_infoprov
i_th_iobj = l
_th_iobj ).
INSERT l_s_rule INTO TABLE r_ts_rule.
ENDLOOP.

l_t_to_tab = i_r_param_set->get_tab_param_struc( 'TOTAB' ).


CLEAR l_index.
LOOP AT l_t_to_tab INTO l_r_to_tab_wa.
l_index = l_index + 1.
l_r_param_elem = l_r_to_tab_wa->get_comp_elem( 'TOSEQNR' ).
l_r_param_elem->get_value( IMPORTING e_value = l_seqnr ).
IF l_index = 1 OR l_seqnr <> l_old_seqnr.
l_index_local_to = 1.
ELSE.
l_index_local_to = l_index_local_to + 1.
ENDIF.
l_old_seqnr = l_seqnr.
CLEAR l_s_rule.
How to... Build a Planning Function that Copies Comments and Data Records in BW

READ TABLE r_ts_rule INTO l_s_rule WITH KEY rulepos = l_rulepos


seqnr = l_seqnr.
IF sy-subrc <> 0.
* Bitte Von-Werte pflegen
MESSAGE e032(rsplf) INTO l_dummy.
i_r_msg-
>add_msg_with_param_context( i_parnm = 'TOSEL' i_param_indx = l_index ).
l_s_rule-rulepos = l_rulepos.
l_s_rule-seqnr = l_seqnr.
ENDIF.
l_r_param_sel = l_r_to_tab_wa->get_comp_data_sel( 'TOSEL' ).
l_t_charsel = l_r_param_sel->get_t_sel( ).
l_s_rule-index_local_to = l_index_local_to.
IF l_index_local_to = 1.
l_s_rule-t_to_sel = cl_rsplfu_charsel=>charsel_2_sel( l_t_charsel ).
MODIFY TABLE r_ts_rule FROM l_s_rule.
ELSE.
l_s_rule-t_to_sel = cl_rsplfu_charsel=>charsel_2_sel( l_t_charsel ).
INSERT l_s_rule INTO TABLE r_ts_rule.
ENDIF.
ENDLOOP.

* ---- convert to_selections to seldr representation and set flag,


* if to selection is restricted to single value on every changing char.
* --> if yes, we can use check_combination instead of create_combination.
* this is faster.
LOOP AT r_ts_rule ASSIGNING <s_rule>.
cl_rsplfc_object_creation_cr=>charsel_to_seldr(
EXPORTING i_ts_charsel = <s_rule>-
t_to_sel
IMPORTING e_tsx_seldr = <s_rule>-
tsx_seldr_repr_of_to ).
CLEAR l_th_iobj.
l_bool = abap_true.
* .... if one of the changing chars is not contained in the to_sel => not
single, proceed with next rule.
LOOP AT p_t_char_usage INTO l_s_char_usage WHERE is_chng_char = abap_tr
ue.
READ TABLE <s_rule>-
t_to_sel INTO l_s_sel WITH KEY chanm = l_s_char_usage-charnm.
IF sy-subrc <> 0.
l_bool = abap_false.
EXIT. "loop
ENDIF.
ENDLOOP.
IF l_bool = abap_false.
<s_rule>-to_sel_is_single = abap_false.
continue. "next rule
ENDIF.

* .... check if to_sel restricts all chars to single


LOOP AT <s_rule>-t_to_sel INTO l_s_sel.
How to... Build a Planning Function that Copies Comments and Data Records in BW

* more than one entries for a char?


READ TABLE l_th_iobj INTO l_s_iobjnm WITH KEY iobjnm = l_s_sel-chanm.
IF sy-subrc = 0.
l_bool = abap_false.
EXIT.
ENDIF.
* is the entry unrestricted or has multiple lines?
IF LINES( l_s_sel-t_rng ) = 0 OR LINES( l_s_sel-t_rng ) > 1.
l_bool = abap_false.
EXIT.
ENDIF.
* is the first entry not a restriction to single value?
LOOP AT l_s_sel-t_rng INTO l_s_rng.
IF l_s_rng-sign = rs_c_range_sign-including
AND l_s_rng-opt = rs_c_range_opt-equal.
EXIT.
ELSE.
l_bool = abap_false.
EXIT.
ENDIF.
ENDLOOP.
IF l_bool = abap_false.
EXIT.
ENDIF.
ENDLOOP.
IF sy-subrc <> 0.
l_bool = abap_false.
ENDIF.
<s_rule>-to_sel_is_single = l_bool.
ENDLOOP.
ENDMETHOD.

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Static Public Method ZCL_COPY_COM=>CREATE_TO_VALUES
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_T_CHARSEL TYPE RSPLF_T_CHARSEL
* | [--->] I_TH_CHA TYPE RSPLF_TH_IOBJ
* | [--->] I_R_MSG TYPE REF TO IF_RSPLFA_MSG
* | [<-()] R_T_CHARSEL TYPE RSPLF_T_CHARSEL
* +------------------------------------------------------------------------
--------------</SIGNATURE>
method CREATE_TO_VALUES.
raise exception type cx_rsr_x_message
exporting
text = 'CREATE_TO_VALUES-01-'.
endmethod.

* <SIGNATURE>--------------------------------------------------------------
How to... Build a Planning Function that Copies Comments and Data Records in BW

-------------------------+
* | Instance Public Method ZCL_COPY_COM-
>IF_RSPLFA_SRVTYPE_IMP_CHECK~CHECK_CHAR_USAGE
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_T_CHAR_USAGE TYPE RSPLF_T_CHAR_USAGE
* | [---
>] I_R_INFOPROV_DESC TYPE REF TO IF_RSPLFA_INFOPROV_DESC
* | [--->] I_R_MSG TYPE REF TO IF_RSPLFA_MSG
* +------------------------------------------------------------------------
--------------</SIGNATURE>
method IF_RSPLFA_SRVTYPE_IMP_CHECK~CHECK_CHAR_USAGE.
DATA: l_dummy TYPE c. "#EC NEEDED

READ TABLE i_t_char_usage TRANSPORTING NO FIELDS WITH KEY is_chng_char =


'X'.
IF sy-subrc <> 0.
* Wählen Sie mindestens ein zu veränderndes Feld aus
MESSAGE e034(rsplf) INTO l_dummy.
i_r_msg->add_msg( ).
ENDIF.
endmethod.

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Instance Public Method ZCL_COPY_COM-
>IF_RSPLFA_SRVTYPE_IMP_CHECK~CHECK_PARAM_SET
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_R_PARAM_SET TYPE REF TO IF_RSPLFA_PARAM_SET
* | [---
>] I_R_MSG TYPE REF TO IF_RSPLFA_MSG_PARAM_CHECK
* +------------------------------------------------------------------------
--------------</SIGNATURE>
method IF_RSPLFA_SRVTYPE_IMP_CHECK~CHECK_PARAM_SET.
create_rules( EXPORTING i_r_msg = i_r_msg
i_r_param_set = i_r_param_set ).
endmethod.

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Instance Public Method ZCL_COPY_COM-
>IF_RSPLFA_SRVTYPE_IMP_CHECK~INIT_CHECK
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_R_SRVTYPE_DEF TYPE REF TO IF_RSPLFA_SRVTYPE_DEF
* | [--->] I_R_SRV TYPE REF TO IF_RSPLFA_SRV
* | [---
>] I_R_INFOPROV_DESC TYPE REF TO IF_RSPLFA_INFOPROV_DESC
* | [--->] I_R_MSG TYPE REF TO IF_RSPLFA_MSG
How to... Build a Planning Function that Copies Comments and Data Records in BW

* +------------------------------------------------------------------------
--------------</SIGNATURE>
method IF_RSPLFA_SRVTYPE_IMP_CHECK~INIT_CHECK.
p_r_srv = i_r_srv.
endmethod.

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Instance Public Method ZCL_COPY_COM-
>IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~ADD_NEW_BLOCKS
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_R_PARAM_SET TYPE REF TO IF_RSPLFA_PARAM_SET
* | [--->] I_TH_REF_DATA TYPE HASHED TABLE
* | [--->] I_TS_EXISTING_BLOCKS TYPE SORTED TABLE
* | [--->] I_R_MSG TYPE REF TO IF_RSPLFA_MSG
* | [<---] E_TS_NEW_BLOCKS TYPE SORTED TABLE
* +------------------------------------------------------------------------
--------------</SIGNATURE>
method IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~ADD_NEW_BLOCKS.
DATA: l_r_new_block TYPE REF TO data.

FIELD-SYMBOLS: <s_ref_data> TYPE ANY,


<s_new_block> TYPE ANY.

CREATE DATA l_r_new_block LIKE LINE OF e_ts_new_blocks.


ASSIGN l_r_new_block->* TO <s_new_block>.

LOOP AT i_th_ref_data ASSIGNING <s_ref_data>.


MOVE-CORRESPONDING <s_ref_data> TO <s_new_block>.
READ TABLE i_ts_existing_blocks TRANSPORTING NO FIELDS FROM <s_new_bloc
k>.
IF sy-subrc <> 0.
COLLECT <s_new_block> INTO e_ts_new_blocks.
ENDIF.
ENDLOOP.
endmethod.

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Instance Public Method ZCL_COPY_COM-
>IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~EXECUTE
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_R_PARAM_SET TYPE REF TO IF_RSPLFA_PARAM_SET
* | [--->] I_TH_REF_DATA TYPE HASHED TABLE
* | [--->] I_S_BLOCK_LINE TYPE ANY
* | [--->] I_R_MSG TYPE REF TO IF_RSPLFA_MSG
* | [<-->] C_TH_DATA TYPE HASHED TABLE
* +------------------------------------------------------------------------
How to... Build a Planning Function that Copies Comments and Data Records in BW

--------------</SIGNATURE>
METHOD IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~EXECUTE.
DATA: l_rulepos TYPE rsplf_rulepos,
l_ts_rule TYPE t_ts_rule,
l_s_rule TYPE t_s_rule,
l_r_data_wa TYPE REF TO data,
l_r_block_line TYPE REF TO data,
l_r_msg TYPE REF TO cl_rsplfu_msg,
l_t_msg TYPE rsplf_t_msg,
l_s_msg TYPE rsplf_s_msg,
l_dummy TYPE c, "#EC NEEDED
l_r_i_msg TYPE REF TO cl_rsplfu_msg,
l_s_dta_pro TYPE rsd_s_dta_pro,
l_s_iobj TYPE rsplf_s_iobjnm,
l_th_iobj TYPE rsplf_th_iobj,
l_r_s_chas TYPE REF TO data,
l_s_sel TYPE rspls_s_sel,
l_s_rng TYPE rspls_s_rng,
l_is_valid TYPE rs_bool,
l_r_th_data TYPE REF TO data,
l_set_cr_controller TYPE rs_bool,
l_s_char_usage TYPE rsplf_s_char_usage,
l_x_chas TYPE xstring,
l_x_chas_related TYPE xstring,
l_chanmid TYPE rssid,
l_ts_chanmid TYPE rrsi_ts_sid,
l_r_chabit TYPE REF TO cl_rsr_chabit,
l_chanm TYPE rsd_chanm.

FIELD-SYMBOLS: <s_data_wa> TYPE any,


<s_data_wa2> TYPE any,
<s_block_line> TYPE any,
<th_chas> TYPE HASHED TABLE,
<s_chas> TYPE any,
<s_combi> TYPE any,
<th_data> TYPE HASHED TABLE,
<cha> TYPE any,
<s_data> TYPE any.

* start modification
data: l_partprov TYPE rsinfoprov,
l_partprov_ref TYPE rsinfoprov,
l_r_datadesc TYPE REF TO cl_abap_datadescr,
l_r_to_comments_line TYPE REF TO data,
l_r_s_comments_line TYPE REF TO data,
l_r_to_comments_line_r TYPE REF TO data,
l_r_s_comments_line_r TYPE REF TO data,
l_s_char like line of P_T_CHAR_USAGE,
l_kyf type RSIOBJNM,
How to... Build a Planning Function that Copies Comments and Data Records in BW

l_handle TYPE GUID_32,


l_fieldname TYPE FIELDNAME,
l_hashkey TYPE hash160.

FIELD-SYMBOLS: <l_to_comments> TYPE INDEX TABLE,


<l_s_comments> TYPE ANY,
<l_to_comments_ref> TYPE INDEX TABLE,
<l_s_comments_ref> TYPE ANY,
<kyfnm> type any,
<value1> type any,
<value2> type any.

* what is the partprov?


* ASSUMPTION: we stay within one InfoProv at the moment, no multiprovider
CALL FUNCTION 'Z_RETURN_PARTPROV'
EXPORTING
i_infoprov = p_infoprov
IMPORTING
e_partprov = l_partprov
EXCEPTIONS
not_unique = 1
OTHERS = 2.
IF sy-subrc <> 0.
CLEAR l_partprov.
exit.
ENDIF.
* what happens if we are in a multiprovider? then we either stay in the sam
e InfoCube or the
* InfoCube must be part of the copy rule
* still to be done!!
* for the time being we stay in the InfoCube
l_partprov_ref = l_partprov.

* create all necessary work areas for tagret infoprov


CALL FUNCTION 'Z_CREATE_DATAREF'
EXPORTING
i_infoprov = l_partprov
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_partprov
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>.
How to... Build a Planning Function that Copies Comments and Data Records in BW

*create necessary work areas for reference infoprov


CALL FUNCTION 'Z_CREATE_DATAREF'
EXPORTING
i_infoprov = l_partprov_ref
i_type = zco_tt_comments_line
IMPORTING
e_o_datadesc = l_r_datadesc.
CREATE DATA l_r_to_comments_line_r TYPE HANDLE l_r_datadesc.
ASSIGN l_r_to_comments_line_r->* TO <l_to_comments_ref>.

CALL FUNCTION 'Z_CREATE_DATAREF'


EXPORTING
i_infoprov = l_partprov_ref
i_type = zco_ty_comments_line
IMPORTING
e_o_datadesc = l_r_datadesc.
CREATE DATA l_r_s_comments_line_r TYPE HANDLE l_r_datadesc.
ASSIGN l_r_s_comments_line_r->* TO <l_s_comments_ref>.

* get the handle for the comments


CALL FUNCTION 'Z_RETURN_HANDLE'
IMPORTING
E_HANDLE = l_handle.

*end modification

l_r_i_msg ?= i_r_msg.
CREATE OBJECT l_r_msg.

* ==== get or create p_r_th_chas for generation of combinations


IF p_r_th_chas IS INITIAL.
LOOP AT cl_rsplfr_controller=>n_t_dta_pro INTO l_s_dta_pro WHERE iobjtp
= 'CHA' OR iobjtp = 'TIM' OR iobjtp = 'UNI'.
l_s_iobj-iobjnm = l_s_dta_pro-iobjnm.
INSERT l_s_iobj INTO TABLE l_th_iobj.
ENDLOOP.
l_r_s_chas = cl_rsplfr_controller=>p_r_cr_controller->n_r_structure-
>create_data( ).
ASSIGN l_r_s_chas->* TO <s_chas>.
CREATE DATA p_r_th_chas LIKE HASHED TABLE OF <s_chas>
WITH UNIQUE KEY (l_th_iobj).
ENDIF.

IF p_r_object_creation IS INITIAL.
CREATE OBJECT p_r_object_creation
EXPORTING
i_t_char_usage = p_t_char_usage
i_r_cr_controller = cl_rsplfr_controller=>p_r_cr_controller.
How to... Build a Planning Function that Copies Comments and Data Records in BW

p_x_source_check = cl_rsplfr_controller=>p_r_cr_controller->n_x_source.
p_x_target_check = cl_rsplfr_controller=>p_r_cr_controller->n_x_target.

l_r_chabit = cl_rsr_chabit=>create( p_infoprov ).


l_x_chas = l_r_chabit->init_xs( ).
p_x_source_create = l_r_chabit->init_xs( ).
p_x_target_create = l_r_chabit->init_xs( ).

LOOP AT p_t_char_usage INTO l_s_char_usage WHERE is_chng_char = rs_c_tr


ue.
l_chanmid = cl_rsr=>get_chanmid( l_s_char_usage-charnm ).
CALL METHOD l_r_chabit->set_bit1
EXPORTING
i_chanmid = l_chanmid
CHANGING
c_xs = l_x_chas.
CALL METHOD l_r_chabit->set_bit1
EXPORTING
i_chanmid = l_chanmid
CHANGING
c_xs = p_x_source_create.
ENDLOOP.

l_x_chas_related = cl_rsplfr_controller=>p_r_cr_controller-
>get_related_chas( i_x_chas = l_x_chas ).
l_ts_chanmid = l_r_chabit->get_ts_chanmid( i_xs = l_x_chas_related ).

LOOP AT l_ts_chanmid INTO l_chanmid.


CALL METHOD l_r_chabit->set_bit1
EXPORTING
i_chanmid = l_chanmid
CHANGING
c_xs = p_x_source_create.
ENDLOOP.

ENDIF.

ASSIGN p_r_th_chas->* TO <th_chas>.


CLEAR <th_chas>.
l_r_s_chas = cl_rsplfr_controller=>p_r_cr_controller->n_r_structure-
>create_data( ).
ASSIGN l_r_s_chas->* TO <s_chas>.
* ==== get or create rule
l_rulepos = i_r_param_set->get_rulepos( ).
READ TABLE p_ts_rule TRANSPORTING NO FIELDS WITH KEY rulepos = l_rulepos.
IF sy-subrc <> 0.
l_ts_rule = create_rules( i_r_param_set = i_r_param_set i_r_msg = l_r_m
sg ).
INSERT LINES OF l_ts_rule INTO TABLE p_ts_rule.
IF l_r_msg->is_filled( ) = rs_c_true.
l_t_msg = l_r_msg->get_t_msg( ).
How to... Build a Planning Function that Copies Comments and Data Records in BW

LOOP AT l_t_msg INTO l_s_msg.


MESSAGE ID l_s_msg-msgid TYPE l_s_msg-msgty NUMBER l_s_msg-msgno
WITH l_s_msg-msgv1 l_s_msg-msgv2 l_s_msg-msgv3 l_s_msg-
msgv4
INTO l_dummy.
i_r_msg->add_msg( ).
ENDLOOP.
RETURN.
ENDIF.
ENDIF.

* ==== clear work areas


CREATE DATA l_r_data_wa LIKE LINE OF i_th_ref_data.
ASSIGN l_r_data_wa->* TO <s_data_wa>.
CREATE DATA l_r_data_wa LIKE LINE OF i_th_ref_data.
ASSIGN l_r_data_wa->* TO <s_data_wa2>.

CREATE DATA l_r_th_data LIKE c_th_data.


ASSIGN l_r_th_data->* TO <th_data>.

* ==== clear receivers


LOOP AT c_th_data INTO <s_data_wa>.
LOOP AT p_ts_rule INTO l_s_rule WHERE rulepos = l_rulepos.
IF abap_true = cl_rsplfu_work_area=>check_conditions( i_ts_sel = l_s_
rule-t_to_sel
i_s_data = <s_d
ata_wa> ).
l_s_rule-r_work_area->clear( CHANGING c_s_data = <s_data_wa> ).
MODIFY TABLE c_th_data FROM <s_data_wa>.

* start modification
* build up the record
* fill all characteristics into the comemnts structure
loop at P_T_CHAR_USAGE into l_s_char.
CALL FUNCTION 'Z_COMNTS_FIELDS_CONVERT'
EXPORTING
I_IOBJNM = l_s_char-CHARNM
IMPORTING
E_FIELDNAME = l_fieldname.

ASSIGN COMPONENT l_s_char-


charnm of structure <s_data_wa> to <value1>.
if sy-subrc <> 0.
continue.
endif.

ASSIGN COMPONENT l_fieldname of STRUCTURE <l_s_comments> to <valu


e2>.
if sy-subrc <> 0.
continue.
endif.
How to... Build a Planning Function that Copies Comments and Data Records in BW

* 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 p_th_kyf INTO l_kyf.
* 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.
*end modification

EXIT.
ENDIF.
ENDLOOP.
ENDLOOP.

*start modification
* delete the comments
if not <l_to_comments> is initial.
CALL FUNCTION 'Z_DELETE_COMMENTS'
EXPORTING
I_TO_COMMENTS = <l_to_comments>
I_HANDLE = l_handle
I_INFOPROV = l_partprov.
endif.

clear <l_to_comments>.

*before we do the actual copying we get the reference comments


clear: l_s_char, l_kyf, <l_to_comments_ref>, <l_s_comments_ref>, l_fieldn
ame.
loop at i_th_ref_data INTO <s_data_wa2>.
loop at P_T_CHAR_USAGE into l_s_char.
CALL FUNCTION 'Z_COMNTS_FIELDS_CONVERT'
EXPORTING
I_IOBJNM = l_s_char-CHARNM
IMPORTING
E_FIELDNAME = l_fieldname.

ASSIGN COMPONENT l_s_char-


charnm of structure <s_data_wa2> to <value1>.
if sy-subrc <> 0.
continue.
endif.
How to... Build a Planning Function that Copies Comments and Data Records in BW

ASSIGN COMPONENT l_fieldname of STRUCTURE <l_s_comments_ref> to <valu


e2>.
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 p_th_kyf INTO l_kyf.
* now fill the comment table structure
assign component 'KYFNM' of STRUCTURE <l_s_comments_ref> to <kyfnm>.
<kyfnm> = l_kyf.
insert <l_s_comments_ref> INTO table <l_to_comments_ref>.
ENDLOOP.
endloop.

* get the comments


CALL FUNCTION 'Z_READ_COMMENTS'
EXPORTING
I_HANDLE = l_handle
I_INFOPROV = l_partprov_ref
CHANGING
X_TO_COMMENTS = <l_to_comments_ref>.

*end modification

* for performance optimation the controller might call this function type o
nly once with all data
* therefore we fill the block line from the reference data.
CREATE DATA l_r_block_line LIKE i_s_block_line.
ASSIGN l_r_block_line->* TO <s_block_line>.

* ==== for every ref data element, do for every receiver_part the copying
LOOP AT i_th_ref_data INTO <s_data_wa2>.
MOVE-CORRESPONDING <s_data_wa2> TO <s_block_line>.
LOOP AT p_ts_rule INTO l_s_rule WHERE rulepos = l_rulepos.
<s_data_wa> = <s_data_wa2>.
IF abap_true = cl_rsplfu_work_area=>check_conditions( i_ts_sel = l_s_
rule-t_from_sel
i_s_data = <s_d
ata_wa> ).
How to... Build a Planning Function that Copies Comments and Data Records in BW

l_s_rule-r_work_area-
>complement_clear( CHANGING c_s_data = <s_data_wa> ).

IF l_s_rule-to_sel_is_single = abap_false.
* .... no restriction to single values => create allowed combinatio
ns
IF l_set_cr_controller = rs_c_false.
l_set_cr_controller = rs_c_true.
cl_rsplfr_controller=>p_r_cr_controller-
>set_sub_structure_x( i_x_source = p_x_source_create
i
_x_target = p_x_target_create ).
ENDIF.

p_r_object_creation-
>create( EXPORTING i_r_cr_controller = cl_rsplfr_controller=>p_r_cr_control
ler
i_s_b
lock_line = <s_block_line>
i_tsx
_seldr = l_s_rule-tsx_seldr_repr_of_to
i_r_m
sg = l_r_msg
IMPORTING e_th_
chas = <th_chas> ).
IF abap_true = l_r_msg->contains_error( ).
* Gleiches Verhalten wie beim Fall mit nur einem Zielwert. Es wird nichts e
rzeugt
CLEAR <th_chas>.
* me->msg_with_context( EXPORTING i_r_msg_src = l_r_msg
* i_s_rule = l_s_rule
* CHANGING c_r_msg_trgt = l_r_i_msg ).
* RETURN.
ENDIF.
LOOP AT <th_chas> ASSIGNING <s_combi>.
MOVE-CORRESPONDING <s_combi> TO <s_data_wa>.

* start modification - see 7.01 coding


* COLLECT <s_data_wa> INTO <th_data>.
COLLECT <s_data_wa> INTO c_th_data.

* get the corresponding comment.


clear: l_s_char, l_kyf, <l_s_comments_ref>, l_fieldname.
loop at P_T_CHAR_USAGE into l_s_char.
CALL FUNCTION 'Z_COMNTS_FIELDS_CONVERT'
EXPORTING
I_IOBJNM = l_s_char-CHARNM
IMPORTING
E_FIELDNAME = l_fieldname.

* fill the reference comment structure


How to... Build a Planning Function that Copies Comments and Data Records in BW

ASSIGN COMPONENT l_s_char-


charnm of structure <s_data_wa2> to <value1>.
if sy-subrc <> 0.
continue.
endif.
ASSIGN COMPONENT l_fieldname of STRUCTURE <l_s_comments_ref>
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.

* fill the target comment structure


ASSIGN COMPONENT l_s_char-
charnm of structure <s_data_wa> 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.
* fill in the key figures
LOOP AT p_th_kyf INTO l_kyf.
* now fill the comment table structure
assign component 'KYFNM' of STRUCTURE <l_s_comments_ref> to <
kyfnm>.
<kyfnm> = l_kyf.
assign component 'KYFNM' of STRUCTURE <l_s_comments> to <kyfn
m>.
<kyfnm> = l_kyf.
ENDLOOP.

* fill the key for reading!!


CALL FUNCTION 'Z_CREATE_HASHKEY'
EXPORTING
I_INFOPROV = l_partprov_ref
CHANGING
X_DATA_STRUCT = <l_s_comments_ref>
How to... Build a Planning Function that Copies Comments and Data Records in BW

X_HASHKEY = l_hashkey.

* get the reference comment:


READ TABLE <l_to_comments_ref> from <l_s_comments_ref> into <l_
s_comments_ref>.
if sy-subrc = 0.
assign component 'CMT' of STRUCTURE <l_s_comments_ref> to <va
lue1>.
assign component 'CMT' of STRUCTURE <l_s_comments> to <value2
>.
<value2> = <value1>.
insert <l_s_comments> INTO table <l_to_comments>.
endif.
* end modification

ENDLOOP.
ELSE.
* .... restriction to single values => check the combination (much
faster)
MOVE-CORRESPONDING <s_block_line> TO <s_chas>.
LOOP AT l_s_rule-t_to_sel INTO l_s_sel.
ASSIGN COMPONENT l_s_sel-chanm OF STRUCTURE <s_chas> TO <cha>.
* precondition: l_s_sel-
t_rng contains just one line with sign = 'I' and opt = 'Eq'
LOOP AT l_s_sel-t_rng INTO l_s_rng.
<cha> = l_s_rng-low.
EXIT.
ENDLOOP.
ENDLOOP.

cl_rsplfr_controller=>p_r_cr_controller-
>check( EXPORTING i_s_chas = <s_chas>
IMPORTING e_is_va
lid = l_is_valid ).
IF l_is_valid = abap_true.
* combination valid -> store kyfs to receiver.
MOVE-CORRESPONDING <s_chas> TO <s_data_wa>.
COLLECT <s_data_wa> INTO c_th_data.

* start modificaton
* get the corresponding comment.
clear: l_s_char, l_kyf, <l_s_comments_ref>, l_fieldname.
loop at P_T_CHAR_USAGE into l_s_char.
CALL FUNCTION 'Z_COMNTS_FIELDS_CONVERT'
EXPORTING
I_IOBJNM = l_s_char-CHARNM
IMPORTING
E_FIELDNAME = l_fieldname.

* fill the reference comment structure


ASSIGN COMPONENT l_s_char-
How to... Build a Planning Function that Copies Comments and Data Records in BW

charnm of structure <s_data_wa2> to <value1>.


if sy-subrc <> 0.
continue.
endif.
ASSIGN COMPONENT l_fieldname of STRUCTURE <l_s_comments_ref>
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.

* fill the target comment structure


ASSIGN COMPONENT l_s_char-
charnm of structure <s_data_wa> 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.
* fill in the key figures
LOOP AT p_th_kyf INTO l_kyf.
* now fill the comment table structure
assign component 'KYFNM' of STRUCTURE <l_s_comments_ref> to <
kyfnm>.
<kyfnm> = l_kyf.
assign component 'KYFNM' of STRUCTURE <l_s_comments> to <kyfn
m>.
<kyfnm> = l_kyf.
ENDLOOP.

* fill the key for reading!!


CALL FUNCTION 'Z_CREATE_HASHKEY'
EXPORTING
I_INFOPROV = l_partprov_ref
CHANGING
X_DATA_STRUCT = <l_s_comments_ref>
X_HASHKEY = l_hashkey.
How to... Build a Planning Function that Copies Comments and Data Records in BW

* get the reference comment:


READ TABLE <l_to_comments_ref> from <l_s_comments_ref> into <l_
s_comments_ref>.
if sy-subrc = 0.
assign component 'CMT' of STRUCTURE <l_s_comments_ref> to <va
lue1>.
assign component 'CMT' of STRUCTURE <l_s_comments> to <value2
>.
<value2> = <value1>.
insert <l_s_comments> INTO table <l_to_comments>.
endif.
* end modification.

ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.

* start modification
* see 7.01 coding
* IF l_set_cr_controller = rs_c_true.
* cl_rsplfr_controller=>p_r_cr_controller-
>set_sub_structure_x( i_x_source = p_x_source_check
* i_x_targ
et = p_x_target_check ).
* ENDIF.
*
* LOOP AT <th_data> ASSIGNING <s_data>.
* MOVE-CORRESPONDING <s_data> TO <s_chas>.
* cl_rsplfr_controller=>p_r_cr_controller-
>check( EXPORTING i_s_chas = <s_chas>
* IMPORTING e_is_valid =
l_is_valid ).
* IF l_is_valid = abap_true.
* COLLECT <s_data> INTO c_th_data.
* ENDIF.
* ENDLOOP.

if not <l_to_comments> is initial.

CALL FUNCTION 'Z_UPDATE_COMMENTS'


EXPORTING
I_TO_COMMENTS = <l_to_comments>
i_handle = l_handle
i_infoprov = l_partprov.

endif.
* end modification
How to... Build a Planning Function that Copies Comments and Data Records in BW

ENDMETHOD.

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Instance Public Method ZCL_COPY_COM-
>IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~FINISH_EXECUTION
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_R_MSG TYPE REF TO IF_RSPLFA_MSG
* +------------------------------------------------------------------------
--------------</SIGNATURE>
method IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~FINISH_EXECUTION.
exit.
endmethod.

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Instance Public Method ZCL_COPY_COM-
>IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~GET_REF_DATA_SEL
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_T_DATA_CHARSEL TYPE RSPLF_T_CHARSEL
* | [---
>] I_T_DATA_NODE_SEL TYPE RSPLF_T_NODE(optional)
* | [--->] I_R_PARAM_SET TYPE REF TO IF_RSPLFA_PARAM_SET
* | [--->] I_R_MSG TYPE REF TO IF_RSPLFA_MSG
* | [<---] E_TH_NO_REF_BLOCK_CHA TYPE RSPLF_TH_IOBJ
* | [<---] E_T_REF_CHARSEL TYPE RSPLF_T_CHARSEL
* | [<---] E_T_REF_NODE_SEL TYPE RSPLF_T_NODE
* +------------------------------------------------------------------------
--------------</SIGNATURE>
METHOD IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~GET_REF_DATA_SEL.

TYPES: BEGIN OF lty_s_sel. "n1749763


TYPES: paramline TYPE sytabix.
TYPES: iobjnm TYPE rsiobjnm.
TYPES: flg_sel TYPE rs_bool.
TYPES: END OF lty_s_sel.
DATA: l_s_sel TYPE lty_s_sel,
l_t_sel TYPE STANDARD TABLE OF lty_s_sel,
flg_charsel TYPE rs_bool,
flg_node TYPE rs_bool,
l_tabix TYPE sytabix.

DATA: l_t_param_tab TYPE rsplfa_t_param_struc,


l_r_param_tab_wa TYPE REF TO if_rsplfa_param_struc,
l_r_param_sel TYPE REF TO if_rsplfa_param_data_sel,
l_s_charsel TYPE rsplf_s_charsel,
How to... Build a Planning Function that Copies Comments and Data Records in BW

l_t_charsel TYPE rsplf_t_charsel,


l_t_char_usage TYPE rsplf_t_char_usage,
l_s_char_usage TYPE rsplf_s_char_usage,
l_s_dta_pro TYPE rsd_s_dta_pro,
l_basecha TYPE rsiobjnm,
l_t_node TYPE rsplf_t_node,
l_s_node TYPE rsplf_s_node,
sellines TYPE i,
paramlines TYPE i.

e_t_ref_charsel = i_t_data_charsel.
e_t_ref_node_sel = i_t_data_node_sel.
l_t_char_usage = p_r_srv->get_tab_char_usage( ).

LOOP AT l_t_char_usage INTO l_s_char_usage WHERE is_chng_char = rs_c_true


.
DELETE e_t_ref_charsel WHERE iobjnm = l_s_char_usage-charnm.
DELETE e_t_ref_node_sel WHERE iobjnm = l_s_char_usage-charnm.
ENDLOOP.

LOOP AT cl_rsplfr_controller=>n_t_dta_pro_atr INTO l_s_dta_pro WHERE atrn


avfl = rs_c_true.
CALL FUNCTION 'RSD_ATTRINM_GET_FROM_ATRNAVNM'
EXPORTING
i_atrnavnm = l_s_dta_pro-iobjnm
IMPORTING
e_chanm = l_basecha.

READ TABLE l_t_char_usage TRANSPORTING NO FIELDS


WITH KEY charnm = l_basecha
is_chng_char = rs_c_true.
IF sy-subrc = 0.
DELETE e_t_ref_charsel WHERE iobjnm = l_s_dta_pro-iobjnm.
DELETE e_t_ref_node_sel WHERE iobjnm = l_s_dta_pro-iobjnm.
ENDIF.
ENDLOOP.

l_t_param_tab = i_r_param_set->get_tab_param_struc( 'FROMTAB' ).


LOOP AT l_t_param_tab INTO l_r_param_tab_wa.
l_tabix = sy-tabix.
l_r_param_sel = l_r_param_tab_wa->get_comp_data_sel( 'FROMSEL' ).
l_r_param_sel->get_t_sel_node( IMPORTING e_t_sel = l_t_charsel
e_t_node = l_t_node ).
"collect the selection restriction of all parameter lines
LOOP AT l_t_char_usage INTO l_s_char_usage WHERE is_chng_char = rs_c_tr
ue.
CLEAR: flg_charsel, flg_node, l_s_sel.
READ TABLE l_t_charsel WITH KEY iobjnm = l_s_char_usage-charnm
TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
flg_charsel = rs_c_true.
ENDIF.
How to... Build a Planning Function that Copies Comments and Data Records in BW

READ TABLE l_t_node WITH KEY iobjnm = l_s_char_usage-charnm


TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
flg_node = rs_c_true.
ENDIF.
l_s_sel-paramline = l_tabix.
l_s_sel-iobjnm = l_s_char_usage-charnm.
IF flg_charsel = rs_c_true OR flg_node = rs_c_true.
l_s_sel-flg_sel = rs_c_true.
ENDIF.
APPEND l_s_sel TO l_t_sel.
ENDLOOP.

LOOP AT l_t_charsel INTO l_s_charsel.


APPEND l_s_charsel TO e_t_ref_charsel.
ENDLOOP.
LOOP AT l_t_node INTO l_s_node.
APPEND l_s_node TO e_t_ref_node_sel.
ENDLOOP.
ENDLOOP.

"if a characteristic is restricted in one parameter line and not restrict


ed
" in another parameter line, the ref data selection must not be restricte
d
" regarding this characteristic otherwise less reference data will select
ed
" in respect of the parameter line w/o restriction
LOOP AT l_t_char_usage INTO l_s_char_usage WHERE is_chng_char = rs_c_true
.
CLEAR flg_charsel.
READ TABLE l_t_sel WITH KEY iobjnm = l_s_char_usage-charnm
flg_sel = rs_c_true
TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
flg_charsel = rs_c_true.
ENDIF.
READ TABLE l_t_sel WITH KEY iobjnm = l_s_char_usage-charnm
flg_sel = rs_c_false
TRANSPORTING NO FIELDS.
IF sy-subrc = 0 AND flg_charsel = rs_c_true.
"if one parameter line with and another parameter line w/o selection
restriction
DELETE e_t_ref_charsel WHERE iobjnm EQ l_s_char_usage-charnm.
DELETE e_t_ref_node_sel WHERE iobjnm EQ l_s_char_usage-charnm.
ENDIF.

ENDLOOP.

ENDMETHOD.
How to... Build a Planning Function that Copies Comments and Data Records in BW

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Instance Public Method ZCL_COPY_COM-
>IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~INIT_EXECUTION
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_R_SRVTYPE_DEF TYPE REF TO IF_RSPLFA_SRVTYPE_DEF
* | [--->] I_R_SRV TYPE REF TO IF_RSPLFA_SRV
* | [---
>] I_R_INFOPROV_DESC TYPE REF TO IF_RSPLFA_INFOPROV_DESC
* | [--->] I_R_MSG TYPE REF TO IF_RSPLFA_MSG
* | [--->] I_T_DATA_CHARSEL TYPE RSPLF_T_CHARSEL
* | [---
>] I_T_DATA_NODE_SEL TYPE RSPLF_T_NODE(optional)
* +------------------------------------------------------------------------
--------------</SIGNATURE>
METHOD IF_RSPLFA_SRVTYPE_IMP_EXEC_REF~INIT_EXECUTION.
DATA: l_x_error TYPE REF TO cx_rs_error,
l_s_msg TYPE bal_s_msg,
l_dummy TYPE c, "#EC NEEDED
l_t_rule TYPE rsplfa_t_param_set_rule,
l_s_rule TYPE rsplfa_s_param_set_rule,
l_r_param_keyf_sel TYPE REF TO if_rsplfa_param_keyf_sel,
l_t_keyfnm TYPE rsplf_t_keyfnm,
l_iobjnm TYPE rsiobjnm,
l_s_iobjnm TYPE rsplf_s_iobjnm,
l_th_kyf TYPE rsplf_th_iobj.

l_t_rule = i_r_srv->get_param_set_rules( ).
CLEAR l_th_kyf.
LOOP AT l_t_rule INTO l_s_rule.
l_r_param_keyf_sel = l_s_rule-r_param_set-
>get_param_keyf_sel( 'KYFSEL' ).
l_t_keyfnm = l_r_param_keyf_sel->get_t_keyfnm( ).
LOOP AT l_t_keyfnm INTO l_iobjnm.
l_s_iobjnm-iobjnm = l_iobjnm.
INSERT l_s_iobjnm INTO TABLE l_th_kyf.
ENDLOOP.
ENDLOOP.

cl_rsplfr_controller=>set_used_kyf( EXPORTING i_th_changed_kyf = l_th_kyf


i_th_ref_kyf = l_th_kyf ).

TRY.
p_r_srv = i_r_srv.
p_infoprov = i_r_srv->get_infoprov( ).
p_t_char_usage = i_r_srv->get_tab_char_usage( ).

CATCH cx_rs_error INTO l_x_error.


l_s_msg = l_x_error->get_message( ).
MESSAGE ID l_s_msg-msgid TYPE 'E' NUMBER l_s_msg-msgno
How to... Build a Planning Function that Copies Comments and Data Records in BW

WITH l_s_msg-msgv1 l_s_msg-msgv2 l_s_msg-msgv3 l_s_msg-


msgv4
INTO l_dummy.
i_r_msg->add_msg( ).
ENDTRY.

p_t_charsel = i_t_data_charsel.

p_th_kyf = l_th_kyf.

ENDMETHOD.

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Instance Public Method ZCL_COPY_COM-
>IF_RSPLFA_SRVTYPE_TREX_EXEC_R~INIT_AND_CHECK
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_ALVL TYPE RSINFOPROV
* | [---
>] I_T_PARAM_SET_RULE TYPE CL_RSPLFR_CONTROLLER=>GT_T_PA
RAM_SET_RULE
* | [--->] I_R_MSG TYPE REF TO IF_RSPLFA_MSG
* | [<---] E_TREX_SUPPORTED TYPE RS_BOOL
* +------------------------------------------------------------------------
--------------</SIGNATURE>
method IF_RSPLFA_SRVTYPE_TREX_EXEC_R~INIT_AND_CHECK.
* e_trex_supported = rs_c_true.

e_trex_supported = rs_c_false.
endmethod.

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Instance Public Method ZCL_COPY_COM-
>IF_RSPLFA_SRVTYPE_TREX_EXEC_R~TREX_EXECUTE
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_R_STORE TYPE REF TO CL_RSR_STORE
* | [--->] I_VIEW TYPE TREXD_PLAN_VIEW
* | [--->] I_VIEW_REF TYPE TREXD_PLAN_VIEW
* | [--->] I_TH_CALC_CHARS TYPE RSPLF_TH_IOBJ
* | [--->] I_TH_BLOCK_CHARS TYPE RSPLF_TH_IOBJ
* | [--->] I_R_PARAM_SET TYPE REF TO IF_RSPLFA_PARAM_SET
* | [--->] I_R_MSG TYPE REF TO IF_RSPLFA_MSG
* | [<-
()] R_S_VIEW TYPE IF_RSPLFA_SRVTYPE_TREX_EXEC=
>TN_S_RESULT_VIEW
* | [!CX!] CX_RS_FAILED
How to... Build a Planning Function that Copies Comments and Data Records in BW

* +------------------------------------------------------------------------
--------------</SIGNATURE>
METHOD IF_RSPLFA_SRVTYPE_TREX_EXEC_R~TREX_EXECUTE.
exit.
* DATA: l_view LIKE r_s_view-view,
* l_view_ref_new LIKE r_s_view-view,
* l_r_param_elem TYPE REF TO if_rsplfa_param_elem,
* l_s_attr_const_mapping TYPE trexs_map_attribute_const,
* l_th_attr_const_mapping TYPE trext_map_attribute_const,
* l_t_to_tab TYPE rsplfa_t_param_struc,
* l_t_from_tab TYPE rsplfa_t_param_struc,
* l_r_kyf_sel TYPE REF TO if_rsplfa_param_keyf_sel,
* l_t_kyfnm TYPE rsplf_t_keyfnm,
* l_r_to_tab_wa TYPE REF TO if_rsplfa_param_struc,
* l_r_from_tab_wa TYPE REF TO if_rsplfa_param_struc,
* l_r_param_sel TYPE REF TO if_rsplfa_param_data_sel,
* l_from_seqnr TYPE rsplf_seqnr,
* l_to_seqnr TYPE rsplf_seqnr,
* l_t_charsel TYPE rsplf_t_charsel,
* l_t_charsel_all TYPE rsplf_t_charsel,
* l_s_range TYPE rsdri_s_range,
* l_t_range TYPE rsdri_t_range,
* l_s_charsel TYPE rsplf_s_charsel,
* l_s_req_c TYPE rspls_s_req_c,
* l_s_req_k TYPE rspls_s_req_k,
* l_s_dta TYPE rsd_s_dta_pro,
* l_t_trex_entries TYPE trext_query_entries,
* l_th_req_k TYPE rspls_th_req_k,
* l_th_req_c TYPE rspls_th_req_c,
* l_x_static_check TYPE REF TO cx_static_check,
* l_r_session_store_manager TYPE REF TO cl_rspls_session_store_manag
er,
* l_r_msg TYPE REF TO cl_rsplfu_msg,
* l_s_block_chars TYPE rsplf_s_iobjnm,
* l_t_level TYPE trext_attributes,
* l_s_level LIKE LINE OF l_t_level,
* l_t_target TYPE trext_pe_formula_target,
* l_s_target TYPE trexs_pe_formula_target,
* l_t_request TYPE trext_pe_formula_request,
* l_s_request TYPE trexs_pe_formula_request,
* l_fiscvarnt TYPE periv,
* l_cnt TYPE i.
*
* TRY.
* cl_rspls_trex_srv=>get_reqs( EXPORTING i_r_store = i_r_store IMPORTI
NG e_th_req_k = l_th_req_k
*
e_th_req_c = l_th_req_c ).
* l_r_session_store_manager = cl_rspls_session_store_manager=>get_inst
ance( i_r_store = i_r_store ).
*
*
How to... Build a Planning Function that Copies Comments and Data Records in BW

* cl_rsplfr_controller=>show_index_data( i_view = i_view_ref


* i_r_session_store_manager = l
_r_session_store_manager ).
*
* l_r_kyf_sel = i_r_param_set->get_param_keyf_sel( 'KYFSEL' ).
* l_t_kyfnm = l_r_kyf_sel->get_t_keyfnm( ).
*
* LOOP AT i_th_block_chars INTO l_s_block_chars.
* READ TABLE l_th_req_c INTO l_s_req_c WITH TABLE KEY chanm = l_s_bl
ock_chars-iobjnm.
* ASSERT sy-subrc IS INITIAL.
* l_s_level-attr_name = l_s_req_c-keyreturnnm.
* INSERT l_s_level INTO TABLE l_t_level.
* ENDLOOP.
*
* LOOP AT i_th_calc_chars INTO l_s_block_chars.
* READ TABLE l_th_req_c INTO l_s_req_c WITH TABLE KEY chanm = l_s_bl
ock_chars-iobjnm.
* ASSERT sy-subrc IS INITIAL.
* l_s_level-attr_name = l_s_req_c-keyreturnnm.
* INSERT l_s_level INTO TABLE l_t_level.
* ENDLOOP.
*
*
** Daten im Filter vorbereiten
* l_view = i_view.
* l_t_to_tab = i_r_param_set->get_tab_param_struc( 'TOTAB' ).
* CLEAR l_t_charsel_all.
* LOOP AT l_t_to_tab INTO l_r_to_tab_wa.
* l_t_charsel = l_r_to_tab_wa->get_comp_data_sel( 'TOSEL' )-
>get_t_sel( ).
* APPEND LINES OF l_t_charsel TO l_t_charsel_all.
* ENDLOOP.
*
* l_t_trex_entries = cl_rsplfu_charsel=>charsel_2_trex_entry( i_t_char
sel = l_t_charsel_all i_th_req_c = l_th_req_c ).
* IF lines( l_t_trex_entries ) > 0.
* l_view = l_r_session_store_manager-
>copy_view( i_t_query_entry = l_t_trex_entries
* i_source_view = l_vie
w ).
* ENDIF.
* CLEAR: l_t_target, l_t_request.
*
* LOOP AT cl_rsplfr_controller=>n_t_dta_pro INTO l_s_dta WHERE iobjtp
= 'KYF'.
* READ TABLE l_t_kyfnm TRANSPORTING NO FIELDS FROM l_s_dta-iobjnm.
* IF sy-subrc = 0.
* CLEAR: l_s_target, l_s_request.
* READ TABLE l_th_req_k INTO l_s_req_k WITH KEY kyfnm = l_s_dta-
iobjnm.
* ASSERT sy-subrc = 0.
How to... Build a Planning Function that Copies Comments and Data Records in BW

* l_s_target-target_keyfigure = l_s_req_k-value_returnnm.
* APPEND l_s_target TO l_t_target.
* l_s_request-target_index = sy-tabix.
* l_s_request-formula = '0'.
* APPEND l_s_request TO l_t_request.
* ENDIF.
* ENDLOOP.
*
* cl_rsplfr_controller=>show_index_data( i_view = l_view
* i_r_session_store_manager = l_r_s
ession_store_manager ).
*
* l_view = l_r_session_store_manager-
>calculate_formula( i_session_view = l_view
* i_aggregate_s
ession_view = rs_c_true
* i_t_target
= l_t_target
* i_t_request
= l_t_request ).
*
* cl_rsplfr_controller=>show_index_data( i_view = l_view
* i_r_session_store_manager = l_r_se
ssion_store_manager ).
*
* l_t_from_tab = i_r_param_set->get_tab_param_struc( 'FROMTAB' ).
* LOOP AT l_t_from_tab INTO l_r_from_tab_wa.
* l_r_param_elem = l_r_from_tab_wa->get_comp_elem( 'FROMSEQNR' ).
* l_r_param_elem->get_value( IMPORTING e_value = l_from_seqnr ).
* l_r_param_sel = l_r_from_tab_wa->get_comp_data_sel( 'FROMSEL' ).
* CLEAR l_t_charsel.
* l_t_charsel = l_r_param_sel->get_t_sel( ).
*
* CLEAR l_t_range.
* LOOP AT l_t_charsel INTO l_s_charsel.
* CLEAR l_s_range.
* READ TABLE l_th_req_c INTO l_s_req_c WITH TABLE KEY chanm = l_s_
charsel-iobjnm.
* ASSERT sy-subrc = 0.
* l_s_range-chanm = l_s_req_c-keyreturnnm.
* l_s_range-sign = l_s_charsel-sign.
* l_s_range-compop = l_s_charsel-opt.
* l_s_range-low = l_s_charsel-low.
* l_s_range-high = l_s_charsel-high.
* APPEND l_s_range TO l_t_range.
* ENDLOOP.
* IF lines( l_t_range ) > 0.
* l_t_trex_entries = cl_rsdrv_trex_query=>build_query_from_range(
l_t_range ).
* ELSE.
* CLEAR l_t_trex_entries.
* ENDIF.
How to... Build a Planning Function that Copies Comments and Data Records in BW

** Jetzt das Const Mapping aus den TO-Werten erzeugen


* l_t_to_tab = i_r_param_set->get_tab_param_struc( 'TOTAB' ).
*
* CLEAR l_t_charsel_all.
* LOOP AT l_t_to_tab INTO l_r_to_tab_wa.
* l_r_param_elem = l_r_to_tab_wa->get_comp_elem( 'TOSEQNR' ).
* l_r_param_elem->get_value( IMPORTING e_value = l_to_seqnr ).
* IF l_to_seqnr = l_from_seqnr.
* l_r_param_sel = l_r_to_tab_wa->get_comp_data_sel( 'TOSEL' ).
* l_t_charsel = l_r_param_sel->get_t_sel( ).
* APPEND LINES OF l_t_charsel TO l_t_charsel_all.
* ENDIF.
* ENDLOOP.
*
* l_fiscvarnt = cl_rsplfu_charsel=>get_value_from_charsel( i_t_chars
el = l_t_charsel_all i_iobjnm = '0FISCVARNT' ).
*
* IF l_fiscvarnt IS INITIAL.
* l_fiscvarnt = cl_rsplfu_charsel=>get_value_from_charsel( i_t_cha
rsel = p_t_charsel i_iobjnm = '0FISCVARNT' ).
* ENDIF.
*
* l_t_charsel_all = cl_rsplfu_charsel=>resolve_charsel( i_t_charsel
= l_t_charsel_all
* i_th_cha
= i_th_calc_chars
* i_r_msg
= i_r_msg
* i_fiscvarnt
= l_fiscvarnt ).
* l_r_msg ?= i_r_msg.
* IF rs_c_true = l_r_msg->contains_error( ).
* RETURN.
* ENDIF.
*
* CLEAR l_th_attr_const_mapping.
** Kennzahlen, die nicht kopiert werden werden auf Null gesetzt
* LOOP AT cl_rsplfr_controller=>n_t_dta_pro INTO l_s_dta WHERE iobjt
p = 'KYF'.
* READ TABLE l_t_kyfnm TRANSPORTING NO FIELDS FROM l_s_dta-iobjnm.
* IF sy-subrc <> 0.
* l_s_attr_const_mapping-value = '0'.
* READ TABLE l_th_req_k INTO l_s_req_k WITH KEY kyfnm = l_s_dta-
iobjnm.
* ASSERT sy-subrc = 0.
* l_s_attr_const_mapping-attribute = l_s_req_k-value_returnnm.
* INSERT l_s_attr_const_mapping INTO TABLE l_th_attr_const_mappi
ng.
* ENDIF.
* ENDLOOP.
*
* l_view_ref_new = l_r_session_store_manager-
How to... Build a Planning Function that Copies Comments and Data Records in BW

>copy_view( i_t_query_entry = l_t_trex_entries


* i_source_vi
ew = i_view_ref
* i_t_map_att
ribute_const = l_th_attr_const_mapping ).
* CLEAR l_th_attr_const_mapping.
*
* cl_rsplfr_controller=>show_index_data( i_view = l_view_ref_new
* i_r_session_store_manager =
l_r_session_store_manager ).
*
*
*
* DATA: l_t_attribute_value TYPE trext_pe_attr_values,
* l_s_attribute_value TYPE trexs_pe_attr_values,
* l_attr TYPE string,
* l_copy_result LIKE i_view,
* l_s_calc_cha TYPE rsplf_s_iobjnm.
*
* CLEAR l_t_attribute_value.
* LOOP AT i_th_calc_chars INTO l_s_calc_cha.
* CLEAR l_s_attribute_value.
* LOOP AT l_t_charsel_all INTO l_s_charsel WHERE iobjnm = l_s_calc
_cha-iobjnm.
* l_attr = l_s_charsel-low.
* APPEND l_attr TO l_s_attribute_value-values.
* ENDLOOP.
* IF sy-subrc = 0.
* READ TABLE l_th_req_c INTO l_s_req_c WITH TABLE KEY chanm = l_
s_calc_cha-iobjnm.
* ASSERT sy-subrc = 0.
* l_s_attribute_value-name = l_s_req_c-keyreturnnm.
* INSERT l_s_attribute_value INTO TABLE l_t_attribute_value.
* ENDIF.
* ENDLOOP.
*
* IF lines( l_t_attribute_value ) > 0.
* l_copy_result = l_r_session_store_manager-
>copy_multiple( i_session_view = l_view_ref_new
* i_t_at
tribute_value = l_t_attribute_value ).
*
* l_view = l_r_session_store_manager-
>copy_view( i_source_view = l_copy_result
* i_session_view =
l_view ).
* ENDIF.
*
* ENDLOOP.
*
* cl_rsplfr_controller=>p_r_cr_controller->restrict_valid_hdb(
* EXPORTING
How to... Build a Planning Function that Copies Comments and Data Records in BW

* i_view_check = l_view
* i_r_store = l_r_session_store_manager->get_store( )
* i_with_ds = rs_c_false
* RECEIVING
* r_view_valid = r_s_view-view ).
*
* r_s_view-checked = rs_c_true.
*
* CATCH cx_static_check INTO l_x_static_check.
* l_r_msg ?= i_r_msg.
* l_r_msg->append( i_r_exception = l_x_static_check ).
* ENDTRY.
ENDMETHOD.

* <SIGNATURE>--------------------------------------------------------------
-------------------------+
* | Instance Protected Method ZCL_COPY_COM->MSG_WITH_CONTEXT
* +------------------------------------------------------------------------
-------------------------+
* | [--->] I_R_MSG_SRC TYPE REF TO CL_RSPLFU_MSG
* | [--->] I_S_RULE TYPE T_S_RULE
* | [<-->] C_R_MSG_TRGT TYPE REF TO CL_RSPLFU_MSG
* +------------------------------------------------------------------------
--------------</SIGNATURE>
method MSG_WITH_CONTEXT.
data: l_dummy type c, "#EC NEEDED
l_int type i.

l_int = i_s_rule-seqnr.
l_int = l_int + 1.
Message s309(rsplf) with i_s_rule-index_local_to l_int into l_dummy.
c_r_msg_trgt->add_msg( ).
c_r_msg_trgt->append( exporting i_r_msg = i_r_msg_src ).
endmethod.
ENDCLASS.
w w w .s d n .s a p .c o m

You might also like