Sie sind auf Seite 1von 25

How to Load a Flat File in SAP BI Integrated Planning Using BEx

Jarrett Bialek (jarrett.bialek@inforte.com) Jens Koerner (jens.koerner@inforte.com) June 10, 2008 Inforte, a Business & Decision Company

Table of Contents
Overview .........................................................................................................................2 Integrated Planning Flat File Upload Basic Functionality.................................................2 Getting Started.............................................................................................................2 Import of new File upload planning function type .........................................................2 Creating Components of IP Upload Mechanism ..........................................................6 Customizing IP Flat File Upload Solution for BEx..........................................................15 Code Changes in Class ZCL_RSPLF_FILE_UPLOAD..............................................15 Creating a Workbook Incorporating the Data Viewer, Planning Sequence, and Save...15 Workbook settings .....................................................................................................15 Creating the Query for Data Preview .........................................................................17 Creating Buttons for Planning Functions....................................................................19 File Selection Screen .................................................................................................24 Conclusion.....................................................................................................................25

Overview
SAP NetWeaver BI Integrated Planning now has the ability to allow users to upload data directly into transactional cubes. The solution outlined in this paper provides a how-to guide to use flat file upload functionality in BEx. It also shows step-by-step how to use a query to preview the data uploaded before deciding whether to save (write) the data to the target cube. This is basically replicating the BPS file upload functionality in IP. The solution depicted in this paper provides the user with the familiarity of BEx, but with the flexibility of Integrated Planning. It can work in conjunction with the Web Dynpro based IP Flat File Upload solution created by SAP see the paper How To.Load a File into BI Integrated Planning from SAP for details https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/7708

Integrated Planning Flat File Upload Basic Functionality


Getting Started
Before you can create BEx based IP Upload capabilities into your transactional cubes, you will need to import some transport files into your system and make sure that a couple key components from those files are installed and activated.

Import of new File upload planning function type

-2-

Before you can start building your IP upload solution you have to import some ABAP objects into your system. Step 1. Import of Transports The transport below containing all necessary objects will have to be imported

K900315.BIR

R900315.BIR

Unzip the files and copy them into the transport directory of your BI system (K9900315.BIR into COFILES directory, R900315.BIR into DATA directory). Then go to transaction STMS, select your system, add the new transport to the import queue, and finally import the transport.

Step 2. Check that class exists and is active The first thing to check is that ABAP class ZCL_RSPLF_FILE_UPLOAD exists and is active using transaction SE24.

Figure 1. Transaction SE24

-3-

Figure 2. Display of class in transaction se24

Step 3. Check that planning function type exists and is active The check confirms that planning function type ZRSPL_FILE_UPLOAD exists and is active. You can check this by using transaction RSPLF1.

Figure 3a. Transaction RSPLF1

-4-

Figure 3b. Display of planning function type ZRSPL_FILE_UPLOAD in transaction RSPLF1

Step 4. Check InfoObject 0TCTIOBJNM Make sure InfoObject 0TCTIOBJNM is activated from Business Content. InfoObject is used in parameter definition of the planning function.

This

Step 5. Creation of additional InfoObjects and Master Data Next we have to create a couple of InfoObjects that will be used in the planning function:

-5-

Character Format (ZIP_ENCOD) Convert Amounts (ZIP_CONVA) Convert Fields (ZIP_CONVF) Overwrite Data (ZIP_OVERW) Skip Header (ZIP_SKIPH)

Once created simply enter the master data for them (see file below).

Master Data for Characteristics

Creating Components of IP Upload Mechanism


Provided that the Function Module and Class components exist and are active, you can now create an IP Upload planning function that runs in Web Dynpro. For that we will use the planning modeler - transaction RSPLAN -> Start Modeler button in the upper left

Figure 4. The planning modeler

Step 6. Create or use an existing transactional InfoCube The IP Upload mechanism takes a flat file from the user and uploads the data into a transactional cube. This cube can be any transactional cube that currently exists in your system, or you can create a new cube to receive data uploaded from your flat file. The SAP How-To paper (mentioned in the Overview section) uses transactional cube 0DBPS_C01 as a target for the flat file upload. This cube can be activated from BI Content. In the following we will also use this cube.

-6-

Figure 5. Display of real-time InfoProvider in the planning modeler

Step 7. Create an Aggregation Level on top of your cube. Aggregation Levels are virtual InfoProviders in the BI system based off of real-time InfoCubes. You can create an Aggregation Level in the Planning Modeler under the Aggregation Level tab. The Aggregation Level in Figure 6 is ZIP_LEVEL. Choose the characteristics and key figures you want to include from your InfoCube. These selections will need to be included in the planning function file upload structure, and in the files you will be uploading (see Step 8). Once created make sure you save and activate your Aggregation level.

-7-

Figure 6. Aggregation level on top of real-time InfoProvider

