<?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: Variable Length Files and ABAP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length-files-and-abap/m-p/1356819#M177933</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 guess rich has written more efficient program anyways this is what I could do.&lt;/P&gt;&lt;P&gt;data : begin of i_line occurs 0,&lt;/P&gt;&lt;P&gt;        line(100),&lt;/P&gt;&lt;P&gt;        end of i_line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data : begin of i_format occurs 0,&lt;/P&gt;&lt;P&gt;        txt1(5),&lt;/P&gt;&lt;P&gt;        txt2(5),&lt;/P&gt;&lt;P&gt;        txt3(5),&lt;/P&gt;&lt;P&gt;        txt4(5),&lt;/P&gt;&lt;P&gt;        txt5(5),&lt;/P&gt;&lt;P&gt;        txt6(5),&lt;/P&gt;&lt;P&gt;        txt7(5),&lt;/P&gt;&lt;P&gt;        txt8(5),&lt;/P&gt;&lt;P&gt;        end of i_format.&lt;/P&gt;&lt;P&gt;   data : comma type c,&lt;/P&gt;&lt;P&gt;      off  TYPE i,&lt;/P&gt;&lt;P&gt;      moff TYPE i,&lt;/P&gt;&lt;P&gt;      mlen TYPE i,&lt;/P&gt;&lt;P&gt;      count type i,&lt;/P&gt;&lt;P&gt;      len(3),&lt;/P&gt;&lt;P&gt;      n type i.&lt;/P&gt;&lt;P&gt; start-of-selection.&lt;/P&gt;&lt;P&gt; i_line-line = 'Abc,abc,abc,abc,abc,003,1a,1b,2a,2b,3a,3c'.&lt;/P&gt;&lt;P&gt; append i_line.&lt;/P&gt;&lt;P&gt; clear i_line.&lt;/P&gt;&lt;P&gt;i_line-line = 'DCE,abc,abc,abc,abc,005,1a,1b,2a,2b,3a,3c,4a,4b,5a,5b'.&lt;/P&gt;&lt;P&gt;append i_line.&lt;/P&gt;&lt;P&gt;clear i_line.&lt;/P&gt;&lt;P&gt;comma = ','.&lt;/P&gt;&lt;P&gt;loop at i_line.&lt;/P&gt;&lt;P&gt;off = 0.&lt;/P&gt;&lt;P&gt;count = 0.&lt;/P&gt;&lt;P&gt;moff = 0.&lt;/P&gt;&lt;P&gt;while count lt 5.&lt;/P&gt;&lt;P&gt;count = count + 1.&lt;/P&gt;&lt;P&gt;find comma in section OFFSET off OF&lt;/P&gt;&lt;P&gt;                i_line-line&lt;/P&gt;&lt;P&gt;                MATCH OFFSET moff&lt;/P&gt;&lt;P&gt;                MATCH LENGTH mlen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;off = moff + mlen.&lt;/P&gt;&lt;P&gt;write : / 'moff',moff,&lt;/P&gt;&lt;P&gt;          'mlen', mlen..&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;endwhile.&lt;/P&gt;&lt;P&gt;moff = moff + 1.&lt;/P&gt;&lt;P&gt;write : i_line-line+moff(3) to len no-zero.&lt;/P&gt;&lt;P&gt;write &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; 'The len is ', len.&lt;/P&gt;&lt;P&gt;i_format-txt1 = i_line+0(3).&lt;/P&gt;&lt;P&gt;i_format-txt2 = i_line+4(3).&lt;/P&gt;&lt;P&gt;i_format-txt3 = i_line+8(3).&lt;/P&gt;&lt;P&gt;i_format-txt4 = i_line+12(3).&lt;/P&gt;&lt;P&gt;i_format-txt5 = i_line+16(3).&lt;/P&gt;&lt;P&gt;i_format-txt6 = i_line+20(3).&lt;/P&gt;&lt;P&gt;n = 24.&lt;/P&gt;&lt;P&gt;do len times.&lt;/P&gt;&lt;P&gt;i_format-txt7 = i_line+n(2).&lt;/P&gt;&lt;P&gt;n = n + 3.&lt;/P&gt;&lt;P&gt;i_format-txt8 = i_line+n(2).&lt;/P&gt;&lt;P&gt;n = n + 3.&lt;/P&gt;&lt;P&gt;append i_format.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at i_format.&lt;/P&gt;&lt;P&gt;write &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; i_format.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt; end-of-selection.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 May 2006 21:49:13 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-05-10T21:49:13Z</dc:date>
    <item>
      <title>Variable Length Files and ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length-files-and-abap/m-p/1356817#M177931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a comma delimited file that is of a variable length.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first 5 fields are fixed, but then I have a counter field and then 2 fields that repeat for each counter.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if the counter field was 3, I&amp;#146;d have 6 additional fields, but if the counter was 5, I&amp;#146;d have 10 additional fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The goal is to end up with 3 records (since the counter was 3) with the 5 fixed fields then the 2 fields respectively.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Such as if it looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Abc,abc,abc,abc,abc,003,1a,1b,2a,2b,3a,3c&lt;/P&gt;&lt;P&gt;DCE,abc,abc,abc,abc,005,1a,1b,2a,2b,3a,3c,4a,4b,5a,5b&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need it to look like this or at least be able to read it similar to this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Abc,abc,abc,abc,abc,003,1a,1b&lt;/P&gt;&lt;P&gt;Abc,abc,abc,abc,abc,003,2a,2b,&lt;/P&gt;&lt;P&gt;Abc,abc,abc,abc,abc,003,3a,3c&lt;/P&gt;&lt;P&gt;DCE,abc,abc,abc,abc,005,1a,1b&lt;/P&gt;&lt;P&gt;DCE,abc,abc,abc,abc,005,2a,2b&lt;/P&gt;&lt;P&gt;DCE,abc,abc,abc,abc,005,3a,3c&lt;/P&gt;&lt;P&gt;DCE,abc,abc,abc,abc,005,4a,4b&lt;/P&gt;&lt;P&gt;DCE,abc,abc,abc,abc,005,5a,5b&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 May 2006 19:57:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length-files-and-abap/m-p/1356817#M177931</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-05-10T19:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Length Files and ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length-files-and-abap/m-p/1356818#M177932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pam, you can try something like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001.

