How To Schedule Query Extracts Using RSCRM - BAPI
How To Schedule Query Extracts Using RSCRM - BAPI
SAP (SAP America, Inc. and SAP AG) assumes no responsibility for errors or omissions in these materials. These materials are provided as is without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages.
1 Business Scenario
You want to download BW query results. Those file download results should arrive either in flat files, or in transparent tables. The downloaded files should be based on existing BEX query definitions. And most of all, the downloads should be executed repeatedly and fully automated in the background.
2 Introduction
The following step-by-step guide describes how you can achieve the desired results of query result download. It is based on transaction code RSCRM_BAPI, a function available in BW 2.1c since SP 8. (There was another, similar function RSCRM_REPORTavailable already since BW 2.0b, however with more limited functionality. Some of the differences are highlighted in this document). Before you proceed, please view the following important notice: As of release 3.0B (as well as 3.0ASP7), a new functionality called SAP BW Open Hub is available, that enhances BWs openness in an Enterprise Data Warehouse environment. Therefore SAP BW is even more capable of taking over the role of an Open Hub Platform, and to function as well as an information hub and distributor. The Open Hub functionality largely enhances the openness of BW, its capabilities surpass the RSCRM_BAPI capabilities by large. In any case, independent of which extraction method you choose (RSCRM_BAPI, OpenHub, or other tools like LISTUBE), it is important to note that SAP BW Enterprise Data Warehouse de facto will function as an Open Hub Platform. Since extracting data from SAP BW by any means requires additional licensing, please make sure to contact your SAP representative.
3 Background
The transactions RSCRM_BAPI and RSCRM_REPORT in the SAP BW system were created for the purpose of testing a programming interface for extracting query results from SAP BW. This programming interface takes the query definitions as the basis for generating MDX statements that are transferred to the ODBO interface in SAP BW. The result generated is either returned to the callup program as an internal table or updated in tables and files. Although the functions and performance with the transactions RSCRM_BAPI and RSCRM_REPORT are comparable to the functionality offered by the Business Explorer Analyzer, certain aspects and in particular some restrictions ought to be considered before deciding whether to opt for these transactions in a project.
4 Restriction of RSCRM
Certain queries that can be defined in the Business Explorer Analyzer cannot be supported by RSCRM_BAPI and RSCRM_REPORT due to the limitations of the ODBO interface. This applies to the following queries: Queries that use the operators CT, RT, and GT as well as %CT, %RT, and %GT in calculated key figures Queries that use replacement path variables while the reference query uses variables that are open for input. User exit variables, on the other hand, are supported. Furthermore, the ODBO interface expects there to be filters and variable values in the InfoCube it is based on. To achieve this, these values are checked upon input, which can lead to longer response times in such cases. The ODBO interface does not support filter and variable values that contain special characters, accents, or characters in the lower case. This restriction applies regardless of which additional characters are permitted for key values in the SAP BW settings. Accents such as the German "Umlaut", however, are supported for displaying the results. If the key values returned in the result contain characters in the lower case, the SIDs are returned instead of the keys. These values are identified by an exclamation mark at the beginning, followed by a +/- sign and an integer value. In the case of Top N conditions, the resulting set might vary between the Business Explorer Analyzer and the ODBO interface if multiple identical values occur due to different sort processes. If a default value is defined for a variable, the ODBO interface always applies this value, even if it had been explicitly deleted manually in the variable dialog box. It is recommended that you do not use default values. 2002 SAP AMERICA, INC. AND SAP AG
Output values for missing or invalid key figure values can be defined in the settings for SAP BW using transaction RSCUSTV4. If nonnumeric output values are defined for this case, any lines containing such values are not written to the extract. When the query results are written to tables, the structure of the query is converted so that characteristics appear in the rows and key figures in the columns, thereby supporting a flat table model. When the query results are written to tables, the characteristics of a query are used in the generated table as key fields. Due to the restrictions imposed by the Data Dictionary, the combined width of all key fields must not exceed 255 bytes. Queries for the InfoProviders "InfoObject" and "InfoSet" are only supported by RSCRM_BAPI from BW Release 3.0B but are not supported by RSCRM_REPORT.
5 Performance
The ODBO interface in SAP BW is intended to be used in OLAP applications for performing complex requests with multidimensional data. It has been optimized for this purpose, not for reading mass data. The ODBO interface has not been released for extracting mass data from SAP BW. For some queries, execution with the ODBO interface can in some instances take considerably longer than with the Business Explorer Analyzer. Moreover, server memory consumption during complex queries can also be fairly high. This is the case if, for example, a large number of characteristics are used in the drilldown (unlike in typical OLAP applications). Characteristics that are not essential should always be removed. The same applies to any superfluous attributes and key figures. Characteristics serving simply as filter characteristics should not appear in the drilldown; they should be defined as free characteristics instead. Note that conditions can only be active within a query while the characteristics used are still in the drilldown. If this is not the case, the condition is automatically deactivated. RSCRM_BAPI and RSCRM_REPORT allow you to use the packaging option (semi-automatic division of a query into several individual requests). To do this, you select a characteristic during scheduling. All values belonging to this characteristic that are found in the InfoCube are automatically divided into intervals of appropriate size ("packages") and these packages are then transferred as interval filters to individual batch jobs. Number of Characteristics in the Drilldown 1 2 3 Package Size 10000 1000 100
>=4
The size of the packages is set automatically on the basis of the number of characteristics in the drilldown. With transaction RSCRM_BAPI, however, you have the option of specifying the package size explicitly (by choosing Extras Package Size: Extract in the menu). Characteristics that are used in conditions with the type "Top-Count", "Bottom-Count", "Top-Sum", "Bottom-Sum", "Top-Product", and "Bottom-Product" are not allowed to be selected for packaging since the total resulting set would otherwise fail to fulfill the defined condition. If a query can also be displayed as a request to the InfoProvider interface in SAP BW, then requests in the transactions RSCRM_BAPI and RSCRM_REPORT are automatically directed at this interface instead of at the ODBO interface. In this way, performance and memory bottlenecks in the ODBO interface can be avoided. In BW Release 2.0B, the ODBO interface is only circumvented if no key figures are used in the query. In BW Releases beyond 2.0B, the InfoProvider interface can also be used internally if the query does not contain the following elements: Conditions Hierarchies Exit variables Characteristics in columns Key figures in rows Restricted and calculated key figures Date key figures Currency translation Concurrently a variable and a filter on a characteristic Variables on compounded characteristics Stock key figures Exception aggregation
Moreover, the InfoCube has to be a BasicCube and the E-table must not contain any entries. If the above conditions are fulfilled, the data can be transferred directly from the InfoProvider. Doing so can have considerable performance benefits.
2. Under query properties, make sure to mark the checkbox Release for OLE DB for OLAP. Then generate and safe the query.
2. Now you are on the main screen of transaction RSCRM_BAPI. Although there is a variety of features available on this screen, for the purpose of this How-To Paper lets focus on the query result download functionality. From the menu icons, click on Extract.
3. Now you are on the definition screen for a query extract. You will need to provide the following information: Technical Name of Extract: You have to choose a unique technical name, which identifies the extract that you want to create. This name is used for the table creation in DDIC (or for the structures generation in DDIC, in casethat you choose file output). The generated technical name will be constructed as follows: /BIC/0C + technical name (Up to BW2.1c/SP7: ZCRM + technical name). The files can be found in the directory DIR_HOME (to be defined via transaction code AL11). User: This is the user id, which will be used for extract creation. This user id needs to have authorization to execute the query; starting from BW2.1c/SP8, also the authorization object RSCRMEXTR is checked. Language: Language chosen for textual information in the extract. Packet by InfoObject: This is basically a partition criteria, which allows you to break down the query execution / extract into several smaller packets. It is required in case of large data volumes, in order to avoid an ODBO memory overflow. (Note: This option cannot be chosen in case of conditions, like TOPN etc.).
Extract Type: There are three options for results output. CSV- or fixedlength flat file, or transparent table. Extract Contents (table only): In case that you had chosen the transparent table for file output, select whether you want to reinitialize the table for every extract, or if you simply want to append to an existing table. File Parameters (file only): In case of flat file output, define the file name for output. Should the file already exist, it will be overwritten. Note, that only files on the application server are allowed here; you cannot choose files on the client machine. Start Condition: Use the usual BW scheduling features to plan the data extract. Note: In transaction RSCRM_REPORT, as start condition, only either immediate execution or scheduling for one future dats is possible. If you require more flexibility here (e.g. periodic loads or event scheduling), schedule the load for a date far into the future (like year 9999). The next chapter of this How-To Paper will explain how to achieve the required flexibility.
4. In case that you had defined user input variables in the query, now you will be prompted for the variable values. Enter the variable values (either manually or via variant), and then press the Continue icon. Now your job is scheduled or executed (depending on the start conditions selected above). 5. Back on the main screen, you can branch now to the monitor, via the icon Batch Monitor.
6. A traffic light will indicate the status of the process. If the traffic light is yellow, you know that the process is still running. It has finished without errors, when you see a green icon. A red icon would indicate a problem situation, which would require individual further research.
8. From the menu, you can also display the table / file contents (transaction AL11 is called in case of files).
10
Work-Around for Flexible Scheduling [only for RSCRM_REPORT, before BW 2.1c / SP8]
1. Cut and Past the job that you scheduled far into the future (see above, e.g. for year 9999). This job will be in status Released.
2. Execute transaction SE37 (Job Overview). You can also access this transaction via the menu. Do not access th transaction via double-click on the Batch-ID, since you willnot be able to modify it then!.
3. Paste the job information, and make sure that you marked also the checkbox Released Jobs.
11
4. Now from the menu, you can choose the option Repeat Scheduling (menu path: Job >> Repeat Scheduling).
5. Now you have the option to change the scheduling parameters. A copy of your original job will be executed, according to the new scheduling settings.
12
Appendix
13