DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Centralized Job Execution Strategy in Cloud Data Warehouses
  • Parent Document Retrieval (PDR): Useful Technique in RAG
  • Fighting Climate Change One Line of Code at a Time
  • How To Start With Low Coding: Expert’s Guide on Developing Business Applications With SAP Build Apps

Trending

  • Engineering Closed-Loop Graph-RAG Systems, Part 2: From Prompts to Rules
  • I Reverse-Engineered 50 API Breaches. The Same Five Mistakes Keep Appearing.
  • A Deep Dive into Tracing Agentic Workflows (Part 2)
  • Getting Started With GitHub Copilot CLI for Coding Tasks
  1. DZone
  2. Data Engineering
  3. Data
  4. Program To Force Copy SAP Bex Queries

Program To Force Copy SAP Bex Queries

This article aims to demonstrate how you can force copy Bex query designer queries from one Infoprovider to another, which have different structures.

By 
Maheshsingh Mony user avatar
Maheshsingh Mony
·
Nov. 27, 23 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
2.6K Views

Join the DZone community and get the full member experience.

Join For Free

Applies To

SAP BI/BW 7.0, 7.1, 7.2, 7.3 etc. For more information. 

Summary 

This article aims to demonstrate how to force copy Bex query designer queries from one Infoprovider to another, which have different structures. (I.e., not all fields of the source infoprovider are present in the target infoprovider).

Introduction 

In SAP BI, we all know that we can copy queries between two info providers through the T-code RSZC. However, to copy queries between these Info providers, both source and target Infoproviders must have the same structure. 

But in many cases, it is not possible to copy queries between two info providers as they don't have the same no of fields or have some files missing in them. 

To overcome this issue, I have created a custom program with the name "ZBI_FORCE_COPY_QUERY."  by this "Z" program, we will be able to force copy the queries between two Infoproviders with different structures. 

Step 1: Creating a Custom Program 

Go to T-code Se38 and create a custom executable program. 

Go to T-code Se38 and create a custom executable program.

Enter the below entries in the “Selection Texts” tab. 

Enter the below entries in the “Selection Texts” tab.

Enter the below entries in the "Text Symbols" tab. 

Enter the below entries in the "Text Symbols" tab.

Source Code 

Paste the code below and activate the program.

 
*________________________________________________________________________________*

*&---------------------------------------------------------------------* 

*& Report ZBI_QUERY_FORCECOPY *&

 *&---------------------------------------------------------------------* *& 

*& *&---------------------------------------------------------------------* 

REPORT ZBI_QUERY_FORCECOPY. 

TYPE-POOLS: RS, "BW global 

RRMS, "message server 

RSZ, "Qry definition global 

RZX0, "Qry RFC interface 

RZD1. "Qry definition database 



TABLES: SSCRFIELDS. 



TYPES: BEGIN OF TY_RSRREPDIR, 

     COMPUID TYPE SYSUUID_25, 

     INFOCUBE TYPE RSINFOCUBE, 

     COMPID TYPE RSZCOMPID, 

END OF TY_RSRREPDIR. 



DATA: IT_RSRREPDIR TYPE TABLE OF TY_RSRREPDIR, 

            WA_RSRREPDIR LIKE LINE OF IT_RSRREPDIR. 

DATA: C_T_UID_SERVER TYPE RZX0_T_UID_SERVER_X, 

             I_TARGET_INFOCUBE TYPE RSD_INFOCUBE, 

             I_SOURCE_INFOCUBE TYPE RSD_INFOCUBE, 

             I_SOURCE_COMPUID TYPE RSZ_UID. 

DATA: I_T_COMP_RENAME type rzd1_t_comp_rename, 

            WA_COMP_RENAME LIKE LINE OF I_T_COMP_RENAME. 

SELECTION-SCREEN : BEGIN OF BLOCK SS01 WITH FRAME TITLE TEXT-001. 

PARAMETERS : P_SQUERY TYPE RSZCOMPID DEFAULT ' ' OBLIGATORY. 

PARAMETERS : P_TQUERY TYPE RSZCOMPID DEFAULT ' ' OBLIGATORY. 

PARAMETERS : P_TCUBE TYPE RSINFOCUBE DEFAULT ' ' OBLIGATORY. 



