You are on page 1of 42

Copying Queries Between InfoSets

Applies to:
SAP BW 3.5, SAP BI 7.0 etc. For more information, visit the EDW homepage.

Summary
This paper gives a detailed understanding and how to copy queries between Infosets. The document guides to understand the issue with existing functionality of RSZC transaction code to copy Infoset queries and explain to overcome the issue with new custom defined transaction code to copy queries between infosets. Author: Lenin Kumar Vutla

Company: Deloitte Consulting Created on: 16 March 2011

Author Bio
Lenin Kumar Vutla is currently working in Deloitte Consulting India Pvt. Ltd. He is working on SAP BW/BI from last 8 years.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 1

Copying Queries Between InfoSets

Table of Contents
Introduction ......................................................................................................................................................... 3 Scenario .............................................................................................................................................................. 3 Step 1: Creating Custom Program .................................................................................................................. 3 Step 2: Settings for Text Elements ................................................................................................................. 5 Step 3: Creating ZRSZC Custom Transaction Code ...................................................................................... 6 Step 4: Results ................................................................................................................................................ 7 Source Query (0CLM_IS02_Q001): ................................................................................................................ 9 Target Query (ZCLM_IS02_Q0001): .............................................................................................................. 9 Source Code: ................................................................................................................................................ 10 Related Content ................................................................................................................................................ 40 Disclaimer and Liability Notice .......................................................................................................................... 41

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 2

Copying Queries Between InfoSets

Introduction
RSZC SAP transaction code help us to copy all query components like Queries, Filters, Restricted Key Figures, Calculated Key Figures and Structures from one InfoCube to another InfoCube or one Multi-provider to another Multi-provider. To copy queries between these Infoproviders, both source and target Infoproviders must have same structure including technical names of Info objects. But in the case of InfoSets it is not possible to copy queries between two infosets however they have same structure. It is because the technical names of Infobjects inside the Infoset will be defined by system while creation. Due to this reason when we create any infoset with copy of another infoset, both original and copied infoset will have different technical names for the infoobjects inside. In that case we cant copy the queries from original infoset to copied infoset. To overcome this issue we have created custom transaction code with name ZRSZC by providing functionality to this transaction code through Z program to facilitate infosets by allow them to copy of queries.

Scenario
To demonstrate the functionality and usage of ZRSZC transaction code to copy queries between InfoSets we took the scenario from FSCM (Financial Supply Chain Management) Business Content Infoset (0CLM_IS02) and created copy Z infoset (ZCLM_IS02).

ZRSZC Functionality:
Please follow the steps below to understand the use of ZRSZC in BW system.

Step 1: Creating Custom Program To provide functionality for ZRSZC transaction code we need to create custom Z program from SE38 ABAP editor. In our scenario we have created the program with name ZRSZC.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 3

Copying Queries Between InfoSets

Please see the Source code for the above program under Source code section. Once program created save and activate.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 4

Copying Queries Between InfoSets

Step 2: Settings for Text Elements To display user defined text elements at input selection screen after program execution, we need to define text elements for all entries defined in the program. Follow the below steps to define text elements for the program output screens. Go to the program editor window in SE38 and select Text Symbols option from Goto menu as shown below.

Enter the below entries in Text Symbols tab.

001 002 003 004 005

Select InfoProvider Select Queries Copying of Query Components Between InfoSets Select Component Log

After that enter the below entries in Selection Texts Tab

G_P_IC1 G_P_IC2 P_CKF P_REP P_RKF P_SOB P_STR

Source InfoSet Target InfoSet Calculated Key Figures Queries Restricted Key Figures Filter Structures

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 5

Copying Queries Between InfoSets

Step 3: Creating ZRSZC Custom Transaction Code To call and execute ZRSZC custom program through transaction code we need to create new Z transaction code with name ZRSZC. The following steps to be followed to create ZRSZC transaction code. Go to SE93 transaction code to create custom transaction code. Type ZRSZC and press Create button as shown below

Then it will display another screen shown below and enter all given parameters(including the program name(ZRSZC) we created ) with required check options.

After entering required parameters press Save button to save the transaction code.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 6

Copying Queries Between InfoSets

Step 4: Results To see the results we have to follow the below instructions. Open new SAP screen and enter ZRSZC transaction code in the command text box as shown below.

Once you run the above transaction code it will execute the assigned ABAP program at back-end and will display the below input selection screen. Enter the source and target infosets and select Queries option to copy all queries from source InfoSet (0CLM_IS02) to target InfoSet (ZCLM_IS02) and press the Execute button.

After execution it will display the below screen with all queries list from the source InfoSet. Select required queries you want to copy from the list and press Transfer Selections button. In our case we selection all queries.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 7

Copying Queries Between InfoSets

Now we need to give copied queries technical names as shown below including CKF, Selections and RKF etc., By default system will assign same technical names of source InfoSet by adding suffix with _1. We can rename them with our own naming convention.

Once all queries successfully copied, below screen will display with confirmation log.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 8

Copying Queries Between InfoSets

Source Query (0CLM_IS02_Q001):

Target Query (ZCLM_IS02_Q0001):

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 9

Copying Queries Between InfoSets

Source Code:
*&---------------------------------------------------------------------* *& Report ZRSZC *& *&---------------------------------------------------------------------* *& Copying of Query Components between InfoSets *& *&---------------------------------------------------------------------*

REPORT

ZRSZC

message-id r9.

type-pools: rs, rrms, rsz, rzx0, rzd1. include <icon>.

"BW global "message server "Qry definition global "Qry RFC interface "Qry definition database

tables: sscrfields.

"needed for custom status

* need info about cubetype of target cube/ODS globally data: g_target_cubetype type rsd_cubetype. data : I_DEFTP TYPE RZD1_DEFTP . FIELD-SYMBOLS: <l_s_complist> TYPE rzd1_s_compdir_compic, <l_s_uid_server> TYPE rzx0_s_uid_server_x, <l_s_dta> TYPE rsd_s_dta. DATA: l_t_eltuid TYPE rsz_t_uid, l_t_comp_rename TYPE rzd1_t_comp_rename, l_s_msg TYPE rs_s_msg, * l_title TYPE string, l_subrc LIKE sy-subrc, l_is_compliant TYPE rs_bool, l_t_msg TYPE rs_t_msg, l_th_complist TYPE rzd1_th_compdir_compic, l_t_popup_in TYPE rso_t_object_f4_list, l_t_popup_out TYPE rso_t_object_f4_list, l_s_popup TYPE rso_s_object_f4_list, l_t_uid_server TYPE rzx0_t_uid_server_x, l_th_uid_server_all TYPE rzx0_th_uid_server_x, l_t_dta TYPE rsd_t_dta. SELECTION-SCREEN BEGIN OF BLOCK ip WITH FRAME TITLE text-001. PARAMETERS g_p_ic1 LIKE v_compdir_compic-infocube OBLIGATORY. PARAMETERS g_p_ic2 LIKE v_compdir_compic-infocube OBLIGATORY. SELECTION-SCREEN END OF BLOCK ip. SELECTION-SCREEN BEGIN OF BLOCK deftp WITH FRAME TITLE text-004.

"value check "value check

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 10

Copying Queries Between InfoSets

PARAMETERS p_rep TYPE rs_bool RADIOBUTTON PARAMETERS p_sob TYPE rs_bool RADIOBUTTON PARAMETERS p_str TYPE rs_bool RADIOBUTTON PARAMETERS p_rkf TYPE rs_bool RADIOBUTTON PARAMETERS p_ckf TYPE rs_bool RADIOBUTTON SELECTION-SCREEN END OF BLOCK deftp.

GROUP GROUP GROUP GROUP GROUP

comp. comp. comp. comp. comp.

