<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: open dataset ... for input in binary mode in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073933#M95731</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about I declare a local field:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data zfield(281065) type x.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then read it into there, and do it all internally using offsets and lengths?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Dec 2005 14:40:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-12-09T14:40:36Z</dc:date>
    <item>
      <title>open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073924#M95722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, ten points for the first person who can tell me how to fix this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got a binary file of size 281065 bytes which I want to attach to an e-mail I'm sending from an ABAP programme. Unfortunately, when I do this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;open dataset zfile for input in binary mode.
  do.
    read dataset zfile into ls_xcontent_hex-line.
    if sy-subrc eq 0.
      append ls_xcontent_hex to xcontent_hex.
    else.
      if zcounter eq 1.
        exit.
      else.
        add 1 to zcounter.
      endif.
    endif.
  enddo.
close dataset zfile.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...it manages to ignore the last 55 bytes of the attachment. Now, this being a .pdf file, this is obviously a problem, as it's missing the footer information (which is pretty important for a .pdf). (Aside from this it's all fine though.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I get those last 55 bytes to read? The amount it's reading - 281,010 bytes - is an exact multiple of 255, which is also the line size of the field into which each bit is being read. I just need those last 55 bytes, and it's annoying me &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:07:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073924#M95722</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-09T14:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073925#M95723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the definition of ls_xcontent_hex-line? May be you should use a string type for this field and try.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:08:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073925#M95723</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-09T14:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073926#M95724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how you defined &amp;lt;b&amp;gt;line&amp;lt;/b&amp;gt; in this ls_xcontent_hex-line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:11:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073926#M95724</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-09T14:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073927#M95725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You must make sure that ls_xcontent_hex-line has a length long enough to accept the entire line of the file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:17:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073927#M95725</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-12-09T14:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073928#M95726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe you should add the keywords &amp;lt;b&amp;gt;MAXIMUM LENGTH&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;LENGTH&amp;lt;/b&amp;gt; as in:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  DO.
    READ DATASET i_srv_file
            INTO e_data
            MAXIMUM LENGTH 1024
            LENGTH l_len.

    IF l_len GT 1024.
*     Line length &amp;amp; exceeds 1024.
      MESSAGE e000 WITH l_len
              RAISING file_read_error.
    ENDIF.

    IF NOT sy-subrc IS INITIAL.
      EXIT.
    ENDIF.

    APPEND e_data.
  ENDDO.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you would get feedback if there's a line that's too long.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Joerg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:23:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073928#M95726</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-09T14:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073929#M95727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the special reason for your zcounter? You ignore one sy-subrc ne 0, but you don't make an append (in else. add 1...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nevertheless, normally line (or file length) is known, that's much easier (as Rich already said, field is big enough for whole line / file).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this is not possible with big dynamical PDF-files, go for single byte read, step by step. Then you can get every byte, put this internally together and nothing will be lost.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: hex_byte(1) TYPE x, 
            len TYPE i value 1. 

OPEN DATASET zfile FOR INPUT IN BINARY MODE. 


DO. 
  READ DATASET zfile INTO hex_byte MAXIMUM LENGTH 1. 
  IF sy-subrc = 0. 
* append hex_byte to your xcontent_hex
  ELSE. 
    EXIT. 
  ENDIF. 
ENDDO. 

CLOSE DATASET file. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:23:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073929#M95727</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2005-12-09T14:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073930#M95728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Apologies for that. ls_xcontent_hex-line is a char255. It isn't possible to do line(281065) type c, as the function module I'm using takes a table of type solix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:26:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073930#M95728</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-09T14:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073931#M95729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;People reply so fast on here!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The zcounter was an attempt to demonstrate that even forcing it to read an extra line doesn't help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I like the byte-at-a-time idea - I'll try it. The longest line, by the way, far exceeds 255, it's roughly 15,000 bytes long.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:29:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073931#M95729</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-09T14:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073932#M95730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I already had doubts about the use of an additional append.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One other option would be: determine total file length in advance, read data in chunks of let's say 100 bytes until you need to read the rest (modulo 100). Just in case byte-by-byte is to slow (and no better solution is proposed).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:37:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073932#M95730</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2005-12-09T14:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073933#M95731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about I declare a local field:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data zfield(281065) type x.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then read it into there, and do it all internally using offsets and lengths?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:40:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073933#M95731</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-09T14:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073934#M95732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't go higher than 65535 with type x.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:44:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073934#M95732</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2005-12-09T14:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073935#M95733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try using the type "LCHR".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Suman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:52:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073935#M95733</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-09T14:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: open dataset ... for input in binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073936#M95734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good idea. There is a xstring, which can hold up to 2GB - should be enough. It's recommended to use a binary type for reading binary files, so conversion should be explicit in the program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2005 14:58:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-dataset-for-input-in-binary-mode/m-p/1073936#M95734</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2005-12-09T14:58:49Z</dc:date>
    </item>
  </channel>
</rss>