data: record type string.
data: counter type i.
data: index type i.
data: iout type table of string with header line.
data: irec type table of string with header line.

record = 'DCE,abc,abc,abc,abc,005,1a,1b,2a,2b,3a,3c,4a,4b,5a,5b'.

split record at ',' into table irec.

index  = 6.
read table irec index index.
counter = irec.

do counter times.

  clear iout.

  loop at irec.
    check sy-tabix &amp;lt;= 6.
    if sy-tabix = 1.
      iout = irec.
    else.
      concatenate iout irec into iout separated by ','.
    endif.
  endloop.

  do 2 times.
    index  = index + 1.
    read table irec index index.
    concatenate iout irec into iout separated by ','.
  enddo.

  append iout.

enddo.


loop at iout.
  write:/ iout.
endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&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>Wed, 10 May 2006 20:05:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length-files-and-abap/m-p/1356818#M177932</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-05-10T20:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Length Files and ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length-files-and-abap/m-p/1356819#M177933</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 guess rich has written more efficient program anyways this is what I could do.&lt;/P&gt;&lt;P&gt;data : begin of i_line occurs 0,&lt;/P&gt;&lt;P&gt;        line(100),&lt;/P&gt;&lt;P&gt;        end of i_line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data : begin of i_format occurs 0,&lt;/P&gt;&lt;P&gt;        txt1(5),&lt;/P&gt;&lt;P&gt;        txt2(5),&lt;/P&gt;&lt;P&gt;        txt3(5),&lt;/P&gt;&lt;P&gt;        txt4(5),&lt;/P&gt;&lt;P&gt;        txt5(5),&lt;/P&gt;&lt;P&gt;        txt6(5),&lt;/P&gt;&lt;P&gt;        txt7(5),&lt;/P&gt;&lt;P&gt;        txt8(5),&lt;/P&gt;&lt;P&gt;        end of i_format.&lt;/P&gt;&lt;P&gt;   data : comma type c,&lt;/P&gt;&lt;P&gt;      off  TYPE i,&lt;/P&gt;&lt;P&gt;      moff TYPE i,&lt;/P&gt;&lt;P&gt;      mlen TYPE i,&lt;/P&gt;&lt;P&gt;      count type i,&lt;/P&gt;&lt;P&gt;      len(3),&lt;/P&gt;&lt;P&gt;      n type i.&lt;/P&gt;&lt;P&gt; start-of-selection.&lt;/P&gt;&lt;P&gt; i_line-line = 'Abc,abc,abc,abc,abc,003,1a,1b,2a,2b,3a,3c'.&lt;/P&gt;&lt;P&gt; append i_line.&lt;/P&gt;&lt;P&gt; clear i_line.&lt;/P&gt;&lt;P&gt;i_line-line = 'DCE,abc,abc,abc,abc,005,1a,1b,2a,2b,3a,3c,4a,4b,5a,5b'.&lt;/P&gt;&lt;P&gt;append i_line.&lt;/P&gt;&lt;P&gt;clear i_line.&lt;/P&gt;&lt;P&gt;comma = ','.&lt;/P&gt;&lt;P&gt;loop at i_line.&lt;/P&gt;&lt;P&gt;off = 0.&lt;/P&gt;&lt;P&gt;count = 0.&lt;/P&gt;&lt;P&gt;moff = 0.&lt;/P&gt;&lt;P&gt;while count lt 5.&lt;/P&gt;&lt;P&gt;count = count + 1.&lt;/P&gt;&lt;P&gt;find comma in section OFFSET off OF&lt;/P&gt;&lt;P&gt;                i_line-line&lt;/P&gt;&lt;P&gt;                MATCH OFFSET moff&lt;/P&gt;&lt;P&gt;                MATCH LENGTH mlen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;off = moff + mlen.&lt;/P&gt;&lt;P&gt;write : / 'moff',moff,&lt;/P&gt;&lt;P&gt;          'mlen', mlen..&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;endwhile.&lt;/P&gt;&lt;P&gt;moff = moff + 1.&lt;/P&gt;&lt;P&gt;write : i_line-line+moff(3) to len no-zero.&lt;/P&gt;&lt;P&gt;write &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; 'The len is ', len.&lt;/P&gt;&lt;P&gt;i_format-txt1 = i_line+0(3).&lt;/P&gt;&lt;P&gt;i_format-txt2 = i_line+4(3).&lt;/P&gt;&lt;P&gt;i_format-txt3 = i_line+8(3).&lt;/P&gt;&lt;P&gt;i_format-txt4 = i_line+12(3).&lt;/P&gt;&lt;P&gt;i_format-txt5 = i_line+16(3).&lt;/P&gt;&lt;P&gt;i_format-txt6 = i_line+20(3).&lt;/P&gt;&lt;P&gt;n = 24.&lt;/P&gt;&lt;P&gt;do len times.&lt;/P&gt;&lt;P&gt;i_format-txt7 = i_line+n(2).&lt;/P&gt;&lt;P&gt;n = n + 3.&lt;/P&gt;&lt;P&gt;i_format-txt8 = i_line+n(2).&lt;/P&gt;&lt;P&gt;n = n + 3.&lt;/P&gt;&lt;P&gt;append i_format.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at i_format.&lt;/P&gt;&lt;P&gt;write &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; i_format.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt; end-of-selection.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Vick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 May 2006 21:49:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length-files-and-abap/m-p/1356819#M177933</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-05-10T21:49:13Z</dc:date>
    </item>
  </channel>
</rss>