IF P_REP IS NOT INITIAL. I_DEFTP = 'REP'. ELSEIF P_SOB IS NOT INITIAL. I_DEFTP = 'SOB'. ELSEIF P_STR IS NOT INITIAL. I_DEFTP = 'STR'. ELSEIF P_RKF IS NOT INITIAL. I_DEFTP = 'RKF'. ELSEIF P_CKF IS NOT INITIAL. I_DEFTP = 'CKF'. ENDIF. * Get InfoArea for source and target CALL METHOD cl_rsd_dta=>get_all EXPORTING i_objvers = rs_c_objvers-active IMPORTING e_t_dta = l_t_dta. READ TABLE l_t_dta ASSIGNING <l_s_dta> WITH KEY infoprov = g_p_ic1. IF sy-subrc = 0. ELSE. * Source InfoProvider is not available MESSAGE a001 WITH g_p_ic1. EXIT. ENDIF. * Check the existence and authorization for thr target IP READ TABLE l_t_dta ASSIGNING <l_s_dta> WITH KEY infoprov = g_p_ic2. IF sy-subrc = 0. ELSE. * Target InfoProvider is not available MESSAGE a001 WITH g_p_ic2. EXIT. ENDIF. * check if taget infocube is compatible PERFORM check_infocube_compliance USING g_p_ic1 g_p_ic2

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 11

Copying Queries Between InfoSets

CHANGING l_subrc l_is_compliant l_t_msg. * show messages if failed IF l_subrc <> 0 OR l_is_compliant = rs_c_false. PERFORM msg_to_protocol USING 'R9' 'E' '145' g_p_ic2 space space space CHANGING l_s_msg. INSERT l_s_msg INTO TABLE l_t_msg. CALL FUNCTION 'RSDC_SHOW_MESSAGES_POPUP' EXPORTING i_t_msg = l_t_msg i_txt = text-001. "Check of IC compatibilit EXIT. ENDIF. * get all queries of source infocube CALL FUNCTION 'RSZ_DB_COMP_LIST_GET' EXPORTING i_by_infocube = g_p_ic1 i_deftp = i_deftp IMPORTING e_th_complist = l_th_complist. * check queries do exist IF l_th_complist[] IS INITIAL. MESSAGE i156 WITH g_p_ic1. EXIT. ENDIF. * convert list to popup structure LOOP AT l_th_complist ASSIGNING <l_s_complist>. * Check authorization to read DEFTPs from the Source CALL FUNCTION 'RSSB_AUTHORITY_COMP_CHECK' EXPORTING i_infoarea = space i_infocube = space i_comptype = <l_s_complist>-deftp i_compid = <l_s_complist>-compid i_owner = <l_s_complist>-owner i_actvt = '03' EXCEPTIONS user_not_authorized = 1 OTHERS = 2.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 12

Copying Queries Between InfoSets

IF sy-subrc <> 0. CALL FUNCTION 'RSSB_AUTHORITY_COMP_CHECK' EXPORTING i_infoarea = space i_infocube = space i_comptype = <l_s_complist>-deftp i_compid = <l_s_complist>-compid i_owner = <l_s_complist>-owner i_actvt = '02' EXCEPTIONS user_not_authorized = 1 OTHERS = 2. IF sy-subrc <> 0. DELETE l_th_complist WHERE compid = <l_s_complist>-compid. CONTINUE. ENDIF. ENDIF.

* Get corresponding ICON CASE <l_s_complist>-deftp. WHEN rzd1_c_deftp-report. l_s_popup-icon = icon_biw_report. WHEN rzd1_c_deftp-structure. l_s_popup-icon = icon_biw_ref_structure. WHEN rzd1_c_deftp-selection. l_s_popup-icon = icon_selection. WHEN rzd1_c_deftp-calkeyfig. l_s_popup-icon = icon_biw_formula. WHEN rzd1_c_deftp-sel_object. l_s_popup-icon = icon_ranking. ENDCASE. l_s_popup-objnm = <l_s_complist>-compid. l_s_popup-txtlg = <l_s_complist>-txtlg. l_s_popup-guid = <l_s_complist>-compuid. INSERT l_s_popup INTO TABLE l_t_popup_in. ENDLOOP. * send selection popup CALL FUNCTION 'RSO_F4_OBJECTS' EXPORTING i_t_object_f4_list = l_t_popup_in i_title = text-004 i_read_only = rs_c_false IMPORTING e_t_object_f4_list = l_t_popup_out EXCEPTIONS cancel = 1 OTHERS = 2. * Cancelled by the user IF sy-subrc = 1.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 13

Copying Queries Between InfoSets

MESSAGE a021. EXIT. ELSEIF sy-subrc > 1. RAISE inherited_error. ENDIF. * Nothing is selected IF l_t_popup_out IS INITIAL. MESSAGE i027. * send selection popup once again CALL FUNCTION 'RSO_F4_OBJECTS' EXPORTING i_t_object_f4_list = l_t_popup_in i_title = text-004 i_read_only = rs_c_false IMPORTING e_t_object_f4_list = l_t_popup_out EXCEPTIONS cancel = 1 OTHERS = 2. ENDIF. * Cancelled by the user IF sy-subrc = 1. MESSAGE a021. EXIT. ELSEIF sy-subrc > 1. RAISE inherited_error. ENDIF. * If nothing is still selected --> exit IF l_t_popup_out IS INITIAL. MESSAGE a027. EXIT. ENDIF. * New renaming popup. Prepare elements table. LOOP AT l_t_popup_out INTO l_s_popup. APPEND l_s_popup-guid TO l_t_eltuid. ENDLOOP. PERFORM rename_by_user USING g_p_ic1 g_p_ic2 l_t_eltuid i_deftp CHANGING l_t_comp_rename l_th_uid_server_all l_subrc l_t_msg. IF l_subrc = 0.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 14

Copying Queries Between InfoSets

LOOP AT l_t_popup_out INTO l_s_popup. l_t_uid_server = l_th_uid_server_all. CALL FUNCTION 'RSZ_I_COPY_QRY_TO_CUBE_SINGLE' EXPORTING i_source_compuid = l_s_popup-guid i_source_infocube = g_p_ic1 i_t_comp_rename = l_t_comp_rename i_target_infocube = g_p_ic2 i_check_compliance = rs_c_false i_deftp = <l_s_complist>-deftp IMPORTING e_t_msg = l_t_msg CHANGING c_t_uid_server = l_t_uid_server EXCEPTIONS no_authority = 1 no_source_infocube_found = 2 infocube_check_failed = 3 error_in_compliance_check = 4 infocubes_not_compliant = 5 OTHERS = 6. IF sy-subrc <> 0. EXIT. ENDIF. LOOP AT l_t_uid_server ASSIGNING <l_s_uid_server>. READ TABLE l_th_uid_server_all WITH TABLE KEY virtual = <l_s_uid_server>-virtual TRANSPORTING NO FIELDS. IF sy-subrc <> 0. INSERT <l_s_uid_server> INTO TABLE l_th_uid_server_all. ENDIF. ENDLOOP. ENDLOOP. ENDIF. * show messages CALL FUNCTION 'RSDC_SHOW_MESSAGES_POPUP' EXPORTING i_t_msg = l_t_msg i_txt = text-005 i_one_msg_direct = rs_c_false. DATA : LT_RSZELTXREF TYPE TABLE OF RSZELTXREF, LT1 TYPE TABLE OF RSZELTXREF, LT2 TYPE TABLE OF RSZELTXREF, LT_RSZSELECT TYPE TABLE OF RSZSELECT, WA_RSZSELECT TYPE RSZSELECT, lt_rszrange type table of rszrange, wa_rszrange type rszrange, lt_rszcalc type table of rszcalc, wa_rszcalc type rszcalc, STRL TYPE STRING,

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 15

