<?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 dataset sample code in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dataset-sample-code/m-p/1390896#M189925</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having a .DAT file on the application server.Now i want to download into my internal tables using Datasets.&lt;/P&gt;&lt;P&gt;The format of the data is as below..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;000123450987&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first 4 places represent one field&lt;/P&gt;&lt;P&gt;second 3 places represent another field&lt;/P&gt;&lt;P&gt;the last 5 places represent another field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is no separator in between.Can any body provide me the sample code for this requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Jun 2006 14:41:09 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-06-13T14:41:09Z</dc:date>
    <item>
      <title>dataset sample code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dataset-sample-code/m-p/1390896#M189925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having a .DAT file on the application server.Now i want to download into my internal tables using Datasets.&lt;/P&gt;&lt;P&gt;The format of the data is as below..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;000123450987&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first 4 places represent one field&lt;/P&gt;&lt;P&gt;second 3 places represent another field&lt;/P&gt;&lt;P&gt;the last 5 places represent another field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is no separator in between.Can any body provide me the sample code for this requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jun 2006 14:41:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dataset-sample-code/m-p/1390896#M189925</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-13T14:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: dataset sample code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dataset-sample-code/m-p/1390897#M189926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DATA: l_car_ret(1) TYPE c,        " To store carriage return character&lt;/P&gt;&lt;P&gt;        l_lin_fed(1) TYPE c,        " To store Line feed character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; OPEN DATASET p_file FOR INPUT&lt;/P&gt;&lt;P&gt;      IN TEXT MODE&lt;/P&gt;&lt;P&gt;      ENCODING DEFAULT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    CLEAR l_car_ret.&lt;/P&gt;&lt;P&gt;    CLEAR l_lin_fed.&lt;/P&gt;&lt;P&gt;    MOVE cl_abap_char_utilities=&amp;gt;cr_lf+0(1) TO l_car_ret.&lt;/P&gt;&lt;P&gt;    MOVE cl_abap_char_utilities=&amp;gt;cr_lf+1(1) TO l_lin_fed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    DO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      TRY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Read the current row of the file&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          READ DATASET p_file INTO w_filedata.&lt;/P&gt;&lt;P&gt;          IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;            EXIT.                "End of file entries&lt;/P&gt;&lt;P&gt;          ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        CATCH cx_root.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;'Invalid input file format :Extraneous column'(048).&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      ENDTRY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Remove the trailing carriage return character, if any&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      SEARCH w_filedata FOR l_car_ret.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        CLEAR l_pos.&lt;/P&gt;&lt;P&gt;        MOVE sy-fdpos TO l_pos.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        REPLACE w_filedata+l_pos(1) IN w_filedata WITH space.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Remove the trailing line feed character, if any&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      SEARCH w_filedata FOR l_lin_fed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        CLEAR l_pos.&lt;/P&gt;&lt;P&gt;        MOVE sy-fdpos TO l_pos.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        REPLACE w_filedata+l_pos(1) IN w_filedata WITH space.&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;      w_data-field1 = w_filedata+0(4).&lt;/P&gt;&lt;P&gt;      w_data-field2 = w_filedata+4(3).&lt;/P&gt;&lt;P&gt;      w_data-field3 = w_filedata+7(5).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      APPEND w_data TO  t_data.&lt;/P&gt;&lt;P&gt;      CLEAR w_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    CLOSE DATASET p_file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jun 2006 14:46:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dataset-sample-code/m-p/1390897#M189926</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-13T14:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: dataset sample code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dataset-sample-code/m-p/1390898#M189927</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 following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : itab(255) occurs 0 with header line.&lt;/P&gt;&lt;P&gt;data : begin of itab1 occurs 0,&lt;/P&gt;&lt;P&gt;       f1(4),&lt;/P&gt;&lt;P&gt;       f2(3),&lt;/P&gt;&lt;P&gt;       f3(5),&lt;/P&gt;&lt;P&gt;       end of itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;open data set &amp;lt;name&amp;gt; for input in text mode encoding default.&lt;/P&gt;&lt;P&gt;do.&lt;/P&gt;&lt;P&gt;read dataset &amp;lt;name&amp;gt; into itab.&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;append itab.&lt;/P&gt;&lt;P&gt;clear itab.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;close dataset &amp;lt;name&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;  itab1-f1 = itab+0(4).&lt;/P&gt;&lt;P&gt;  itab1-f2 = itab+4(3).&lt;/P&gt;&lt;P&gt;  itab1-f3 = itab+7(5).&lt;/P&gt;&lt;P&gt;  append itab1.&lt;/P&gt;&lt;P&gt;  clear itab1.&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;Sreedhar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jun 2006 14:47:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dataset-sample-code/m-p/1390898#M189927</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-13T14:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: dataset sample code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dataset-sample-code/m-p/1390899#M189928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FORM read_file.&lt;/P&gt;&lt;P&gt;data : BEGIN OF IT_LINE ,&lt;/P&gt;&lt;P&gt;         VBELN(10)        TYPE C,&lt;/P&gt;&lt;P&gt;         BOLNR(35)        TYPE C,&lt;/P&gt;&lt;P&gt;         TRAID(20)        TYPE C,&lt;/P&gt;&lt;P&gt;         CARR_CHARGES(20) TYPE C,&lt;/P&gt;&lt;P&gt;         CURR_CODE(3)     TYPE C,&lt;/P&gt;&lt;P&gt;         ORD_CNT(4)       TYPE C,&lt;/P&gt;&lt;P&gt;         EXP_CNT(4)       TYPE C,&lt;/P&gt;&lt;P&gt;         WADAT_IST(10)    TYPE C,&lt;/P&gt;&lt;P&gt;      END OF IT_LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA : lv_len TYPE i,  " String length&lt;/P&gt;&lt;P&gt;  OPEN DATASET p_filename FOR INPUT  IN TEXT MODE&lt;/P&gt;&lt;P&gt;                      ENCODING DEFAULT&lt;/P&gt;&lt;P&gt;                      MESSAGE v_mess.&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;&lt;/P&gt;&lt;P&gt;*--file opened.&lt;/P&gt;&lt;P&gt;  DO.&lt;/P&gt;&lt;P&gt;    READ DATASET p_filename INTO it_line.&lt;/P&gt;&lt;P&gt;    IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      APPEND it_line.&lt;/P&gt;&lt;P&gt;      CLEAR it_line.&lt;/P&gt;&lt;P&gt;    ELSE.&lt;/P&gt;&lt;P&gt;      EXIT.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDDO.&lt;/P&gt;&lt;P&gt;As your input file is a fixed length file(i mean each field will be of specific length always) you can define an internal table with those fields of specified length &amp;amp; if you use READ dataset, automatically those fields will be populated properly in the IT_LINE table.no need to take another internal table to sort out.&lt;/P&gt;&lt;P&gt;you can use 1 internal table to read the values from the file &amp;amp; the values will go and fit in the table fields.&lt;/P&gt;&lt;P&gt;&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;srikanth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;added comments &lt;/P&gt;&lt;P&gt;Message was edited by: Srikanth Kidambi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jun 2006 14:47:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dataset-sample-code/m-p/1390899#M189928</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-13T14:47:36Z</dc:date>
    </item>
  </channel>
</rss>

