Skip to Content

Summary

This article gives clear picture about how to copy Bex query from a destination system to the source system by running a custom program.


Introduction

  Using an ABAP program we can copy the Bex query across the systems. There are scenarios like, the Bex Query is developed directly in production system and in order to have all the systems (development, test and production) in line, we might want to copy the queries across the systems without recreating in each of the systems which is time consuming. Instead, we can create a custom program to copy the queries between the systems


Scenario

Let’s take an example of a Bex query “ZTEST_QUERY1” which is available in production system ‘PRO’ to be copied to Development system ‘DEV’.


Function modules

  • RSZ_X_COMPONENT_GET
  • RSZ_X_COMPONENT_SET

Custom program Explained

Let’s create a custom program ZCOPY_QUERY with a selection screen allowing the user to provide the Query name in the destination system, destination system name and name to be copied to the source system.



Selection Screen:


S1.jpg






RSZ_X_COMPONENT_GET:


Function module RSZ_X_COMPONENT_GET is used to get the Query elements of the query in the production system PRO.



The above function module reads the query definition from the remote system.

Modify internal table IT_ELTDIR with the new query name to be copied to. 

RSZ_X_COMPONENT_SET:


Function module RSZ_X_COMPONENT_SET is used to create a query in the source system.


Once the program is executed with these two function modules described above the query will be copied to the source system as expected.


S2.jpg


Tables being used:


RSRREPDIR     Directory of all reports
RSZCOMPIC     Assignment reusable component <Infocube>
RSZCOMPDIR   Directory of reporting components
RSZELTXREF    Directory of query element references
RSZGLOBV      Global Variables in Reporting
RSZELTDIR     Directory of the reporting component elements
RSZCALC          Definition of a formula element
RSZELTPROP Element properties (settings)
RSZELTPRIO Priorities with element collisions
RSZSELECT Selection properties of an element
RSZRANGE

Selection specification for an element


Caution:

Copying procedure also copies all reusable component used in this query. Such as, Calculated Key Figures, Restricted Key Figures, Structures, Variables and Selection Objects. Someone would only identify these duplicated components only when the query is opened using Bex 7.X or higher, this could cause many inconsistencies when running reports.

Use report ANALYZE_RSZ_TABLES (notes 792779 and 853826) for detection of both situations (Table RSZCOMPDIR). The program allows renaming of duplicated queries and query components.

S3.jpg

S4.jpg

S5.jpg


Recommendation:


Recommended workaround is to use ‘Save As…’  functionality. This can be achieved by passing I_COPY_MODE = “L” in the function module RSZ_X_COMPONENT_SET_NEW.

S6.jpg

Conclusion:


Using an ABAP program with the above function modules described, we can copy the Bex query across the systems.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Suhas Karnik

    Hi Rajesh,

    Interest approach. Wouldn’t it be simpler though to just transport the query from one system to another?

    Regards,

    Suhas

    (0) 
    1. Markus Alterauge

      Hi Suhas,

      transportation is an alterantive. However, mostly only a few queries origin in a development system, often it is business that develops such queries directly in the productive environment. Also, not all systems might share a common transporting environment.

      Greetings

      Markus

      (0) 

Leave a Reply