Copying Queries Between InfoSets

LEN TYPE I, LT_RSZCOMPIC TYPE TABLE OF RSZCOMPIC, WA_RSZCOMPIC TYPE RSZCOMPIC. DATA : STR TYPE STRING. SELECT * FROM RSZELTXREF INTO TABLE LT_RSZELTXREF WHERE INFOCUBE = g_p_ic2. *BREAK-POINT. LT1[] = LT_RSZELTXREF[]. LT2[] = LT_RSZELTXREF[]. SORT LT1 BY SELTUID. DELETE ADJACENT DUPLICATES FROM LT1 COMPARING SELTUID. SORT LT2 BY TELTUID. DELETE ADJACENT DUPLICATES FROM LT2 COMPARING TELTUID. MOVE G_P_IC1 TO STRL. LEN = STRLEN( STRL ). IF LT1[] IS NOT INITIAL. SELECT * FROM RSZSELECT INTO TABLE LT_RSZSELECT FOR ALL ENTRIES IN LT1 WHERE ELTUID = LT1-SELTUID. LOOP AT LT_RSZSELECT INTO WA_RSZSELECT. IF WA_RSZSELECT-IOBJNM CS g_p_ic1. IF WA_RSZSELECT-IOBJNM+0(LEN) = g_p_ic1. CLEAR : STR. * CONCATENATE 'Z' WA_RSZSELECT-IOBJNM+1(29) INTO STR. move WA_RSZSELECT-IOBJNM to str. replace all occurrences of g_p_ic1 in str with g_p_ic2. UPDATE RSZselect SET IOBJNM = STR WHERE ELTUID = WA_RSZSELECT-ELTUID and iobjnm = WA_RSZSELECT-IOBJNM AND OBJVERS = WA_RSZSELECT-OBJVERS. ENDIF. ENDLOOP. ENDIF. clear : lt_rszselect[]. * IF LT2[] IS NOT INITIAL. SELECT * FROM RSZSELECT INTO TABLE LT_RSZSELECT FOR ALL ENTRIES IN LT2 WHERE ELTUID = LT2-TELTUID. LOOP AT LT_RSZSELECT INTO WA_RSZSELECT. * IF WA_RSZSELECT-IOBJNM CS g_p_ic1. IF WA_RSZSELECT-IOBJNM+0(LEN) = g_p_ic1. CLEAR : STR. * CONCATENATE 'Z' WA_RSZSELECT-IOBJNM+1(29) INTO STR. move WA_RSZSELECT-IOBJNM to str. replace all occurrences of g_p_ic1 in str with g_p_ic2.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 16

Copying Queries Between InfoSets

UPDATE RSZselect SET IOBJNM = STR WHERE ELTUID = WA_RSZSELECT-ELTUID and iobjnm = WA_RSZSELECT-IOBJNM AND OBJVERS = WA_RSZSELECT-OBJVERS. ENDIF. ENDLOOP. ENDIF. IF LT1[] IS NOT INITIAL. SELECT * FROM RSZrange INTO TABLE LT_RSZrange FOR ALL ENTRIES IN LT1 WHERE ELTUID = LT1-SELTUID. LOOP AT LT_RSZrange INTO WA_RSZrange. * IF WA_RSZrange-IOBJNM CS g_p_ic1. IF WA_RSZRANGE-IOBJNM+0(LEN) = g_p_ic1. CLEAR : STR. * CONCATENATE 'Z' WA_RSZrange-IOBJNM+1(29) INTO STR. move WA_RSZrange-IOBJNM to str. replace all occurrences of g_p_ic1 in str with g_p_ic2. UPDATE RSZrange SET IOBJNM = STR WHERE ELTUID = WA_RSZrange-ELTUID and iobjnm = WA_RSZrange-IOBJNM AND OBJVERS = WA_RSZrange-OBJVERS. ENDIF. * IF WA_RSZrange-LOW CS g_p_ic1. IF WA_RSZRANGE-LOW+0(LEN) = g_p_ic1. CLEAR : STR. * CONCATENATE 'Z' WA_RSZrange-LOW+1(59) INTO STR. move WA_RSZrange-low to str. replace all occurrences of g_p_ic1 in str with g_p_ic2. UPDATE RSZrange SET LOW = STR WHERE ELTUID = WA_RSZrange-ELTUID and iobjnm = WA_RSZrange-IOBJNM AND OBJVERS = WA_RSZrange-OBJVERS. ENDIF. IF WA_RSZrange-HIGH CS g_p_ic1. IF WA_RSZRANGE-HIGH+0(LEN) = g_p_ic1. CLEAR : STR. * CONCATENATE 'Z' WA_RSZrange-HIGH+1(59) INTO STR. move WA_RSZrange-high to str. replace all occurrences of g_p_ic1 in str with g_p_ic2. UPDATE RSZrange SET HIGH = STR WHERE ELTUID = WA_RSZrange-ELTUID and iobjnm = WA_RSZrange-IOBJNM AND OBJVERS = WA_RSZrange-OBJVERS. *

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 17

Copying Queries Between InfoSets

ENDIF. ENDLOOP. endif. clear : lt_rszrange[]. IF LT2[] IS NOT INITIAL. SELECT * FROM RSZRANGE INTO TABLE LT_RSZRANGE FOR ALL ENTRIES IN LT2 WHERE ELTUID = LT2-TELTUID.

LOOP AT LT_RSZrange INTO WA_RSZrange. * IF WA_RSZrange-IOBJNM CS g_p_ic1. IF WA_RSZRANGE-IOBJNM+0(LEN) = g_p_ic1. CLEAR : STR. * CONCATENATE 'Z' WA_RSZrange-IOBJNM+1(29) INTO STR. move WA_RSZrange-IOBJNM to str. replace all occurrences of g_p_ic1 in str with g_p_ic2. UPDATE RSZrange SET IOBJNM = STR WHERE ELTUID = WA_RSZrange-ELTUID and iobjnm = WA_RSZrange-IOBJNM AND OBJVERS = WA_RSZrange-OBJVERS. ENDIF. *IF WA_RSZrange-LOW CS g_p_ic1. IF WA_RSZRANGE-LOW+0(LEN) = g_p_ic1. CLEAR : STR. * CONCATENATE 'Z' WA_RSZrange-LOW+1(59) INTO STR. move WA_RSZrange-low to str. replace all occurrences of g_p_ic1 in str with g_p_ic2. UPDATE RSZrange SET LOW = STR WHERE ELTUID = WA_RSZrange-ELTUID and iobjnm = WA_RSZrange-IOBJNM AND OBJVERS = WA_RSZrange-OBJVERS. ENDIF. IF WA_RSZrange-HIGH CS g_p_ic1. IF WA_RSZRANGE-HIGH+0(LEN) = g_p_ic1. CLEAR : STR. * CONCATENATE 'Z' WA_RSZrange-HIGH+1(59) INTO STR. move WA_RSZrange-high to str. replace all occurrences of g_p_ic1 in str with g_p_ic2. UPDATE RSZrange SET HIGH = STR WHERE ELTUID = WA_RSZrange-ELTUID and iobjnm = WA_RSZrange-IOBJNM AND OBJVERS = WA_RSZrange-OBJVERS. * ENDIF. ENDLOOP. ENDIF. *IF LT1[] IS NOT INITIAL .

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 18

Copying Queries Between InfoSets

IF

I_DEFTP = 'CKF' or I_DEFTP = 'REP'. SELECT * FROM RSZCOMPIC INTO TABLE LT_RSZCOMPIC WHERE INFOCUBE = G_P_IC2.