SELECTION-SCREEN : END OF BLOCK SS01. 



START-OF-SELECTION. 



SELECT COMPUID INFOCUBE COMPID FROM RSRREPDIR INTO CORRESPONDING FIELDS OF TABLE IT_RSRREPDIR WHERE OBJVERS = 'A' AND COMPID = P_SQUERY. 

IF SY-SUBRC = 0. 

READ TABLE IT_RSRREPDIR INTO WA_RSRREPDIR WITH KEY COMPID = P_SQUERY.

       I_TARGET_INFOCUBE = P_TCUBE.

       I_SOURCE_INFOCUBE = WA_RSRREPDIR-INFOCUBE. 

       I_SOURCE_COMPUID = WA_RSRREPDIR-COMPUID. 

      WA_COMP_RENAME-COMPUID = I_SOURCE_COMPUID. 

      WA_COMP_RENAME-COMPID_OLD = P_SQUERY. 

      WA_COMP_RENAME-COMPID_NEW = P_TQUERY. 

      WA_COMP_RENAME-INFOCUBE = P_TCUBE. 

APPEND WA_COMP_RENAME TO I_T_COMP_RENAME. 



CALL FUNCTION 'RSZ_I_COPY_QRY_TO_CUBE_SINGLE' 

EXPORTING 

           I_SOURCE_COMPUID = I_SOURCE_COMPUID 

           I_SOURCE_INFOCUBE = I_SOURCE_INFOCUBE 

           I_T_COMP_RENAME = I_T_COMP_RENAME

           I_TARGET_INFOCUBE = I_TARGET_INFOCUBE 

           I_CHECK_COMPLIANCE = '' 

CHANGING 

           C_T_UID_SERVER = C_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. 

           MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 

ELSE. 

          MESSAGE 'Query copied successfully' TYPE 'S'. 

ENDIF. 

ELSE. 

         MESSAGE 'Please enter correct Query name' TYPE 'I'. 

ENDIF. 

END-OF-SELECTION. 

*_______________________________________________________________________________*


Step 2: Program Execution 

Once the program has been activated, execute the program, and you will get the below selection screen. 

Once the program has been activated, execute the program, and you will get the below selection screen.

You need to input the values for the below fields present in the selection screen of the program. 

  • The technical name of the Source Query 
  • The technical name of the New Query 
  • Tech name Target Infoprovider 

You can select the Source query name using the F4 option. Here, we have selected the query “ZZMRMBBBP1_Q0024” as the source Query built on the multi-provider “ZMRMBBBP1”. 

Here, we have selected the query “ZZMRMBBBP1_Q0024” as the source Query built on the multiprovider “ZMRMBBBP1”.

This is how the selected query “ZZMRMBBBP1_Q0024 looks in Query Designer.

This is how the selected query “ZZMRMBBBP1_Q0024 looks in Query designer.

Enter the name of the new query and the DSO/Cube/Multiprovider name on which you need the Source query to be copied. 

In our case, the new query name is YZOMMBPS01_Q0021, and the Multiprovider on which it should be built is ZOMMBPS01. 

In our case, the new query name is YZOMMBPS01_Q0021, and the Multiprovider on which it should be built is ZOMMBPS01.

Before execution, the new query does not exist in the system.

Before execution, the new query does not exist in the system.

Execute the program, and you will get the below message.

Execute the program, and you will get the below message.

Check the new query in the query designer. It would now be present in the system. 

Please Note: The program, by default, copies the same description for the new query from the source query, which can be later changed through the query designer. 

Remove the fields that are not present in the new info provider and Click on save. You can now use the new query to fetch data from the new info provider. 

You can also, through transaction Se93, use this program as a Custom T-code. 

You can also, through transaction Se93, use this program as a Custom T-code.

Disclaimer and Liability Notice From SAP

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. 

Document Coding (social sciences) Data (computing) Execution (computing) SAP S/4HANA

Published at DZone with permission of Maheshsingh Mony. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Centralized Job Execution Strategy in Cloud Data Warehouses
  • Parent Document Retrieval (PDR): Useful Technique in RAG
  • Fighting Climate Change One Line of Code at a Time
  • How To Start With Low Coding: Expert’s Guide on Developing Business Applications With SAP Build Apps

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook