<?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: remove last character in a string in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149225#M1193290</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can write this logic,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:  lv_len TYPE i.
lv_len = STRLEN( lv_c ).
SUBTRACT 1 FROM lv_len.
lv_c = lv_c+0(lv_len). "Here last character will be removed&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Manoj Kumar P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Feb 2009 08:39:30 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-02-10T08:39:30Z</dc:date>
    <item>
      <title>remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149213#M1193278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a variable with C type for example lv_c = 'xxxx#'. Now I want to remove the last character of this variable value? which function do I use? and how do I do that. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 07:27:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149213#M1193278</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-10T07:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149214#M1193279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use: SHIFT lv_c.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 07:29:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149214#M1193279</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-10T07:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149215#M1193280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;just use offsetting..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data&lt;/P&gt;&lt;P&gt;w_temp like lv_c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lv_c = 'xxxx#'.&lt;/P&gt;&lt;P&gt;w_temp = lv_c+0(4).&lt;/P&gt;&lt;P&gt;write: w_temp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;output is like this:&lt;/P&gt;&lt;P&gt; XXXX&lt;/P&gt;&lt;P&gt;lv_c+0(4) means it takes the first(i.e.from starting) 4 characters.based on this u can omitt or select the characters..just mention the offset value...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Kiran&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Kiran Saka on Feb 10, 2009 8:31 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 07:30:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149215#M1193280</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-10T07:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149216#M1193281</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;u can use n = strlen(lv_c) // u will get length of the string..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then  lv_c = lv_c+0(n-1)... will fetch u the value except last character..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds.,&lt;/P&gt;&lt;P&gt;subash&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 07:30:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149216#M1193281</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-10T07:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149217#M1193282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;here's the logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: str type string value 'abcd#',    len type i.

len = strlen( str ).
len = len - 1.
str = str+0(len).

write:/ str.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 07:33:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149217#M1193282</guid>
      <dc:creator>former_member222860</dc:creator>
      <dc:date>2009-02-10T07:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149218#M1193283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;first find string length from function strlen&lt;/P&gt;&lt;P&gt;lv_len = strlen(lv_c)&lt;/P&gt;&lt;P&gt;lv_len = lv_len - 1&lt;/P&gt;&lt;P&gt;then make one more var of type lv_c lv_c1&lt;/P&gt;&lt;P&gt;lv_c1 = lv_c + 0(lv_len)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 07:33:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149218#M1193283</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-10T07:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149219#M1193284</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;data w_i type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;w_i = strlen( lv_c ).&lt;/P&gt;&lt;P&gt;subtract 1 from w_i.&lt;/P&gt;&lt;P&gt;write : lv_c+0(w_i).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 07:35:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149219#M1193284</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-10T07:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149220#M1193285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;You  can use the following code  It will solve the problem.-----&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : w_data(6) TYPE c VALUE 'ABCDEF'.
CONDENSE w_data NO-GAPS.
SHIFT  w_data RIGHT .
WRITE w_data.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards &lt;/P&gt;&lt;P&gt;Pinaki&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 07:36:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149220#M1193285</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-10T07:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149221#M1193286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;  you can use &lt;/P&gt;&lt;P&gt;shift lv_c &lt;/P&gt;&lt;P&gt;condense lv_c&lt;/P&gt;&lt;P&gt;it should give you the remaining characters&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Viquar Iqbal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 07:40:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149221#M1193286</guid>
      <dc:creator>viquar_iqbal</dc:creator>
      <dc:date>2009-02-10T07:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149222#M1193287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is a special character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To remove the special characters use below FM,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONVERT_STREAM_TO_ITF_TEXT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 07:43:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149222#M1193287</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-10T07:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149223#M1193288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;w_str(5) type c value 'xxxx#'.&lt;/P&gt;&lt;P&gt;shift w_str by 1 places right.&lt;/P&gt;&lt;P&gt;write:/ w_str.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Mdi.Deeba&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 07:46:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149223#M1193288</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-10T07:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149224#M1193289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anthony ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly go through this link below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/9f/db999535c111d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/9f/db999535c111d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regrds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mansi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 07:46:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149224#M1193289</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-10T07:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149225#M1193290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can write this logic,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:  lv_len TYPE i.