IF LT_RSZCOMPIC[] IS NOT INITIAL. SELECT * FROM RSZCALC INTO TABLE LT_RSZCALC FOR ALL ENTRIES IN LT_RSZCOMPIC WHERE ELTUID = LT_RSZCOMPIC-COMPUID. ENDIF. LOOP AT LT_RSZCALC INTO WA_RSZCALC. IF WA_RSZCALC-OPER1 CS g_p_ic1. IF WA_RSZCALC-OPER1+0(LEN) = g_p_ic1. CLEAR : STR. * CONCATENATE 'Z' WA_RSZCALC-OPER1+1(31) INTO STR. move WA_RSZcalc-oper1 to str. replace all occurrences of g_p_ic1 in str with g_p_ic2. UPDATE RSZCALC SET OPER1 = STR WHERE ELTUID = WA_RSZCALC-ELTUID and STEPNR = WA_RSZCALC-STEPNR AND OBJVERS = WA_RSZCALC-OBJVERS. ENDIF. * *IF WA_RSZCALC-OPER2 CS g_p_ic1. IF WA_RSZCALC-OPER2+0(LEN) = g_p_ic1. CLEAR : STR. * CONCATENATE 'Z' WA_RSZCALC-OPER2+1(31) INTO STR. move WA_RSZcalc-oper2 to str. replace all occurrences of g_p_ic1 in str with g_p_ic2. UPDATE RSZCALC SET OPER2 = STR WHERE ELTUID = WA_RSZCALC-ELTUID and STEPNR = WA_RSZCALC-STEPNR AND OBJVERS = WA_RSZCALC-OBJVERS. ENDIF. *IF WA_RSZCALC-AGGRCHA CS g_p_ic1. IF WA_RSZCALC-AGGRCHA+0(LEN) = g_p_ic1. CLEAR : STR. * CONCATENATE 'Z' WA_RSZCALC-AGGRCHA+1(29) INTO STR. move WA_RSZcalc-aggrcha to str. replace all occurrences of g_p_ic1 in str with g_p_ic2. UPDATE RSZCALC SET AGGRCHA = STR WHERE ELTUID = WA_RSZCALC-ELTUID and STEPNR = WA_RSZCALC-STEPNR AND OBJVERS = WA_RSZCALC-OBJVERS. ENDIF. ENDLOOP. ENDIF. *----------------------------------------------------------------------* ***INCLUDE LRZIMPACTF01 .

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 19

Copying Queries Between InfoSets

*----------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form MSG_TO_PROTOCOL *&---------------------------------------------------------------------* * add messages to transport protocol *----------------------------------------------------------------------* * --> I_ID message id * --> I_TYPE message type * --> I_NUMB message number * --> I_PAR1 parameter 1 * --> I_PAR2 parameter 2 * --> I_PAR3 parameter 3 * --> I_PAR4 parameter 4 * <-- E_S_MSG message *----------------------------------------------------------------------* FORM msg_to_protocol USING value(i_id) value(i_type) value(i_numb) value(i_par1) value(i_par2) value(i_par3) value(i_par4) CHANGING e_s_msg CLEAR e_s_msg. LIKE LIKE LIKE TYPE TYPE TYPE TYPE sy-msgid sy-msgty sy-msgno c c c c

TYPE rs_s_msg.

e_s_msg-msgid = i_id. e_s_msg-msgty = i_type. e_s_msg-msgno = i_numb. e_s_msg-msgv1 = i_par1. e_s_msg-msgv2 = i_par2. e_s_msg-msgv3 = i_par3. e_s_msg-msgv4 = i_par4. PERFORM set_detlevel_probclass CHANGING e_s_msg. ENDFORM. " MSG_TO_PROTOCOL *&---------------------------------------------------------------------* *& Form SET_DETLEVEL_PROBCLASS *&---------------------------------------------------------------------* * set problem class levels *----------------------------------------------------------------------* * <-- C_S_MSG message * *----------------------------------------------------------------------* FORM set_detlevel_probclass CHANGING c_s_msg TYPE rs_s_msg. c_s_msg-detlevel = '1'. CASE c_s_msg-msgty. WHEN 'S'. c_s_msg-probclass = '3'. WHEN 'W' OR 'I'. c_s_msg-probclass = '2'. WHEN 'E' OR "Display message imediately

"medium

"important

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 20

Copying Queries Between InfoSets

'A'. c_s_msg-probclass = '1'. ENDCASE.

"very important

ENDFORM. " SET_DETLEVEL_PROBCLASS *&---------------------------------------------------------------------* *& Form check_infocube_compliance *&---------------------------------------------------------------------* * check if all infoObject of source are in target *----------------------------------------------------------------------* FORM check_infocube_compliance USING i_source_infocube TYPE rsd_infocube i_target_infocube TYPE rsd_infocube CHANGING l_subrc LIKE sy-subrc e_is_compliant TYPE rs_bool c_t_msg TYPE rs_t_msg. FIELD-SYMBOLS: <l_s_source_cob_pro>

TYPE rsd_s_cob_pro.

DATA: l_with_atr_nav l_s_msg l_t_source_cob_pro l_t_target_cob_pro l_th_target_cob_pro e_is_compliant = rs_c_true. * check is weaker if target is ODS object IF g_target_cubetype = rsd_c_cubetype-ods_ic. l_with_atr_nav = rs_c_false. ELSE. l_with_atr_nav = rs_c_true. ENDIF. * get all infoobjects of source infocube CALL FUNCTION 'RSD_COB_PRO_ALL_GET' EXPORTING i_infocube = i_source_infocube i_with_atr_nav = l_with_atr_nav i_with_meta_iobj = rs_c_true IMPORTING e_t_cob_pro = l_t_source_cob_pro EXCEPTIONS infocube_not_found = 1 error_reading_infocatalog = 2 illegal_input = 3. IF sy-subrc <> 0. l_subrc = sy-subrc. PERFORM msg_to_protocol USING 'R9' 'E' '144' TYPE TYPE TYPE TYPE TYPE rs_bool, rs_s_msg, rsd_t_cob_pro, rsd_t_cob_pro, rsd_th_cob_pro.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 21

Copying Queries Between InfoSets

i_source_infocube space space space CHANGING l_s_msg. INSERT l_s_msg INTO TABLE c_t_msg. EXIT. ENDIF. * get all infoobjects of target infocube CALL FUNCTION 'RSD_COB_PRO_ALL_GET' EXPORTING i_infocube = i_target_infocube i_with_atr_nav = rs_c_true i_with_meta_iobj = rs_c_true IMPORTING e_t_cob_pro = l_t_target_cob_pro EXCEPTIONS infocube_not_found = 1 error_reading_infocatalog = 2 illegal_input = 3. IF sy-subrc <> 0. l_subrc = sy-subrc. PERFORM msg_to_protocol USING 'R9' 'E' '144' i_target_infocube space space space CHANGING l_s_msg. INSERT l_s_msg INTO TABLE c_t_msg. EXIT. ENDIF. * check if all infoobjects of source infocube are contained in * target infocube l_th_target_cob_pro = l_t_target_cob_pro. LOOP AT l_t_source_cob_pro ASSIGNING <l_s_source_cob_pro> WHERE chasel <> rsd_c_chasl-not_allowed AND iobjnm <> '0REQUID' AND iobjnm <> '0INFOPROV'. *CAUTION! Need to check set of queries in the future. READ TABLE l_th_target_cob_pro WITH KEY infoprov = i_target_infocube FIELDNM = <l_s_source_cob_pro>-FIELDNM TRANSPORTING NO FIELDS. IF sy-subrc <> 0. * infoobject is missing e_is_compliant = rs_c_false. PERFORM msg_to_protocol USING 'R9'

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 22

Copying Queries Between InfoSets

