<?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 Checking a file for data in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-a-file-for-data/m-p/1723967#M315772</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I am new to ABAP so please bear with me if my question is a little stupid...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am creating a program to dataload information into a transaction from a text file.  I am checking the file exists by doing the following:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;OPEN DATASET file IN TEXT MODE.

IF sy-subrc &amp;lt;&amp;gt; 0.

  MESSAGE s001(zt) WITH 'Unable to locate specified file'.
  STOP.

ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But I would also like to be able to check the contents of the file and stop the program creating a batch input session if an empty file is being loaded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way this can be done?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Carly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Oct 2006 14:26:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-10-30T14:26:19Z</dc:date>
    <item>
      <title>Checking a file for data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-a-file-for-data/m-p/1723967#M315772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I am new to ABAP so please bear with me if my question is a little stupid...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am creating a program to dataload information into a transaction from a text file.  I am checking the file exists by doing the following:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;OPEN DATASET file IN TEXT MODE.

IF sy-subrc &amp;lt;&amp;gt; 0.

  MESSAGE s001(zt) WITH 'Unable to locate specified file'.
  STOP.

ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But I would also like to be able to check the contents of the file and stop the program creating a batch input session if an empty file is being loaded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way this can be done?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Carly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Oct 2006 14:26:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/checking-a-file-for-data/m-p/1723967#M315772</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-30T14:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Checking a file for data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-a-file-for-data/m-p/1723968#M315773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, after you open it you can simply read it, into your ITAB, then check ITAB afterwards, if not initial, then create your BI SESSION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001.

Parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt'.
   

data: itab type table of string.
data: wa type string.

start-of-selection.

* Read file
  open dataset d1 for input in text mode.
  if sy-subrc = 0.
    do.
      read dataset d1 into wa.
      if sy-subrc &amp;lt;&amp;gt; 0.
        exit.
      endif.
      append wa to itab.
    enddo.
  endif.
  close dataset d1.
&amp;lt;b&amp;gt;
if not itab[] is initial.
* then create your BI session.
endif.&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;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Oct 2006 14:30:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/checking-a-file-for-data/m-p/1723968#M315773</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-10-30T14:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Checking a file for data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-a-file-for-data/m-p/1723969#M315774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OPEN DATASET file for input IN TEXT MODE.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  MESSAGE s001(zt) WITH 'Unable to locate specified file'.&lt;/P&gt;&lt;P&gt;  STOP.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do.&lt;/P&gt;&lt;P&gt;read dataset file into jtab. &lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;exit.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;close dataset file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if jtab is not initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at jtab.&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;write ur bdc code here&lt;/P&gt;&lt;P&gt;endloop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Kaluvala Santhosh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Oct 2006 14:31:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/checking-a-file-for-data/m-p/1723969#M315774</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-30T14:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Checking a file for data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-a-file-for-data/m-p/1723970#M315775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Carly,&lt;/P&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: lines type sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET DATEI_AC FOR INPUT IN TEXT MODE.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;IF SY-SUBRC NE 0. MESSAGE E001. EXIT. ENDIF.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;  READ DATASET DATEI_AC INTO ITAB_AC.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0. EXIT. ENDIF. "EOF reached&lt;/P&gt;&lt;P&gt;  APPEND ITAB_AC.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;  CLOSE DATASET DATEI_AC.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;describe table itab_AC lines lines.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;if lines = 0. "than are no lines in the external file.&lt;/P&gt;&lt;P&gt;  write: / 'Nolines in external file'.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;do what you want.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Dieter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Oct 2006 14:38:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/checking-a-file-for-data/m-p/1723970#M315775</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-30T14:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Checking a file for data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/checking-a-file-for-data/m-p/1723971#M315776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;      if itab[] is initial.&lt;/P&gt;&lt;P&gt;       message 'No data to transfer'&lt;/P&gt;&lt;P&gt;      else.&lt;/P&gt;&lt;P&gt;       loop at itab.&lt;/P&gt;&lt;P&gt;         transfer itab to gv_file.&lt;/P&gt;&lt;P&gt;        endloop.  &lt;/P&gt;&lt;P&gt;      endif.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;amole&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Oct 2006 15:26:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/checking-a-file-for-data/m-p/1723971#M315776</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-30T15:26:11Z</dc:date>
    </item>
  </channel>
</rss>

