<?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: Truncating string in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401478#M194064</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Look at this code below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: v_index LIKE sy-tabix.
DO.
  SEARCH p_file+v_index FOR '/'. " or '' depending on unix or pc.
  IF sy-subrc &amp;lt;&amp;gt; 0.
    v_file_name = p_file+v_index.
  ELSE.
    v_index = v_index + sy-fdpos + 1.
  ENDIF.
ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I didn't see the response you gave regarding the extension part of it. v_file_name from my code above will give you the file name with the extension. You can then split the file name at '.' and get file name and extension separated out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Srinivas Adavi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Jun 2006 19:04:07 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-06-26T19:04:07Z</dc:date>
    <item>
      <title>Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401474#M194060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Say for example I have a string of file directory in such a way:&lt;/P&gt;&lt;P&gt;c:/dir/subdir/subdir/subdir/.../filename.txt&lt;/P&gt;&lt;P&gt;and i would like to extract only filename from this string, how should I do it? Thanks a lot!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 18:54:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401474#M194060</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T18:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401475#M194061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use &amp;lt;b&amp;gt;SPLIT&amp;lt;/b&amp;gt; Statement .....&lt;/P&gt;&lt;P&gt;else Use FM &amp;lt;b&amp;gt;TEXT_SPLIT&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 19:00:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401475#M194061</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T19:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401476#M194062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;split by "/"? but how can I get rid of the ".txt" then if the file name can be of any length? Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 19:02:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401476#M194062</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T19:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401477#M194063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use FM SO_SPLIT_FILE_AND_PATH&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;br&lt;/P&gt;&lt;P&gt;Andrzej&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 19:03:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401477#M194063</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T19:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401478#M194064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Look at this code below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: v_index LIKE sy-tabix.
DO.
  SEARCH p_file+v_index FOR '/'. " or '' depending on unix or pc.
  IF sy-subrc &amp;lt;&amp;gt; 0.
    v_file_name = p_file+v_index.
  ELSE.
    v_index = v_index + sy-fdpos + 1.
  ENDIF.
ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I didn't see the response you gave regarding the extension part of it. v_file_name from my code above will give you the file name with the extension. You can then split the file name at '.' and get file name and extension separated out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Srinivas Adavi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 19:04:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401478#M194064</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T19:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401479#M194065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Use FM &amp;lt;b&amp;gt;TEXT_SPLIT&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Have a look at this link so as to know how to use that FM&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="399858"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can check this so as to know as how to use Split statement&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;http://help.sap.com/saphelp_erp2005/helpdata/en/fc/eb33f3358411d1829f0000e829fbfe/frameset.htm&amp;lt;/b&amp;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>Mon, 26 Jun 2006 19:05:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401479#M194065</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T19:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401480#M194066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anyi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use SPLIT &amp;lt;string&amp;gt; AT &amp;lt;delimiter&amp;gt; INTO TABLE &amp;lt;itab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Laxmi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 19:08:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401480#M194066</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T19:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401481#M194067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001.

parameters: fullname type rlgrap-filename
     default 'c:/dir/subdir/subdir/subdir/.../filename.txt'.

data: file_name type rlgrap-filename.
data: file_path type rlgrap-filename.

call function 'SO_SPLIT_FILE_AND_PATH'
     exporting
          full_name     = fullname
     importing
          stripped_name = file_name
          file_path     = file_path.

write:/ file_name.

&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, 26 Jun 2006 19:09:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401481#M194067</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-06-26T19:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401482#M194068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi anyi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this fm &amp;lt;b&amp;gt;'PC_SPLIT_COMPLETE_FILENAME'&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="1593702"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 19:09:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401482#M194068</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T19:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401483#M194069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I kind of like Rich's answer, but his answer does not truncate the extension of the file as well, any tip on that, the file could be of any extension with variable length. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 19:29:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401483#M194069</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T19:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401484#M194070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh,  must have missed that part.  &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001.

parameters: fullname type rlgrap-filename
     default 'c:/dir/subdir/subdir/subdir/.../filename.txt'.

data: file_name type rlgrap-filename.
data: file_path type rlgrap-filename.
&amp;lt;b&amp;gt;data: file_ext type rlgrap-filename.&amp;lt;/b&amp;gt;

call function 'SO_SPLIT_FILE_AND_PATH'
     exporting
          full_name     = fullname
     importing
          stripped_name = file_name
          file_path     = file_path.

&amp;lt;b&amp;gt;split file_name at '.' into file_name file_ext.&amp;lt;/b&amp;gt;

write:/ file_name.

&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>Mon, 26 Jun 2006 19:34:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401484#M194070</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-06-26T19:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401485#M194071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since we now that the extension will always be a length of three and a period,  we can do this too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001.

parameters: fullname type rlgrap-filename
     default 'c:/dir/subdir/subdir/subdir/.../filename.txt'.

data: file_name type rlgrap-filename.
data: file_path type rlgrap-filename.

call function 'SO_SPLIT_FILE_AND_PATH'
     exporting
          full_name     = fullname
     importing
          stripped_name = file_name
          file_path     = file_path.

&amp;lt;b&amp;gt;shift file_name right deleting trailing space.
shift file_name right by 4 places.
shift file_name left deleting leading space.&amp;lt;/b&amp;gt;

write:/ file_name.


&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>Mon, 26 Jun 2006 19:45:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401485#M194071</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-06-26T19:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401486#M194072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could even do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


report zrich_0001.

parameters: fullname type rlgrap-filename
     default 'c:/dir/subdir/subdir/subdir/.../filename.txt'.

data: file_name type rlgrap-filename.
data: file_path type rlgrap-filename.

call function 'SO_SPLIT_FILE_AND_PATH'
     exporting
          full_name     = fullname
     importing
          stripped_name = file_name
          file_path     = file_path.

&amp;lt;b&amp;gt;search file_name for '...'.
if sy-subrc = 0.
  clear file_name+sy-fdpos(4).
endif.&amp;lt;/b&amp;gt;

write:/ file_name.

&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>Mon, 26 Jun 2006 20:15:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401486#M194072</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-06-26T20:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Truncating string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401487#M194073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anyi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this one.&lt;/P&gt;&lt;P&gt;data: file_path type string ,&lt;/P&gt;&lt;P&gt;      file_name type string ,&lt;/P&gt;&lt;P&gt;      file_ext type string ,&lt;/P&gt;&lt;P&gt;      n type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of itab occurs 0,&lt;/P&gt;&lt;P&gt;      str(25) type c,&lt;/P&gt;&lt;P&gt;      end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;file_path = 'C:/Test/Text.txt'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;split file_path at '/' into table itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;file_name = itab-str.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;split file_path at '.' into file_name file_ext.&lt;/P&gt;&lt;P&gt;write file_name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 21:01:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/truncating-string/m-p/1401487#M194073</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T21:01:03Z</dc:date>
    </item>
  </channel>
</rss>