Step 8. Create a Filter. Create your filter from the Filter tab in the Planning Modeler. A filter will restrict what values can be written to the InfoCube and also selects what data to lock when writing to the cube. Not having any restrictions will lock all the data in the cube. Create either hard-coded restrictions or variables for locking only the data that will be affected by the upload. This can be done in the bottom half of the Filter screen under Display Filter <Filter_name>. In Figure 7 for example, Filter IP_UPLOAD_FILTER has been restricted by the Version characteristic and variable IP FILE VERSION VAR. This variable was copied from business content, the business content variable 0D_PVERS may be suitable without any alteration.

-8-

Figure 7. Filter tab

Step 9. Create the Upload Planning Function on your aggregation level and set file format Create the file upload planning function via pressing the yellow create button in the upper left part of the planning function tab in Planning Modeler. Choose the planning type File Upload from the dropdown in the Create Planning Function screen (this is the function type we imported in Step 1). Note: Other options in this dropdown box include Copy, Formula, Repost, etc. In general planning functions dictate how transaction data in an aggregation level should be changed. The five parameters below help determine how the file upload planning function handles the data changes. The parameters are defined with the planning function type checked in Step 3 (parameter tab can be seen in Figure 3b). The Skip Header Line parameter for example will include the first line of the file if set to #, and will skip the first line (if your file contains a header) if set to X. Another parameter example is the Overwrite Data parameter with three options: # adds values to cube, D for write only the deltas, and X Overwrite contents of cube. These parameters are maintained in the Planning Functions tab in Planning Modeler. Example: Character Format = DEFAULT (UTF-8) Overwrite Data = D (delta mode) Skip Header Line = # (do not skip first line)

-9-

Convert Fields = # (no field conversion) Convert Amounts = # (no amount conversion) The upload function will determine whether the file being uploaded is in tab delimited, fixed length, or XML format. These are currently the only accepted formats. After setting the parameters, the file format needs to be determined. This is set in the planning function tab as well in the lower section of the screen under File Format. The order of the characteristics and key figures must match the flat file you want to upload. Key figures must be last. The easiest way to add new InfoObjects is to enter them directly through the Input Help. The location of the pop-up input screen often appears below the viewable area. Selecting a value tends to re-center the input screen and will allow you to confirm or cancel.

Figure 8. File format section of the planning function

Step 10. Create Planning Sequence. NOTE: The planning sequence is not necessarily needed for the BEx functionality; but it is required for the Web Dynpro capabilities. Under the Planning Sequence tab (the last tab in Planning Modeler), create the planning sequence. The planning sequence assembles planning functions in a sorted order for processing as a group or in a process chain. It is possible to create your upload process without a planning sequence if there is only one planning function. If - 10 -

the possibility exists for multiple planning functions, a planning sequence should be used. Add the aggregation level, filter, and the planning function created in Step 8. This is done under the Steps section of the planning sequence tab. If a variable has been added to the filter, it should show up in the bottom section marked Variable Input.

Figure 9. Planning sequence

Step 11. Checking URL for File Upload Use your text flat file to check that the file upload works with Web Dynpro, before making modifications to make it work with BEx. You can do this by pasting the URL for the planning sequence into your browser. You can get the URL by going to transaction SE80, under Repository Browser tab in the upper left part of the screen, Select Web Dynpro Comp/ Intf. from the dropdown menu, and choose your Web Dynpro component interface zrsplf_file_upload. Under Web Dynpro Applications (highlighted in yellow in figure 10) click on zrsplf_file_upload and on the right half of the screen under the properties tab, the URL should appear at the bottom of the screen.

- 11 -

Figure 10. Determining the URL for the Web Dynpro test

You will need to add your planning sequence in the URL after zrsplf_file_upload by adding planning_sequence=<name_of_sequence>&.

Troubleshooting: Checking Web Service If there are problems with the URL, check that the web service is enabled. You can do this through transaction SICF shown in Figure 11a. Click on Execute button in upper left hand corner.

- 12 -

Figure 11a. Transaction SICF

This will bring you to a hierarchy of services, follow the path: default host/sap/bc/webdynpro/sap/zrsplf_file_upload. The first couple directories can be seen in Figure 11b.

- 13 -

Figure 11 b. Maintain services screen

The file upload screen should look like Figure 11c if the IP Paper has been followed correctly. This is the Web Dynpro solution delivered from the SAP How To paper.

Figure 11 c. Web Dynpro Screen from SAP how-to paper

- 14 -

Customizing IP Flat File Upload Solution for BEx


Once you have a successful IP Upload working on the web, the solution can be customized for BEx to include a data preview screen along with the same functionality found in Web Dynpro. To achieve this we need to modify some of the ABAP code we imported in step 1.

Code Changes in Class ZCL_RSPLF_FILE_UPLOAD


Step 12. Replace code in execute method in Class ZCL_RSPLF_FILE_UPLOAD Some changes need to be made for the BEx solution to the IF_RSPLFA_SRVTYPE_IMP_EXEC~EXECUTE method in the ZCL_RSPLF_FILE_UPLOAD class. This change can be made in transaction SE24. Double click on the method and replace the existing code with the code listed in this file:

BEx IP Code Changes.txt

