Sei sulla pagina 1di 10

SAP BW Copy Existing DTP for Data Targets

Applies to:
SAP BI Consultants with ABAP Knowledge. For more information, visit the EDW HomePage .

Summary
Copy existing DTP to a new one in not possible in SAP BI 7.0, to make it workable created a CLASS (ABAP) to copy DTP to a new one. Author: Suraj Tigga

Company: Capgemini Consulting Created on: 08 November 2010

Author Bio
Suraj Tigga is a Senior SAP BI / ABAP consultant at Capgemini Consulting. Suraj joined Capgemini Consulting in 2008 and has worked on multiple SAP BI implementation and support projects.

SAP COMMUNITY NETWORK 2010 SAP AG

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

SAP BW Copy Existing DTP for Data Targets

Table of Contents
Scenario .............................................................................................................................................................. 3 Step-by-Step Solution ..................................................................................................................................... 3
Class (ABAP) ............................................................................................................................................................... 3 Method (COPY_DTP) .................................................................................................................................................. 5 ABAP - Z_COPY_DTP_ABAP ..................................................................................................................................... 6 Execute Class (ABAP) ................................................................................................................................................. 7

Related Content .................................................................................................................................................. 9 Disclaimer and Liability Notice .......................................................................................................................... 10

SAP COMMUNITY NETWORK 2010 SAP AG

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

SAP BW Copy Existing DTP for Data Targets

Scenario
Copying existing DTP is not possible in SAP BI 7.0, so every time we want to copy a existing DTP, we have to create a new one. Here in this article developed Class (ABAP), which would help us copy the existing DTP for different data targets (Infocubes, DSO, Infoobject Attributes, Infoobject Text and Infoobject Hierarchies) Step-by-Step Solution Below are the steps mentioned to copy the DTP based on existing DTP (Built on DSO): Class (ABAP): ABAP class would be created with required Definition and Implementation. Method: ABAP code which copies the existing DTP definition to a new one. Execute Class (ABAP): Executes the Class (ABAP) to copy the DTP in M version and then activate it. Class (ABAP) Copy the existing DTP (Full Update) on DSO (ZQMNTST):

Step1: Go to transaction SE24 and create a Class Z_DTP_COPY:

SAP COMMUNITY NETWORK 2010 SAP AG

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

SAP BW Copy Existing DTP for Data Targets

Step2: Create a Method COPY_DTP:

Maintain the Importing and Exporting parameters for the Method:

Maintain Exception (Error):

SAP COMMUNITY NETWORK 2010 SAP AG

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

SAP BW Copy Existing DTP for Data Targets

Method (COPY_DTP) Write the ABAP Code to copy the existing DTP

Activate the Class (ABAP):

SAP COMMUNITY NETWORK 2010 SAP AG

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

SAP BW Copy Existing DTP for Data Targets

ABAP - Z_COPY_DTP_ABAP Step1: ABAP Code Z_COPY_DTP_ABAP to call the Class Z_DTP_COPY:
REPORT z_copy_dtp_abap.

******* DATA DECLARATION *********** DATA : BEGIN OF p_tab OCCURS 0, dtp(30) TYPE c, END OF p_tab , lt_return TYPE STANDARD TABLE OF ddshretval, wl_return TYPE ddshretval , e_dtp_copy TYPE rsbkdtpnm , zc_dtp_copy TYPE REF TO z_dtp_copy. DATA: valu_flds TYPE dfies OCCURS 0 , valu_flds_wa TYPE dfies , w_dtp TYPE rsbkdtpnm. ******* SELECTION SCREEN ***************** * DTP entered PARAMETERS : p_dtp TYPE rsbkdtpnm . ******* AT SELECTION SCREEN ON VALUE ****** AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dtp. * Retreive the values from DB table RSBKDTP SELECT dtp FROM rsbkdtp INTO TABLE p_tab WHERE objvers EQ 'A'. IF sy-subrc EQ 0. * Sort the internal table with DTP SORT p_tab BY dtp. * Pass the Field definition of DTP valu_flds_wa-tabname = 'RSBKDTP'. valu_flds_wa-fieldname = 'DTP'. APPEND valu_flds_wa TO valu_flds. * Call the FM to retrieve the values in F4 help CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'DTP' dynpprog = sy-repid dynpnr = sy-dynnr dynprofield = 'P_DTP' window_title = 'DTP Selection' TABLES value_tab = p_tab field_tab = valu_flds return_tab = lt_return . IF sy-subrc EQ 0. READ TABLE lt_return INTO wl_return INDEX 1. IF sy-subrc EQ 0. w_dtp = wl_return-fieldval. ENDIF. ENDIF. ENDIF.

SAP COMMUNITY NETWORK 2010 SAP AG

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

SAP BW Copy Existing DTP for Data Targets

***** START -OF-SELECTION ************* START-OF-SELECTION. * Call method to copy DTP CALL METHOD z_dtp_copy=>copy_dtp EXPORTING i_dtp = w_dtp i_dtp_txt = 'Test' i_dtp_prefix = ' ' IMPORTING e_dtp_copy = e_dtp_copy. IF sy-subrc EQ 0. WRITE : 'DTP Copied ' , e_dtp_copy. ENDIF.

Execute Class (ABAP) This is an example of a code sample: Step1: Execute (F8) the ABAP Code Z_COPY_DTP_ABAP and enter the DTP which has to be copied:

Step2: Execute the ABAP code which copied the DTP to a new one:

SAP COMMUNITY NETWORK 2010 SAP AG

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

SAP BW Copy Existing DTP for Data Targets

Step3: Check the newly created DTP:

Activate the DTP DTP_4JRXZZHDYPBZF0QICXJ13QASR

SAP COMMUNITY NETWORK 2010 SAP AG

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

SAP BW Copy Existing DTP for Data Targets

Related Content
For more information, visit the EDW HomePage .

SAP COMMUNITY NETWORK 2010 SAP AG

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

SAP BW Copy Existing DTP for Data Targets

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 2010 SAP AG

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

Potrebbero piacerti anche