Built a Plannign Function Copy
Built a Plannign Function Copy
Built a Plannign Function Copy
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
T a b l e o f Co n t e n t s
1. Scenario ................................................................................................................................ 2
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:
On the attributes tab create the attribute ‘P_TH_KYF’ of type ‘RSPLF_TH_IOBJ’ as shown in the
screen shot.
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
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
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!!!
* <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
* <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
l_rulepos = i_r_param_set->get_rulepos( ).
l_t_from_tab = i_r_param_set->get_tab_param_struc( 'FROMTAB' ).
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.
* <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
* <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.
* <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.
* 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
*end modification
l_r_i_msg ?= i_r_msg.
CREATE OBJECT l_r_msg.
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_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 ).
ENDIF.
* 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.
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>.
*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>.
X_HASHKEY = l_hashkey.
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.
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.
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.
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( ).
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.
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( ).
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
* 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
* 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