lv_len = STRLEN( lv_c ).
SUBTRACT 1 FROM lv_len.
lv_c = lv_c+0(lv_len). "Here last character will be removed&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Manoj Kumar P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2009 08:39:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149225#M1193290</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-10T08:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149226#M1193291</link>
      <description>&lt;P&gt;thank u issue resolved.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 05:59:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/5149226#M1193291</guid>
      <dc:creator>former_member770121</dc:creator>
      <dc:date>2021-11-03T05:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: remove last character in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/14099343#M2041807</link>
      <description>&lt;P&gt;&lt;FONT color="#000000"&gt;While working in ABAP, especially when preparing data for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;file downloads&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;exporting internal tables&lt;/STRONG&gt;, you might notice that some lines seem to end with a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT size="4" color="#003366"&gt;&lt;STRONG&gt;" # "&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/FONT&gt;symbol. But here's the catch&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;that&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT size="4" color="#003366"&gt;" # "&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is not always a real hash symbol.&amp;nbsp;&lt;/STRONG&gt;Naturally, you might think it’s a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;hashtag&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;— but often, it’s not. These characters&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;don’t display visually&lt;/STRONG&gt;, but depending on how the file is opened or downloaded, they may appear as strange or misleading symbols.&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;H3 id="toc-hId-1859709276"&gt;&lt;FONT color="#003366"&gt;What’s Actually Happening?&lt;/FONT&gt;&lt;/H3&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Sometimes, that&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT size="4" color="#003366"&gt;&lt;STRONG&gt;" # "&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is just how&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;non-printable characters&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;like&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;carriage return (CR)&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;or&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;newline (LF)&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;appear when viewed in SAP ALV, Excel, or when downloading.&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;These hidden characters:&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT color="#000000"&gt;Can&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;break the line&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;unexpectedly in the downloaded file&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#000000"&gt;May cause the data to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;appear in a new row or line&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#000000"&gt;Often sneak in from copied text, manual input, or external systems&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H3 id="toc-hId-1663195771"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#003366"&gt;How to Fix It? - Solution (with hex check)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/H3&gt;&lt;P class=""&gt;&lt;FONT color="#000000"&gt;Here’s a reliable way to &lt;STRONG&gt;detect the actual last character&lt;/STRONG&gt; and remove it only if needed (e.g. it's a # or control character):&lt;/FONT&gt;&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;DATA: lv_value    TYPE string VALUE 'ABCDE#',  " Input string (may have unwanted char at end)" replace this variable with yours*
      lv_len      TYPE i,                      " Length of the string
      lv_lastval  TYPE string,             " Last character of the string
      lv_hex      TYPE xstring,                 " Hex value of the last character
      lv_newval   TYPE string.                 " Final cleaned value

" Step 1: Find the length of the string
lv_len = strlen( lv_value ).
SUBTRACT 1 FROM lv_len.  " Adjust to point to last character (0-based index)

" Step 2: Get the last character
lv_lastval = lv_value+lv_len(1).

" Step 3: Convert last character to hex using built-in function module
CALL FUNCTION 'NLS_STRING_CONVERT_FROM_SYS'
  EXPORTING
    lang_used = sy-langu       " Use system language
    source    = lv_lastval     " Character to convert
    to_fe     = 'MS '          " Target frontend encoding (Microsoft)
  IMPORTING
    result    = lv_hex         " Hex value of the character
  EXCEPTIONS
    OTHERS    = 1.             " Simple error catch

" Step 4: Check if the character is '#' (hex 23)
IF lv_hex = '23'.  " ASCII hex for '#'
  lv_newval = lv_value+0(lv_len).  " Remove last character
ELSE.
  lv_newval = lv_value.            " Keep original if not '#'
ENDIF.&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT color="#000000"&gt;NLS_STRING_CONVERT_FROM_SYS helps get the &lt;STRONG&gt;true hex value&lt;/STRONG&gt; of a character.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#000000"&gt;This avoids misleading visual characters (like #) that are actually CR, LF, etc.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;I hope this helps! Let me know your thoughts or if you have any questions.&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;Thanks,&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4" color="#003366"&gt;&lt;SPAN&gt;&lt;STRONG&gt;Akshay Anil&lt;/STRONG&gt;&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;Technical Consultant, SAP ABAP | BTP | Fiori | Ui5&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 May 2025 18:27:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/remove-last-character-in-a-string/m-p/14099343#M2041807</guid>
      <dc:creator>AkshayAnil919</dc:creator>
      <dc:date>2025-05-22T18:27:53Z</dc:date>
    </item>
  </channel>
</rss>

