<?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 data set problem with binary mode in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-data-set-problem-with-binary-mode/m-p/1691854#M303897</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    Check out this way ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; OPEN DATASET lv_file_name FOR INPUT IN BINARY MODE &amp;lt;b&amp;gt;ENCODING DEFAULT&amp;lt;/b&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Nov 2006 08:04:25 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-11-28T08:04:25Z</dc:date>
    <item>
      <title>Open data set problem with binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-data-set-problem-with-binary-mode/m-p/1691853#M303896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to read into a buffer the content of a binary file (like Excel) and to write that content file using open data set into a folder destination.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The file destination has a size diferent than from the original one and cannot be open.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  DATA:  lv_file_name(100),
         lt_content LIKE sdokcntbin OCCURS 0 WITH HEADER LINE.

  MOVE '\computerTestA1.xls' TO lv_file_name.
  OPEN DATASET lv_file_name FOR INPUT IN BINARY MODE.
  IF sy-subrc NE 0.
    EXIT.
  ENDIF.

  DO.
    READ DATASET lv_file_name INTO lt_content-line.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
    APPEND lt_content.
  ENDDO.
  CLOSE DATASET lv_file_name.
*  DELETE DATASET lv_file_name.

*****************************************************

  CLEAR: lv_file_name.
  MOVE '\computerTestB2.xls' TO lv_file_name.
  OPEN DATASET lv_file_name FOR OUTPUT IN BINARY MODE.
  IF sy-subrc NE 0.
    EXIT.
  ENDIF.

  LOOP AT lt_content.
    TRANSFER lt_content-line TO lv_file_name.
  ENDLOOP.
  CLOSE DATASET lv_file_name.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;THanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        David Fryda&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Nov 2006 08:01:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-data-set-problem-with-binary-mode/m-p/1691853#M303896</guid>
      <dc:creator>david_fryda2</dc:creator>
      <dc:date>2006-11-28T08:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Open data set problem with binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-data-set-problem-with-binary-mode/m-p/1691854#M303897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    Check out this way ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; OPEN DATASET lv_file_name FOR INPUT IN BINARY MODE &amp;lt;b&amp;gt;ENCODING DEFAULT&amp;lt;/b&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Nov 2006 08:04:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-data-set-problem-with-binary-mode/m-p/1691854#M303897</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-28T08:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Open data set problem with binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-data-set-problem-with-binary-mode/m-p/1691855#M303898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First check the authorization for that folder on application server using the F.M. &lt;/P&gt;&lt;P&gt;Authorization_Check_dataset.&lt;/P&gt;&lt;P&gt;if sy-subrc Eq 0.&lt;/P&gt;&lt;P&gt;Then try to open the destination file.&lt;/P&gt;&lt;P&gt;if the size is different from source &amp;amp; target try with to open the dataset in TEXT MODE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Messages Mess for finding the error message in the open statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Ashok Damaraju&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Nov 2006 08:08:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-data-set-problem-with-binary-mode/m-p/1691855#M303898</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-28T08:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Open data set problem with binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-data-set-problem-with-binary-mode/m-p/1691856#M303899</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 with ENCODING DEFAULT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rgds&lt;/P&gt;&lt;P&gt;Anver&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Nov 2006 08:08:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-data-set-problem-with-binary-mode/m-p/1691856#M303899</guid>
      <dc:creator>anversha_s</dc:creator>
      <dc:date>2006-11-28T08:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Open data set problem with binary mode</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/open-data-set-problem-with-binary-mode/m-p/1691857#M303900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;I solve the problem.&lt;/P&gt;&lt;P&gt;In fact, when I try to write the last line of lt_content, it does write all the line even if this line is not full of data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Solution :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  DATA:  lv_file_name(100),
         lt_content LIKE sdokcntbin OCCURS 0 WITH HEADER LINE,
         alen TYPE i,
         pos TYPE i.

  MOVE '\mr0221TestA1.xls' TO lv_file_name.
  OPEN DATASET lv_file_name FOR INPUT IN BINARY MODE.
  IF sy-subrc NE 0.
    EXIT.
  ENDIF.

*--------------

  SET DATASET lv_file_name POSITION END OF FILE.
  GET DATASET lv_file_name POSITION pos.
  SET DATASET lv_file_name POSITION 0.
*--------------

  DO.
    CLEAR lt_content.
    READ DATASET lv_file_name INTO lt_content-line ACTUAL LENGTH alen .
    IF sy-subrc NE 0.
      APPEND lt_content.
      EXIT.
    ENDIF.
    APPEND lt_content.
  ENDDO.
  CLOSE DATASET lv_file_name.
*  DELETE DATASET lv_file_name.

*****************************************************

  CLEAR: lv_file_name.
  MOVE '\mr0221TestB2.xls' TO lv_file_name.
  OPEN DATASET lv_file_name FOR OUTPUT IN BINARY MODE.
  IF sy-subrc NE 0.
    EXIT.
  ENDIF.

  LOOP AT lt_content.
    AT LAST.
      TRANSFER lt_content-line TO lv_file_name LENGTH alen.
      EXIT.
    ENDAT.
    TRANSFER lt_content-line TO lv_file_name.
  ENDLOOP.
  CLOSE DATASET lv_file_name.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Nov 2006 09:50:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/open-data-set-problem-with-binary-mode/m-p/1691857#M303900</guid>
      <dc:creator>david_fryda2</dc:creator>
      <dc:date>2006-11-28T09:50:20Z</dc:date>
    </item>
  </channel>
</rss>