'E' '147' i_target_infocube <l_s_source_cob_pro>-iobjnm space space CHANGING l_s_msg. INSERT l_s_msg INTO TABLE c_t_msg. ENDIF. ENDLOOP. ENDFORM. " check_infocube_compliance *&---------------------------------------------------------------------* *& Form copy_query_to_infocube *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM copy_query_to_infocube USING i_source_compuid TYPE rsz_uid i_t_comp_rename TYPE rzd1_t_comp_rename i_target_infocube TYPE rsd_infocube i_deftp TYPE rzd1_deftp CHANGING c_subrc LIKE sy-subrc c_t_msg TYPE rs_t_msg c_t_uid_server TYPE rzx0_t_uid_server_x. DATA: l_target_compid TYPE rszcompdir-compid, l_t_uid_server TYPE rzx0_t_uid_server, l_s_uid_server TYPE rzx0_s_uid_server_x, l_s_msg TYPE rs_s_msg, l_s_compdir TYPE rzx0_s_compdir, l_s_eltdir TYPE rzx0_s_eltdir, l_s_elttxt TYPE rzx0_s_elttxt, l_t_eltdir TYPE rzx0_t_eltdir, l_t_eltprop TYPE rzx0_t_eltprop, l_t_eltprio TYPE rzx0_t_eltprio, l_t_eltattr TYPE rzx0_t_eltattr, l_t_eltxref TYPE rzx0_t_eltxref, l_t_compdir TYPE rzx0_t_compdir, l_t_compic TYPE rzx0_t_compic, l_t_select TYPE rzx0_t_select, l_t_range TYPE rzx0_t_range, l_t_calc TYPE rzx0_t_calc, l_t_elttxt TYPE rzx0_t_elttxt, l_t_cell TYPE rzx0_t_cel. DATA: l_t_comp_rename TYPE l_s_comp_rename TYPE FIELD-SYMBOLS: <l_s_comp_rename> TYPE <l_s_eltdir> TYPE <l_s_compdir> TYPE

rzd1_t_comp_rename, rzd1_s_comp_rename.

rzd1_s_comp_rename, rzx0_s_eltdir, rzx0_s_compdir,

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 23

Copying Queries Between InfoSets

<l_s_compic>

TYPE

rzx0_s_compic.

* get the tables of source query and its components CALL FUNCTION 'RSZ_X_COMPONENT_GET' EXPORTING i_compuid = i_source_compuid i_template_type = i_deftp i_language = '*' i_use_buffer = 'A' i_designtime_call = rs_c_false IMPORTING e_subrc = c_subrc TABLES c_t_eltdir = l_t_eltdir c_t_eltprop = l_t_eltprop c_t_eltprio = l_t_eltprio c_t_eltattr = l_t_eltattr c_t_eltxref = l_t_eltxref c_t_compdir = l_t_compdir c_t_compic = l_t_compic c_t_select = l_t_select c_t_range = l_t_range c_t_calc = l_t_calc c_t_elttxt = l_t_elttxt c_t_cell = l_t_cell. IF c_subrc <> 0. * get and convert messages from msg server PERFORM get_messages CHANGING c_t_msg. EXIT. ENDIF. * * modify COMPIDs to new values: Query name is given all other names must be generated PERFORM rename_components USING i_source_compuid i_target_infocube l_t_eltdir c_t_uid_server CHANGING l_target_compid l_t_compdir l_t_compic c_subrc c_t_msg. LOOP AT l_t_compdir ASSIGNING <l_s_compdir>. READ TABLE i_t_comp_rename ASSIGNING <l_s_comp_rename> WITH KEY compuid = <l_s_compdir>-compuid. IF sy-subrc = 0. <l_s_compdir>-compid = <l_s_comp_rename>-compid_new. ENDIF.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 24

Copying Queries Between InfoSets

ENDLOOP. * Setting the target InfoProvider LOOP AT l_t_compic ASSIGNING <l_s_compic>. <l_s_compic>-infocube = i_target_infocube. ENDLOOP. IF c_subrc = 0. save tables under the new name (COMPID) copy_mode = true leads to replacement of all ELTUIDs l_t_uid_server[] = c_t_uid_server[]. CALL FUNCTION 'RSZ_X_COMPONENT_SET' EXPORTING i_compuid = i_source_compuid I_OBJVERS = 'A' i_copy_mode = rs_c_true i_language = '*' IMPORTING E_GENUNIID = e_subrc = c_subrc TABLES c_t_eltdir = l_t_eltdir c_t_eltprop = l_t_eltprop c_t_eltprio = l_t_eltprio c_t_eltattr = l_t_eltattr c_t_eltxref = l_t_eltxref c_t_compdir = l_t_compdir c_t_compic = l_t_compic c_t_select = l_t_select c_t_range = l_t_range c_t_calc = l_t_calc c_t_elttxt = l_t_elttxt c_t_cell = l_t_cell c_t_uid_server = l_t_uid_server. c_t_uid_server[] = l_t_uid_server[]. fill tech name LOOP AT l_t_compdir INTO l_s_compdir. update tech name l_s_uid_server-compid = l_s_compdir-compid. MODIFY c_t_uid_server FROM l_s_uid_server TRANSPORTING compid WHERE virtual = l_s_compdir-compuid. ENDLOOP. ENDIF. IF c_subrc <> 0.

* *

get and convert messages from msg server PERFORM get_messages CHANGING c_t_msg. EXIT. ELSE. * Add all copied components to the protocol LOOP AT l_t_compdir ASSIGNING <l_s_compdir>.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 25

Copying Queries Between InfoSets

READ TABLE l_t_eltdir ASSIGNING <l_s_eltdir> WITH KEY eltuid = <l_s_compdir>-compuid. IF sy-subrc = 0 AND <l_s_eltdir>-deftp NE rzd1_c_deftp-variable. PERFORM msg_to_protocol USING 'R9' 'S' '202' <l_s_compdir>-compid <l_s_eltdir>-deftp i_target_infocube space CHANGING l_s_msg. APPEND l_s_msg TO c_t_msg. ENDIF. ENDLOOP. ENDIF. ENDFORM. " copy_query_to_info *&---------------------------------------------------------------------* *& Form rename_components *&---------------------------------------------------------------------* * remodelled with J19K003184 *----------------------------------------------------------------------* FORM rename_components USING i_source_compuid TYPE rsz_uid i_target_infocube TYPE rsd_infocube i_t_eltdir TYPE rzx0_t_eltdir i_t_uid_server TYPE rzx0_t_uid_server_x CHANGING c_target_compid TYPE rszcompid c_t_compdir TYPE rzx0_t_compdir c_t_compic TYPE rzx0_t_compic c_subrc LIKE sy-subrc c_t_msg TYPE rs_t_msg. CONSTANTS: c_number(10) c_customer_prefix(1) DATA: l_s_uid_server l_t_compdir_rename l_s_eltdir l_subrc l_comp_not_found * l_suffix(2) l_sys_type l_s_compic l_s_compdir * l_Len * l_next_suffix

TYPE c VALUE '0123456789', TYPE c VALUE 'Z'.

TYPE rzx0_s_uid_server_x, TYPE rzx0_t_compdir, TYPE rzx0_s_eltdir, LIKE sy-subrc, TYPE rs_bool, TYPE c, TYPE rs_systp, TYPE rzx0_s_compic, TYPE rzx0_s_compdir, type i, type i,

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 26

Copying Queries Between InfoSets

l_retry l_pos l_maxlen l_trunk

TYPE TYPE TYPE TYPE

rs_bool, i, i, rszcompdir-compid.

