

{"id":1676,"date":"2012-03-28T21:20:47","date_gmt":"2012-03-28T19:20:47","guid":{"rendered":"http:\/\/www.hackingsap.com\/blog\/?p=1676"},"modified":"2012-04-05T15:49:11","modified_gmt":"2012-04-05T13:49:11","slug":"sap-bw-create-a-fixed-length-file-with-open-hub-destination","status":"publish","type":"post","link":"https:\/\/www.hackingsap.com\/blog\/sap-bw-create-a-fixed-length-file-with-open-hub-destination","title":{"rendered":"SAP BW: Create a fixed length file with Open Hub Destination"},"content":{"rendered":"<p>At my current project we are using SAP BW and its <strong>Open Hub Destination<\/strong> (Open Hub) object to create a number of flat file <strong>interfaces<\/strong> to <strong>export data<\/strong> from SAP BW to other systems. An Open Hub creates a comma\u00a0separated 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.<\/p>\n<p>Now we got this fancy old-school requirement to create an interface in which the files should be <strong>fixed length<\/strong> 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.<\/p>\n<p><strong>Update<\/strong>: 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 <a href=\"http:\/\/help.sap.com\/saphelp_nw73\/helpdata\/en\/4a\/14158d174f0452e10000000a421937\/content.htm\" target=\"_blank\">SAP Help<\/a> for more info. If your BW hasn&#8217;t been upgraded to 7.3 you can still use the workaround.<\/p>\n<p>In this example I will create an Open Hub called <strong>ZFIXED<\/strong> on top of the <strong>0PERSON<\/strong> InfoObject which generates a fixed length file. The file will contain 4 fields according to the specs below:<\/p>\n<ol>\n<li>Person, position 1 to 10;<\/li>\n<li>City, position 11 to 20;<\/li>\n<li>Country, position 21 to 30;<\/li>\n<li>Date of birth, position 31 to 38.<\/li>\n<\/ol>\n<p>Let&#8217;s see how this works:<!--more-->1. First create your Open Hub. Do not select a template. We don&#8217;t need this.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1684\" title=\"oh1\" src=\"http:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh1.png\" alt=\"\" width=\"642\" height=\"302\" srcset=\"https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh1.png 642w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh1-150x70.png 150w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh1-300x141.png 300w\" sizes=\"auto, (max-width: 642px) 100vw, 642px\" \/>2. Choose Destination Type <strong>File<\/strong> and enter the file directory in which you want the file to be exported. For this example I just use a local directory. In a production scenario you should use the <strong>Application Server<\/strong> option since you then can export the file to an application server and use logical file names. Also it is not possible to use the DTP between your source object and the Open Hub in a Process Chain if you use a local directory.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1685\" title=\"oh2\" src=\"http:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh2.png\" alt=\"\" width=\"590\" height=\"257\" srcset=\"https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh2.png 590w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh2-150x65.png 150w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh2-300x130.png 300w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/p>\n<p>3. Go to the <strong>Field Def.<\/strong> tab. Here you enter a name for your field (i.e. FIELD), use Type <strong>STRG<\/strong> and 38 for\u00a0Length. Now Activate the Open Hub.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1686\" title=\"oh3\" src=\"http:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh3.png\" alt=\"\" width=\"558\" height=\"163\" srcset=\"https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh3.png 558w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh3-150x43.png 150w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh3-300x87.png 300w\" sizes=\"auto, (max-width: 558px) 100vw, 558px\" \/><\/p>\n<p>4. Create a transformation from 0ZPERSON to the Open Hub ZFIXED. Connect the InfoObjects you want to use from 0PERSON to ZFIXED. I connected 0PERSON, 0CITY, 0COUNTRY and 0DATEBIRTH.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1687\" title=\"oh4\" src=\"http:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh4.png\" alt=\"\" width=\"538\" height=\"510\" srcset=\"https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh4.png 538w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh4-94x90.png 94w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh4-300x284.png 300w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/p>\n<p>5. Change the Rule Type into <strong>Routine<\/strong>. We need some simple ABAP coding to merge the 4 fields and set the correct starting positions for each field. Scroll down until you see &#8220;RESULT = .&#8221; and add the code below.<\/p>\n<blockquote>\n<p>\u00a0 \u00a0\u00a0DATA: lv_char TYPE c LENGTH 38.<\/p>\n<p>lv_char(10) = SOURCE_FIELDS-PERSON.<br \/>\nlv_char+10(10) = SOURCE_FIELDS-CITY.<br \/>\nlv_char+20(10) = SOURCE_FIELDS-COUNTRY.<br \/>\nlv_char+30(8) = SOURCE_FIELDS-DATEBIRTH.<\/p>\n<p>RESULT = lv_char.<\/p>\n<p>&nbsp;<\/p>\n<\/blockquote>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1690\" title=\"oh7\" src=\"http:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh7.png\" alt=\"\" width=\"495\" height=\"285\" srcset=\"https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh7.png 495w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh7-150x86.png 150w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh7-300x172.png 300w\" sizes=\"auto, (max-width: 495px) 100vw, 495px\" \/><\/p>\n<p>6. <strong>Activate<\/strong> the transformation, create a <strong>DTP<\/strong> and <strong>Execute<\/strong> it!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1689\" title=\"oh6\" src=\"http:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh6.png\" alt=\"\" width=\"389\" height=\"95\" srcset=\"https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh6.png 389w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh6-150x36.png 150w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh6-300x73.png 300w\" sizes=\"auto, (max-width: 389px) 100vw, 389px\" \/><\/p>\n<p>7. You can now open the file in Notepad.exe. It should look something like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1688\" title=\"oh5\" src=\"http:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh5.png\" alt=\"\" width=\"480\" height=\"250\" srcset=\"https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh5.png 480w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh5-150x78.png 150w, https:\/\/www.hackingsap.com\/blog\/wp-content\/uploads\/oh5-300x156.png 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.<\/p>\n<p>Now we got this fancy old-school requirement to create an interface in which the files would 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 has no options to determine the exact position of each field in a record in the file, a workaround is needed to make this work.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[44,1],"tags":[151,152,132],"class_list":["post-1676","post","type-post","status-publish","format-standard","hentry","category-knowledge-sharing","category-sapbw","tag-open-hub","tag-open-hub-destination","tag-sap-bw"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pKaa2-r2","jetpack-related-posts":[{"id":3397,"url":"https:\/\/www.hackingsap.com\/blog\/sap-analytics-cloud-anno-2018-the-good-the-bad-the-ugly","url_meta":{"origin":1676,"position":0},"title":"SAP Analytics Cloud anno 2018: the good, the bad &#038; the ugly","author":"Xavier Hacking","date":"December 28, 2018","format":false,"excerpt":"Just a few more days and the year is almost over again, which makes this a perfect time to have a look at what happened in the past 12 months in the world of SAP Analytics Cloud. With all the updates the tool got in 2018 (22 waves!), you\u2019d almost\u2026","rel":"","context":"In &quot;SAP Analytics Cloud&quot;","block_context":{"text":"SAP Analytics Cloud","link":"https:\/\/www.hackingsap.com\/blog\/category\/sap-analytics-cloud"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3225,"url":"https:\/\/www.hackingsap.com\/blog\/sap-analytics-hub-a-first-look","url_meta":{"origin":1676,"position":1},"title":"SAP Analytics Hub &#8211; A first look","author":"Xavier Hacking","date":"May 30, 2017","format":false,"excerpt":"In my previous post on the new names for the SAP BI products, the list (in the tweet) also included a new product: SAP Analytics Hub. Unfortunately I don't have access yet, and there is also not that much material available on this product, but enough to at least get\u2026","rel":"","context":"In &quot;SAP&quot;","block_context":{"text":"SAP","link":"https:\/\/www.hackingsap.com\/blog\/category\/sap"},"img":{"alt_text":"sapanalyticshub4","src":"https:\/\/i0.wp.com\/www.hackingsap.com\/blog\/wp-content\/uploads\/sapanalyticshub4-1024x524.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.hackingsap.com\/blog\/wp-content\/uploads\/sapanalyticshub4-1024x524.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.hackingsap.com\/blog\/wp-content\/uploads\/sapanalyticshub4-1024x524.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.hackingsap.com\/blog\/wp-content\/uploads\/sapanalyticshub4-1024x524.png?resize=700%2C400 2x"},"classes":[]},{"id":3313,"url":"https:\/\/www.hackingsap.com\/blog\/sap-going-all-in-on-sap-analytics-cloud","url_meta":{"origin":1676,"position":2},"title":"SAP going all-in on SAP Analytics Cloud","author":"Xavier Hacking","date":"February 11, 2018","format":false,"excerpt":"Shocking news this week, as SAP made a major announcement\u00a0on the SAP BI product strategy, and specifically on SAP Lumira, Discovery edition. In summary, SAP Analytics Cloud will be the primary solution for data discovery from now on. The consequence is that new investments in this area will be focused\u2026","rel":"","context":"In &quot;SAP&quot;","block_context":{"text":"SAP","link":"https:\/\/www.hackingsap.com\/blog\/category\/sap"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.hackingsap.com\/blog\/wp-content\/uploads\/all_in.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.hackingsap.com\/blog\/wp-content\/uploads\/all_in.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.hackingsap.com\/blog\/wp-content\/uploads\/all_in.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.hackingsap.com\/blog\/wp-content\/uploads\/all_in.png?resize=700%2C400 2x"},"classes":[]},{"id":3521,"url":"https:\/\/www.hackingsap.com\/blog\/sap-analytics-cloud-2019-roundup-the-good-the-bad-and-the-ugly","url_meta":{"origin":1676,"position":3},"title":"SAP Analytics Cloud 2019 Roundup: the good, the bad and the ugly","author":"Xavier Hacking","date":"December 29, 2019","format":false,"excerpt":"2019 is almost over, so just like last year\u00a0this is a good moment to look back at what happened in the SAP Analytics Cloud universe over the past 12 months. This year we got an astonishing 24 wave releases for the SAC tenants that are on the fast track schedule,\u2026","rel":"","context":"In &quot;SAP Analytics Cloud&quot;","block_context":{"text":"SAP Analytics Cloud","link":"https:\/\/www.hackingsap.com\/blog\/category\/sap-analytics-cloud"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2662,"url":"https:\/\/www.hackingsap.com\/blog\/sap-bi4-override-olap-connections-in-promotion-management","url_meta":{"origin":1676,"position":4},"title":"SAP BI4: Override OLAP Connections in Promotion Management","author":"Xavier Hacking","date":"November 13, 2014","format":false,"excerpt":"The Promotion\u00a0Management corner in the\u00a0SAP BusinessObjects BI Platform CMC is still a bit of a strange place for us coming from the SAP BW world. I really like the fact that you\u00a0can use a single promotion job to promote a report again and again after each change. In SAP BW\u2026","rel":"","context":"In &quot;Knowledge sharing&quot;","block_context":{"text":"Knowledge sharing","link":"https:\/\/www.hackingsap.com\/blog\/category\/knowledge-sharing"},"img":{"alt_text":"override1","src":"https:\/\/i0.wp.com\/www.hackingsap.com\/blog\/wp-content\/uploads\/override1.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.hackingsap.com\/blog\/wp-content\/uploads\/override1.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.hackingsap.com\/blog\/wp-content\/uploads\/override1.png?resize=525%2C300 1.5x"},"classes":[]},{"id":2588,"url":"https:\/\/www.hackingsap.com\/blog\/new-sapexperts-article-how-to-use-css-in-design-studio","url_meta":{"origin":1676,"position":5},"title":"New SAPexperts article: How to Use CSS in Design Studio","author":"Xavier Hacking","date":"May 1, 2014","format":false,"excerpt":"I wrote another article for the SAPexperts online knowledge base. In line with some of my recent posts here on my blog this one is all about CSS, but now more from a basic, 101 course standpoint. In this article I give a basic introduction to the language of CSS\u2026","rel":"","context":"In &quot;Knowledge sharing&quot;","block_context":{"text":"Knowledge sharing","link":"https:\/\/www.hackingsap.com\/blog\/category\/knowledge-sharing"},"img":{"alt_text":"sapexperts_bihub","src":"https:\/\/i0.wp.com\/www.hackingsap.com\/blog\/wp-content\/uploads\/sapexperts_bihub.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hackingsap.com\/blog\/wp-json\/wp\/v2\/posts\/1676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hackingsap.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hackingsap.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hackingsap.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hackingsap.com\/blog\/wp-json\/wp\/v2\/comments?post=1676"}],"version-history":[{"count":16,"href":"https:\/\/www.hackingsap.com\/blog\/wp-json\/wp\/v2\/posts\/1676\/revisions"}],"predecessor-version":[{"id":1700,"href":"https:\/\/www.hackingsap.com\/blog\/wp-json\/wp\/v2\/posts\/1676\/revisions\/1700"}],"wp:attachment":[{"href":"https:\/\/www.hackingsap.com\/blog\/wp-json\/wp\/v2\/media?parent=1676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hackingsap.com\/blog\/wp-json\/wp\/v2\/categories?post=1676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hackingsap.com\/blog\/wp-json\/wp\/v2\/tags?post=1676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}