Open Hub
SAP BW: Create a fixed length file with Open Hub Destination
At my current project we are using SAP BW and its Open Hub Destination (Open Hub) object to create a number of flat file interfaces to export data from SAP BW to other systems. An Open Hub creates a comma separated value (CSV) file which can be placed on a local directory or on an application server. The Open Hub uses a standard transformation and DTP to transform and load data from an InfoCube, DSO or InfoObject. If you are exporting to an application server you can also use Process Chains for scheduling.
Now we got this fancy old-school requirement to create an interface in which the files should be fixed length instead of CSV. Great. Since the Open Hub uses a mandatory separator (the comma, or in most cases a semicolon) to separate the fields and it does not have any options to determine the exact position of each field in a record in the file, a workaround is needed to make this work.
Update: Thomas Brandt mentioned in the comments below this post that with SAP BW 7.3 it now is possible to export to CSV, ASCII and XML. Check SAP Help for more info. If your BW hasn’t been upgraded to 7.3 you can still use the workaround.
In this example I will create an Open Hub called ZFIXED on top of the 0PERSON InfoObject which generates a fixed length file. The file will contain 4 fields according to the specs below:
- Person, position 1 to 10;
- City, position 11 to 20;
- Country, position 21 to 30;
- Date of birth, position 31 to 38.
Let’s see how this works:
Posted in: Knowledge sharing, SAP BW