* determine technicallength of compid. DESCRIBE FIELD l_s_compdir-compid LENGTH l_maxlen IN CHARACTER MODE. * get system type CALL FUNCTION 'RRSV_SYSTYPE_GET' IMPORTING sys_type = l_sys_type. * backup component table l_t_compdir_rename = c_t_compdir. * remove variables LOOP AT i_t_eltdir INTO l_s_eltdir WHERE reusable = rs_c_true AND deftp = rzd1_c_deftp-variable. DELETE l_t_compdir_rename WHERE compuid = l_s_eltdir-eltuid. ENDLOOP. * rename reuseable components in case of mass copy LOOP AT i_t_uid_server INTO l_s_uid_server. * update tech name l_s_compdir-compid = l_s_uid_server-compid. MODIFY c_t_compdir FROM l_s_compdir TRANSPORTING compid WHERE compuid = l_s_uid_server-virtual. * update infocube MOVE-CORRESPONDING l_s_compdir TO l_s_compic. l_s_compic-infocube = i_target_infocube. MODIFY c_t_compic FROM l_s_compic TRANSPORTING infocube WHERE compuid = l_s_uid_server-virtual. DELETE l_t_compdir_rename WHERE compuid = l_s_uid_server-virtual. ENDLOOP. * rename the rest LOOP AT l_t_compdir_rename INTO l_s_compdir. IF l_s_compdir-compuid = i_source_compuid AND NOT c_target_compid IS INITIAL. l_s_compdir-compid = c_target_compid. ELSE. l_pos = sy-tabix. * extract a suffix if present DATA l_index TYPE i. PERFORM extract_suffix USING l_s_compdir-compid CHANGING l_trunk l_index. l_retry = rs_c_true. * loop is broken by exit (if found). WHILE l_retry = rs_c_true. * l_retry = rs_c_false. * next attempt for unique name.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 27

Copying Queries Between InfoSets

PERFORM generate_next_unique_name USING l_maxlen CHANGING l_index l_trunk l_s_compdir-compid. * Enforce proper namespace IF l_sys_type = rs_sys_cus AND l_s_compdir-compid(1) CO c_number. l_s_compdir-compid(1) = c_customer_prefix. ENDIF. * it happened that % signs were stored in tch names of CKFs REPLACE '%' WITH '_' INTO l_s_compdir-compid. REPLACE '-' WITH '_' INTO l_s_compdir-compid. CALL FUNCTION 'RSZ_X_COMPONENT_EXIST' EXPORTING i_compid = l_s_compdir-compid I_OBJVERS = 'A' I_COMPUID = i_check_name = rs_c_true IMPORTING e_subrc = l_subrc e_component_not_found = l_comp_not_found.

* *

IF l_comp_not_found = rs_c_false. continue ELSEIF l_subrc <> 0 AND l_subrc <> 1 AND l_subrc <> 6. "l_subrc = 0: Component not found "l_subrc = 1: Component not found "l_subrc = 6: Reserved name create sap * get and convert messages from msg server PERFORM get_messages CHANGING c_t_msg. * if we get here, we are in trouble, no need to check for existence. c_subrc = l_subrc. EXIT. ELSE. * verify that compid is unique among the already generated entries * (in c_t_compdir[1...(l_pos-1)] [but we test all] ). READ TABLE c_t_compdir WITH KEY compid = l_s_compdircompid TRANSPORTING NO FIELDS. IF ( sy-subrc <> 0 ). EXIT. " the compid is unique! ENDIF. ENDIF. * ENDDO. ENDWHILE. IF l_s_compdir-compuid = i_source_compuid. c_target_compid = l_s_compdir-compid. ENDIF. ENDIF. * update tech name MODIFY c_t_compdir FROM l_s_compdir TRANSPORTING compid WHERE compuid = l_s_compdir-compuid. * update infocube *

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 28

Copying Queries Between InfoSets

MOVE-CORRESPONDING l_s_compdir TO l_s_compic. l_s_compic-infocube = i_target_infocube. MODIFY c_t_compic FROM l_s_compic TRANSPORTING infocube WHERE compuid = l_s_compdir-compuid. ENDLOOP. ENDFORM. " rename_components

*&--------------------------------------------------------------------* *& Form extract_suffix *&--------------------------------------------------------------------* * J19K003184 * given an string ( c-field ). * XXXXXXX_DDDD where D are digits, this * form returns c_trunk = XXXXXXX (wo underscore) * and c_index = DDDD as integer * for DDDD-Sequence < 6 digits. * otherwise C_trunk = input and * c_index = 0. *---------------------------------------------------------------------* * -->I_NAME text * -->C_TRUNK text * -->C_INDEX text *---------------------------------------------------------------------* FORM extract_suffix USING i_name LIKE rszcompdir-compid CHANGING c_trunk TYPE rszcompdir-compid c_index TYPE i. DATA: c_number(10) TYPE c VALUE '0123456789', l_len TYPE i, l_fulllen TYPE i, l_nonlynum(8) TYPE n, l_hasnumber TYPE c VALUE ' '. c_trunk = i_name. c_index = 0. IF i_name CS '_'. * in this case the target may already contain a number l_fulllen = STRLEN( i_name ) . l_len = l_fulllen - 1. IF ( l_len > 1 ). * we start at the end and try to get the old number WHILE i_name+l_len(1) CO c_number. l_len = l_len - 1. l_hasnumber = 'X'. ENDWHILE. DATA l_numsuffixlen TYPE i. l_numsuffixlen = l_fulllen - l_len. IF ( l_hasnumber = 'X' AND l_len > 1 AND l_numsuffixlen < 7 ). " do not treat numeric sequences with more than 6 characters " as integer IF ( i_name+l_len(1) = '_' ). " as good as it gets:

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 29

Copying Queries Between InfoSets

c_trunk = i_name(l_len). " string prior _ l_len = l_len + 1. l_nonlynum = i_name+l_len(*). " the DDD sequence. c_index = l_nonlynum. EXIT. ENDIF. ENDIF. ENDIF. ENDIF. ENDFORM. "extract_suffix

