You can use open hub transformation any time you need to alter extracted data. This method offers a great deal of flexibility and customization because it relies on ABAP code to transform data.
Key Concept
Open hub allows BW to act as a source to distribute data to systems outside of BW. It extracts data from BW’s InfoCubes, DataStore objects (formerly operational data store [ODS] objects), and master data. It then sends that data to external destinations as either a relational database table or a flat file. Transforming data in open hub requires ABAP coding in the form of a custom Business Add-In (BAdI).
The nature of many IT organizations dictates that information needs to flow not only into the BW system, but also out of BW into other systems. For example, your sales team needs BW data to feed a third-party transactional system. This system tracks and maintains shipping orders on a monthly basis. The third-party package has specific data storage requirements. To get the data out of BW into this third-party shipping system, you can use open hub. However, open hub extracts data in its current form. You often need to translate the data to comply with the third-party system’s data requirements, such as a five-digit material number or a leading zero at the beginning of each field. To satisfy these requirements, use custom ABAP code in the open hub transformation Business Add-In (BAdI).
In my example, SAP has a four-character alphanumeric plant field 0PLANT, but the third- party system requires a five-character numeric field for plant. During extraction, you must convert the plant field. Open hub transformation can perform the translation in just three steps: Set up the InfoSpoke, configure open hub transformation, and write custom ABAP code.
Tip!
For testing purposes, I advise you first set up the InfoSpoke to go to a local drive on your PC rather than to the application server. This allows you to use Microsoft Excel or other tools to verify the extracted data. Once you have completed this task, you can switch to saving extracted data to the application server.
Step 1. Set Up the InfoSpoke
The InfoSpoke contains the selection details, file information, and method to extract data using open hub. You can arrive at the open hub configuration screen either by transaction RSBOH1 or Administrator Workbench (RSA1) menu path Tools>Open Hub Service>Edit InfoSpoke. In this example, I’m editing the SD_EXTRACT InfoSpoke.
First, populate the General tab of this screen with the DataSource that you want to use for extraction. In this case, I am using InfoCube 0SD_C03 (Figure 1). Next, fill in the fields on the Destination tab. This tells the system where to place the data after extracting it. You can connect directly to a logical system, save to a database table, or create a flat file. In this case, I am creating a semicolon delimited flat file using the file name SD_EXTRAC.CSV (Figure 2).

Figure 1
Fill in the settings in the InfoSpoke General tab

Figure 2
Create a semicolon delimited flat file
The InfoObject screen allows you to tell the system which InfoObjects to include in the open hub extraction (Figure 3). In the InfoObjects tab, choose the InfoObjects you want in your file. Use the transfer all icon to transfer all InfoObjects to the left side of the InfoObjects tab. Alternatively, highlight the InfoObject you want and click on the transfer icon to move it to the left. Finally, click on the activate icon.

Figure 3
Modify and activate the InfoObjects tab of the InfoSpoke
The Selection tab in Figure 4 limits the data that this InfoSpoke extracts. If you need to extract a subset of data, define it here. For example, if you only want to extract data for a specific calendar month range, place this range in the From Val and To Value columns for 0CALMONTH. This allows BW to filter the data. You may use any combination of characteristic fields or the filter logic. Users define these characteristics, which are not mandatory.

Figure 4
Selection tab of InfoSpoke
Step 2. Configure Open Hub Transformation
Now you can set up the transformation. If you require any data transformation, you must set the InfoSpoke with Transform. Using BAdI flag in the Transformation tab (Figure 5). This tells the system to look to the BAdI for custom code when extracting the data. Once you select the flag for the first time, a screen appears to warn you that it will create objects for transformation. Click on the Yes button (Figure 6).

Figure 5
The Transformation tab shows source and target structures as well as the BAdI

Figure 6
Accept the warning when you select the InfoSpoke with Transform. Using BAdI flag
The system creates structures to store the data before and after transformation. The system displays the structure names after activation in the Transformation tab (Figure 5). BW creates the source or input structure with the prefix /BIC/CYXXXX and the target structure as /BIC/CZXXXX, where XXXX represents the InfoSpoke name. View these structures by double-clicking on them or using transaction SE11. They contain all of the fields the system uses before and after transformation. The system then creates a new BAdI automatically (shown in the Addin implementation field).
In my example, the length of the plant fields needs to expand from four to five characters. To accomplish this, you need to edit the target structure and expand the field. Double-click on the entry in the Target Structure field in Figure 5. The system brings up the structure.
The generated target structure table /BIC/CZSD_EXTRACT field for PLANT uses a component type and domain that allow only four characters. Since you need five characters, change the system-generated component type for PLANT to Z_PLANT by typing in the component type value in the Component type field (Figure 7). To assign it to a domain allowing five characters, you either can press F4 to find one or create a new domain by typing a value. In my case, I am using the SAP-delivered domain CHAR5.