The new code will allow you to run planning functions and sequences from BEx and enables a user to select any text file from their system and upload it according to the file structure specified in the planning function. Also included in this section, if you do not check if the filename is assigned, you will receive an error if the user cancels out of the file selection screen without picking a file. These changes will allow you to create a workbook with ability to select a file for upload, run the planning sequence, see the data uploaded before saving, and finally saving the data.

Creating a Workbook Incorporating the Data Viewer, Planning Sequence, and Save
Now since the ABAP part is done we will focus on creating the workbook to invoke the functions we modified.

Workbook settings

- 15 -

Before you design your workbook, there are a couple of workbook settings that will need to be set in order for the solution to run as expected. Step 13. Logon with Attached SAP GUI in Global Settings This setting must be checked in order for your planning functions and IP logic to be accessible in BEx. If you try and run a planning function and this is not checked you will get an error message instructing you to check this setting. Global Settings is highlighted in Figure 15 below. Set this before connecting to your system.

Figure 12. Check the Log on with Attached SAP GUI

Step 14. Automatic Refresh This button should be highlighted as it is in Figure 13 below. This will allow the users to see the changes they make in the workbook right when they upload the file, not forcing them to reprocess variables or manually refresh the workbook to see changes.

- 16 -

Figure 13. Check Automatic refresh

Creating the Query for Data Preview


First we need to create a query to select the data we upload to preview it in our workbook. Step 15. Creating the Data Preview Query Creating an Input Ready Query for data preview as opposed to a normal query allows us to view the buffer that holds the data we are uploading before it is written to the cube. This allows the user to confirm that these are values he/she expects to see and then can confirm the upload by clicking on the Save button. Depending on whether you want to allow uses to change the uploaded data using the input ready query you should set your Change Data parameter by right clicking on the key figure Figure 17. We chose Data can be changed using planning functions. thus allowing no manual overwrites from users.

Figure 14. Creating an input ready query

Step 16. Connecting the Input Ready Query to the Workbook

- 17 -

In BEx Analyzer we create a new workbook. Use the toolbar on the left side of the screen to add an Analysis Grid - see red arrow in Figure 15a. The grid below was placed in cell B9. You will connect this to a data provider/query the same way you normally would in a BEx workbook by clicking on the Analysis Grid in the workbook while in Design Mode.

Figure 15a. Insert Analysis Grid

Connect the query to your data provider, and check the Reference the View box in Figure 15b.

- 18 -

Figure 15b. Connection of input ready query to workbook

Creating Buttons for Planning Functions


Step 17. To execute our planning functions and planning sequences, we need to insert buttons into our workbook, using the same toolbar as in step 16 on the left side of the screen. The first step is inserting the button(s) into your workbook. The button for inserting buttons is highlighted in the small red rectangle on the toolbar. Below (large red rectangle) in Figure 16 is what the buttons could look like after creating one for the upload and one for saving (writing the data to the cube). This will be done in the next two steps.

- 19 -

Figure 16.

Step 18. Upload Button Settings Figure 17a. After dragging the button into the workbook you will be asked to select a command type. Choose Planning Specific Command and choose Next.

- 20 -

17b. The next step is to choose a Planning Specific Command. Choose Execute Planning Sequence. Alternatively: You can also opt to execute the Planning Function directly.

- 21 -

17c. Now you have to connect your planning sequence to this button. Clicking on the button highlighted by the red arrow will allow you to search for the planning sequence that you created. You can search by description or technical name, select your planning sequence and click Open. Then click on the Finish button.

17d. Set the Range of cells you would like the physical button to occupy in the workbook. Then give your button text. The Static parameters at the right should show up the same. This screen gives you the ability to add more functionality to the button, such as the save command as well, but most people would like to view the data they are

- 22 -

uploading before they commit to writing it to the cube. Click OK and you are done. Table 1 Figure 12

Step 19. Save Button Settings 18a. For the Save button, we will need to insert another button if we do not add save functionality to the upload button. For the Save button, you will still choose Planning Specific Command in the Select Command Type screen

- 23 -

18b. Choose Save in the Planning Specific Command Screen, and then press Finish.

18c. Set the parameters and text for this button as you did for the upload button. The only Command you should see in Static Parameters Save_Area. is Click OK and you are done. Table 2 Figure 13

File Selection Screen


After the buttons are created we are ready to run our workbook and to upload our flat file. The uploaded data will be displayed in the preview query in our workbook.

- 24 -

Step 20. How File Selection Screen Looks to End User Clicking on the File Upload button in our workbook will open the file upload screen Figure 19. Sometimes the screen is hidden behind other windows so make sure you use <alt><tab> to get it into focus. You can now browse for your flat file. Hitting the Open button will upload the data and triggering the save button in the workbook saves the data back to your cube.

Figure 19.

Conclusion
The IP upload function configuration, tied with BEx functionality creates a very flexible and powerful solution. One setting that is key to this ability is the Logon with Attached SAP GUI and being able to call back-end ABAP in BEx. With knowledge of ABAP, the solution is even more flexible than illustrated here. This paper provides a step by step solution to allow users to have the familiarity of BEx, but with the flexibility and functionality of Integrated Planning.

Wed also like to thank Niels Koerner for the thorough review of the paper.

- 25 -

Das könnte Ihnen auch gefallen