*&--------------------------------------------------------------------* *& Form generate_next_unique_name *&--------------------------------------------------------------------* * J19K003184 *---------------------------------------------------------------------* * -->I_MAXLEN text * -->C_INDEX text * -->C_TRUNK text * -->C_NEXTNAME text * strategy: append _1 _2,..... _999999999 * (if strlen is exceeded, we start to gobble up previous chars: * Example for string len c(5) * AA_1 < * AA_9 < * AA_10< *... * AA_91 * AA_92 * AA_99 * A_100 * A_101 *---------------------------------------------------------------------* FORM generate_next_unique_name USING i_maxlen TYPE i " max length of char CHANGING c_index TYPE i c_trunk TYPE rszcompdir-compid c_nextname TYPE rszcompdir-compid. * optimization potential (carry t_pos along ). * todo: extract l_index if wanted from suffix and reduce DATA l_tpos TYPE i. " target position DATA l_nlen TYPE i. " length of numerical string. DATA l_cbuf(8) TYPE c. DATA l_ctrunk TYPE rszcompdir-compid. DATA l_trunklen TYPE i. l_trunklen = STRLEN( c_trunk ). l_tpos = l_trunklen + 1. " 1 for '_' c_index = c_index + 1. "this is brute force, but people may enter XX9999999999_999999 for fun. IF c_index > 999999 . c_index = 1. ENDIF. WRITE c_index TO l_cbuf LEFT-JUSTIFIED NO-GROUPING.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 30

Copying Queries Between InfoSets

l_nlen = STRLEN( l_cbuf ). l_tpos = STRLEN( c_trunk ). " if _number does not fit into string, " we shorten c_trunk. DATA l_fit TYPE i. l_fit = i_maxlen - l_nlen - 1. IF ( l_fit < l_tpos ). c_trunk = c_trunk(l_fit). l_tpos = l_fit. ENDIF. CONCATENATE c_trunk '_' l_cbuf INTO c_nextname. ENDFORM. "generate_next_unique_name

*&---------------------------------------------------------------------* *& Form get_messages *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM get_messages CHANGING c_t_msg TYPE rs_t_msg. DATA: l_s_msg l_t_rrms_mesg l_s_rrms_mesg

TYPE rs_s_msg, TYPE rrms_t_mesg, TYPE rrms_s_mesg.

* * *

* * * *

CALL FUNCTION 'RRMS_MESSAGES_OUTPUT' EXPORTING I_HANDLE = I_NO_LAST_CALLS = IMPORTING e_t_mesg = l_t_rrms_mesg. E_MAX_SEVERITY = EXCEPTIONS INVALID_HANDLE = 1 OTHERS = 2 LOOP AT l_t_rrms_mesg INTO l_s_rrms_mesg. l_s_msg-msgty = l_s_rrms_mesg-msgty. l_s_msg-msgid = l_s_rrms_mesg-arbgb. l_s_msg-msgno = l_s_rrms_mesg-txtnr. l_s_msg-msgv1 = l_s_rrms_mesg-msgv1. l_s_msg-msgv2 = l_s_rrms_mesg-msgv2. l_s_msg-msgv3 = l_s_rrms_mesg-msgv3. l_s_msg-msgv4 = l_s_rrms_mesg-msgv4. APPEND l_s_msg TO c_t_msg. ENDLOOP.

ENDFORM. " get_messages *&---------------------------------------------------------------------* *& Form set_selection_screen_status *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------*

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 31

Copying Queries Between InfoSets

FORM set_selection_screen_status. DATA: l_t_exclude TYPE STANDARD TABLE OF rsexfcode. * this call sets the custom status 'COPY' to the selection screen * we needed to have a docu button CALL FUNCTION 'RS_SET_SELSCREEN_STATUS' EXPORTING p_status = 'COPY' * P_PROGRAM = ' ' TABLES p_exclude = l_t_exclude. ENDFORM. " set_selection_screen_status

*&---------------------------------------------------------------------* *& Form process_user_command *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM process_user_command. CASE sscrfields-ucomm. WHEN 'CRET'. native selection screen command WHEN 'CCAN'. native selection screen command WHEN 'INFO'. show documentation CALL FUNCTION 'POPUP_DISPLAY_TEXT' EXPORTING LANGUAGE = SY-LANGU popup_title = text-003 START_COLUMN = 10 START_ROW = 3 text_object = 'RS_COPY_QUERIES' HELP_MODAL = 'X' IMPORTING CANCELLED = EXCEPTIONS text_not_found = 0 OTHERS = 0. INFO is a user command "on exit" in order to skip field checks however we need to go back to the screen therefore... SET SCREEN sy-dynnr. LEAVE SCREEN. ENDCASE. ENDFORM. " process_user_command *&---------------------------------------------------------------------* *& Form launch_cube_f4 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------*

* * *

* * * * * *

* *

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 32

Copying Queries Between InfoSets

FORM launch_cube_f4 CHANGING c_infocube

TYPE rsd_infocube.

TYPES: BEGIN OF lt_ip, infoprov TYPE rsinfoprov, icon TYPE icon_d, txtlg TYPE rs_txtlg, END OF lt_ip. DATA: l_t_dta l_icon l_icon_id DATA: l_s_ip DATA: l_t_ip DATA: l_s_retval DATA: l_t_retval FIELD-SYMBOLS: <l_s_dta>

TYPE rsd_t_dta, TYPE rsd_icon_stat, TYPE i. TYPE lt_ip. TYPE lt_ip OCCURS 0. LIKE ddshretval. LIKE ddshretval OCCURS 0.

TYPE rsd_s_dta.

CALL METHOD cl_rsd_dta=>get_all EXPORTING i_objvers = rs_c_objvers-active IMPORTING e_t_dta = l_t_dta. LOOP AT l_t_dta ASSIGNING <l_s_dta>. * Determine Icons CALL METHOD cl_rsd_dta=>get_icon EXPORTING i_tlogo = <l_s_dta>-tlogo IMPORTING e_icon = l_icon. CALL FUNCTION 'RSAH_ICON_GET_INDEX' EXPORTING i_icon_name = l_icon IMPORTING e_icon_index = l_icon_id. * Authorization check for DISPLAY at least * CREATE authorization for the target IP is checked later CALL FUNCTION 'RSSB_AUTHORITY_COMP_CHECK' EXPORTING i_infoarea = <l_s_dta>-infoarea i_infocube = <l_s_dta>-infoprov i_comptype = space i_compid = space i_owner = space i_actvt = '03' EXCEPTIONS

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 33

Copying Queries Between InfoSets

user_not_authorized = 1 OTHERS = 2. IF sy-subrc <> 0. * If no DISPLAY check for CHANGE CALL FUNCTION 'RSSB_AUTHORITY_COMP_CHECK' EXPORTING i_infoarea = <l_s_dta>-infoarea i_infocube = <l_s_dta>-infoprov i_comptype = space i_compid = space i_owner = space i_actvt = '02' EXCEPTIONS user_not_authorized = 1 OTHERS = 2. IF sy-subrc <> 0. * If no DISPLAY or CHANGE authorization --> delete from list DELETE TABLE l_t_dta FROM <l_s_dta>. CONTINUE. ENDIF. ENDIF. l_s_ip-infoprov = <l_s_dta>-infoprov. l_s_ip-txtlg = <l_s_dta>-txtlg. l_s_ip-icon = l_icon. APPEND l_s_ip TO l_t_ip. CLEAR l_s_ip. ENDLOOP.

SORT l_t_ip BY infoprov. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'INFOPROV' window_title = text-001 value = '*' value_org = 'S' * multiple_choice = ' ' display = rs_c_false TABLES value_tab = l_t_ip return_tab = l_t_retval EXCEPTIONS OTHERS = 3. READ TABLE l_t_retval INTO l_s_retval INDEX 1. IF sy-subrc EQ 0. c_infocube = l_s_retval-fieldval. ENDIF. *** Old F4 part * DATA: * l_t_cubetype TYPE rsd_t_cubetype, * l_s_cubetype TYPE rsd_s_cubetype. *

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 34

Copying Queries Between InfoSets

* * * * * * * * * * * * * * * *

l_s_cubetype-cubetype = rsd_c_cubetype-basic_ic. APPEND l_s_cubetype TO l_t_cubetype. l_s_cubetype-cubetype = rsd_c_cubetype-multi_ic. APPEND l_s_cubetype TO l_t_cubetype. l_s_cubetype-cubetype = rsd_c_cubetype-ods_ic. APPEND l_s_cubetype TO l_t_cubetype. l_s_cubetype-cubetype = rsd_c_cubetype-remote_ic. APPEND l_s_cubetype TO l_t_cubetype. CALL FUNCTION 'RSD_CUBE_F4' EXPORTING i_t_cubetype = l_t_cubetype IMPORTING e_cubetype = g_target_cubetype CHANGING c_infocube = c_infocube.

ENDFORM. " launch_cube_f4 *&---------------------------------------------------------------------* *& Form rename_suggest *&---------------------------------------------------------------------* FORM rename_suggest CHANGING c_t_comp_rename TYPE rzd1_t_comp_rename c_subrc LIKE sy-subrc c_t_msg TYPE rs_t_msg. CONSTANTS: c_number(10) c_customer_prefix(1) FIELD-SYMBOLS: <l_s_comp_rename>

TYPE c VALUE '0123456789', TYPE c VALUE 'Z'.

TYPE rzd1_s_comp_rename.

DATA: l_sys_type l_maxlen l_index l_trunk l_pos l_subrc l_comp_not_found l_compid_new TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE rs_systp, i, i, rszcompdir-compid, i, sy-subrc, rs_bool, rszcompdir-compid.

* Determine technical length of compid. DESCRIBE FIELD <l_s_comp_rename>-compid_old LENGTH l_maxlen IN CHARACTER MODE. * Get system type CALL FUNCTION 'RRSV_SYSTYPE_GET' IMPORTING sys_type = l_sys_type. * Find new name for suggustion LOOP AT c_t_comp_rename ASSIGNING <l_s_comp_rename>.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 35

Copying Queries Between InfoSets

* *

* * *

l_compid_new = <l_s_comp_rename>-compid_old. l_pos = sy-tabix. Extract a suffix if present PERFORM extract_suffix USING l_compid_new CHANGING l_trunk l_index. Loop is broken by exit (if found). WHILE 1 = 1. Next attempt for unique name. PERFORM generate_next_unique_name USING l_maxlen CHANGING l_index l_trunk l_compid_new. Enforce proper namespace IF l_sys_type = rs_sys_cus AND l_compid_new(1) CO c_number. l_compid_new(1) = c_customer_prefix. ENDIF. It happened that % signs were stored in tch names of CKFs MP30B30 Some queries contain more than 1 sign... Here are MORE cases to add..... REPLACE ALL OCCURRENCES OF '%' IN l_compid_new WITH '_'. REPLACE ALL OCCURRENCES OF '-' IN l_compid_new WITH '_'. CALL FUNCTION 'RSZ_X_COMPONENT_EXIST' EXPORTING i_compid = l_compid_new i_check_name = rs_c_true IMPORTING e_subrc = l_subrc e_component_not_found = l_comp_not_found. IF l_comp_not_found = rs_c_false. continue ELSEIF l_subrc <> 0 AND l_subrc <> 1 AND l_subrc <> 6. "l_subrc = 0: Component not found "l_subrc = 1: Component not found "l_subrc = 6: Reserved name create sap

* Get and convert messages from msg server PERFORM get_messages CHANGING c_t_msg. * If we get here, we are in trouble, no need to check for existence. c_subrc = l_subrc. EXIT. ELSE. * Verify that compid is unique among the already generated entries * (in c_t_compdir[1...(l_pos-1)] [but we test all] ). READ TABLE c_t_comp_rename WITH KEY compid_new = l_compid_new TRANSPORTING NO FIELDS. IF ( sy-subrc <> 0 ). EXIT. " the compid is unique!

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 36

Copying Queries Between InfoSets

ENDIF. ENDIF. ENDWHILE. <l_s_comp_rename>-compid_new = l_compid_new. ENDLOOP. ENDFORM. " rename_suggest *&--------------------------------------------------------------------* *& Form RENAME_BY_USER *&--------------------------------------------------------------------* *& - new renaming procedure *&---------------------------------------------------------------------* FORM rename_by_user USING i_source_infoprovider TYPE rsd_infocube i_target_infoprovider TYPE rsd_infocube i_t_eltuid TYPE rsz_t_uid i_deftp TYPE rzd1_deftp CHANGING e_t_comp_rename TYPE rzd1_t_comp_rename e_th_uid_server_all TYPE rzx0_th_uid_server_x c_subrc TYPE sy-subrc c_t_msg TYPE rs_t_msg. DATA: l_ts_eltxref l_th_ref_list l_s_ref_list l_th_eltxref l_th_cmp_join l_s_cmp_join l_s_comp_rename l_s_uid_server l_t_eltuid l_deftp FIELD-SYMBOLS: <l_s_comp_rename>

TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE

rzd1_ts_eltxref, rzd1_th_ref_list, rzd1_s_ref_list, rzd1_th_eltxref, rzd1_th_cmp_join, rzd1_s_cmp_join, rzd1_s_comp_rename, rzx0_s_uid_server_x, rsz_t_uid, rzd1_deftp. "1254898

TYPE

rzd1_s_comp_rename.

* we resolve the given UID list CALL FUNCTION 'RSZ_DB_FULL_XREF_GET' EXPORTING i_objvers = rs_c_objvers-active i_by_infocube = i_source_infoprovider IMPORTING e_ts_eltxref = l_ts_eltxref. * do the resolving PERFORM rsz_resolve_eltxref(sapfrsz1) USING i_t_eltuid l_ts_eltxref CHANGING l_th_eltxref l_th_ref_list.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 37

Copying Queries Between InfoSets

* Select all components SELECT * FROM v_cmp_join INTO TABLE l_th_cmp_join FOR ALL ENTRIES IN l_th_ref_list WHERE compuid = l_th_ref_list-uid AND objvers = rs_c_objvers-active. * We need here to return the DEFTP = SEL for RKF which * was changed for AUTHORITY check IF i_deftp = rzd1_c_deftp-restkeyfig. "1254898 l_deftp = rzd1_c_deftp-selection. "1254898 ENDIF. "1254898 * Start filling table for renaming LOOP AT l_th_cmp_join INTO l_s_cmp_join. IF i_source_infoprovider = i_target_infoprovider AND * l_s_cmp_join-deftp <> rzd1_c_deftp-report. l_s_cmp_join-deftp <> l_deftp. "1254898 * in this case we copy only queries, get rid of all components * because this is not possible, we enter all uid's of all components * and their dependent elements as already copied with same uid l_s_uid_server-virtual = l_s_cmp_join-compuid. l_s_uid_server-actual = l_s_cmp_join-compuid. l_s_uid_server-compid = l_s_cmp_join-compid. READ TABLE e_th_uid_server_all WITH TABLE KEY virtual = l_s_uid_server-virtual TRANSPORTING NO FIELDS. IF sy-subrc <> 0. INSERT l_s_uid_server INTO TABLE e_th_uid_server_all. ENDIF. * find also all dependents CLEAR: l_th_eltxref, l_th_ref_list, l_t_eltuid. APPEND l_s_cmp_join-compuid TO l_t_eltuid. * l_s_comp_rename-compuid = l_s_cmp_join-compuid. * l_s_comp_rename-compid_old = l_s_cmp_join-compid. * l_s_comp_rename-deftp = l_s_cmp_join-deftp. * l_s_comp_rename-infocube = i_target_infoprovider. * APPEND l_s_comp_rename TO e_t_comp_rename. PERFORM rsz_resolve_eltxref(sapfrsz1) USING l_t_eltuid l_ts_eltxref CHANGING l_th_eltxref l_th_ref_list. LOOP AT l_th_ref_list INTO l_s_ref_list. CLEAR: l_s_uid_server. l_s_uid_server-virtual = l_s_ref_list-uid. l_s_uid_server-actual = l_s_ref_list-uid. READ TABLE e_th_uid_server_all WITH TABLE KEY virtual = l_s_uid_server-virtual TRANSPORTING NO FIELDS. IF sy-subrc <> 0. INSERT l_s_uid_server INTO TABLE e_th_uid_server_all. ENDIF.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 38

Copying Queries Between InfoSets

ENDLOOP. ELSE. l_s_comp_rename-compuid = l_s_cmp_join-compuid. l_s_comp_rename-compid_old = l_s_cmp_join-compid. l_s_comp_rename-deftp = l_s_cmp_join-deftp. l_s_comp_rename-infocube = i_target_infoprovider. APPEND l_s_comp_rename TO e_t_comp_rename. ENDIF. ENDLOOP. * suggest new names for components PERFORM rename_suggest CHANGING e_t_comp_rename c_subrc c_t_msg. * Call dialog for renaming CALL FUNCTION 'RSZ_P_DB_COMP_RENAME_AS_POPUP' CHANGING c_t_comp_rename = e_t_comp_rename EXCEPTIONS cancelled = 1. c_subrc = sy-subrc. IF c_subrc > 0. * MESSAGE a021. EXIT. ENDIF. ENDFORM. "RENAME_BY_USER

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 39

Copying Queries Between InfoSets

Related Content
For more information, visit the Business Intelligence Home Page

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 40

Copying Queries Between InfoSets

Disclaimer and Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 41

Copying Queries Between InfoSets

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 42

You might also like