Figure 7
Custom component type in the target structure of Z_PLANT expands the field to five characters
Step 3. Write Custom ABAP Code
Next, create the coding to transform the plant field during extraction using open hub. When you set the InfoSpoke with Transform. Using BAdI flag in the Transformation tab in step 2, the system automatically created a new BAdI.
You can access this BAdI by double-clicking on the BAdI name in the Addin implementation field of Figure 5. You also can access BAdIs via transaction SE19. In the resulting BAdI creation screen, add a text description and a filter value. The filter type always should match the InfoSpoke name. It tells the system to use your InfoSpoke when running this BAdI. Fill this into the area of the BAdI labeled InfoSpoke near the bottom of Figure 8.

Figure 8
Set up the BAdI and choose your InfoSpoke
You now can create your custom ABAP code in the BAdI. Choose the tab in the BAdI screen labeled Interface. The system automatically adds the method TRANSFORM to the list of methods and defaults it to ABAP code. Double- click on the TRANSFORM method to create your ABAP code (Figure 9).

Figure 9
Double-click on TRANSFORM to display ABAP code
In my example, the plant field needs to become a five- characteristic numeric field. The ABAP code in this BAdI uses two reserved areas:
- I_T_DATA_IN: System area with all input data
- E_T_DATA_OUT: System area with final output of data
These are SAP internal tables. During the open hub transformation process, the data starts in I_T_DATA_IN and moves to E_T_DATA_OUT. In between these two tables, you can alter the data via the open hub transformation process.
The goal is to transform the data during the move from I_T_ DATA_IN to E_T_DATA_OUT. The simple code logic looks for all plants that are set to 1000 and makes them 99999. One approach is to create a custom Z table with translation values for the plants so BW can read this Z table to get the value to fill into the plant field. BW developers often use this approach to avoid hard coding values into the transformation code. However, to simplify the ABAP, this code just looks for a value of 1000 and makes it 99999.
Start by clearing the E_T_DATA_OUT internal table so that BW does not populate values until after it transforms them. The code’s move-corresponding statement moves all values in the source table to the target table, checks for plant values equal to 1000, and sets them to 99999. The system ignores all other records that do not have a plant of 99999. My example code does not look for four-digit numbers other than 1000. If you want to search for all four-digit values, your ABAP code needs to use a wildcard. Ask your BW developer or Basis team for more details if needed.
Tip!
You can add a breakpoint in the code for debugging purposes. Add the statement break-point. to the BAdI and run the transformation process extracting data in the foreground to your local PC. The system stops at the breakpoint. You can debug your code from here.
Since all implementations and requirements differ, use my code in Figure 10 as a template for your transformation. Any custom logic to read outside tables or do any complex transformation can occur after the move-corresponding statement. At the end, insert the record into E_T_DATA_OUT. This internal table fills the extracted data.
method IF_EX_OPENHUB_TRANSFORM~TRANSFORM. data: l_s_data_in type /BIC/CYSD_EXTRACT, l_s_data_out type /BIC/CZSD_EXTRACT. clear e_t_data_out. loop at i_t_data_in into l_s_data_in. move-corresponding l_s_data_in to l_s_data_out. if l_s_data_in-PLANT = ‘1000’ l_s_data_out-PLANT = ‘99999’. insert l_s_data_out into table e_t_data_out. endloop. endmethod.
|
Figure 10 |
Code to transform the plant field data into a five-digit numeric field |
Once you finish coding, activate the BAdI to use it during transformation. Click on the activate icon in the BAdI builder screen. Subsequently, BW displays your active BAdI at the top of the BAdI screen next to the Implementation Name field (Figure 9). If the BAdI is active, it is ready to use during transformation.
Once you run the extraction, the system creates two files. One contains the extracted data and the other contains details about the extracted data: its location, length, structure of fields, and their order. You can use this roadmap to set up the third-party system to input this file.