<?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: replace in a string in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449054#M212775</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jon,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls elaborate your requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shekhar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Jul 2006 06:55:06 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-07-17T06:55:06Z</dc:date>
    <item>
      <title>replace in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449053#M212774</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 need to remove som values in a string if it's longer than 18 char. The logic is as follows. If len &amp;gt; 18 start removing '-' from back of the string until (if possible) the length is 18. &lt;/P&gt;&lt;P&gt;I have probelms reaplcing from behind, any ideas? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/jon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2006 06:52:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449053#M212774</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-17T06:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: replace in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449054#M212775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jon,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls elaborate your requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shekhar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2006 06:55:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449054#M212775</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-17T06:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: replace in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449055#M212776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;STRING = 'ABDCE'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LEN = STRLEN( STRING ). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;if len &amp;gt; 18.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;use  logic  like  that....&lt;/P&gt;&lt;P&gt;REPORT abc.&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(50),&lt;/P&gt;&lt;P&gt;       END OF itab.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;DATA : cha(50) VALUE 'cha-sek-jskjfsjf',&lt;/P&gt;&lt;P&gt;       str(2000).&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;SPLIT cha 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; &lt;/P&gt;&lt;P&gt; concatenate str itab-str into str separated by space.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; endloop.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; write : str.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2006 06:56:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449055#M212776</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-17T06:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: replace in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449056#M212777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Jon,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this.&lt;/P&gt;&lt;P&gt;data var_len type i, ch type c.&lt;/P&gt;&lt;P&gt;var_len = strlen of string.&lt;/P&gt;&lt;P&gt;if var_len &amp;gt; 18.&lt;/P&gt;&lt;P&gt;var_len = var_len - 1.&lt;/P&gt;&lt;P&gt; ch = string+var_len(1).&lt;/P&gt;&lt;P&gt;do var_len times.&lt;/P&gt;&lt;P&gt; if ch = '-'.&lt;/P&gt;&lt;P&gt;   delete that character.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is just a rough logic... try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Madan..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2006 07:00:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449056#M212777</guid>
      <dc:creator>madan_ullasa</dc:creator>
      <dc:date>2006-07-17T07:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: replace in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449057#M212778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jon,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider these code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;If you want to repalce all '-' with spaces and condense&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  zztest_arun_1 .

DATA : string TYPE string.

START-OF-SELECTION.
string = 'sdfsadf--asdf-asd-asd-'.

IF STRLEN( string ) GT 18.

  TRANSLATE string USING '- '.
  CONDENSE string NO-GAPS.

ENDIF.

WRITE :  string.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;If you want to repalce only  '-' till length 18 form backwards with spaces and condense&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  REPORT  zztest_arun_2 .

  DATA : string TYPE string,
         len TYPE i,
         off TYPE i.

  START-OF-SELECTION.
    string = 'sdfsadf--asdf-asd-asd-'.

    len =  STRLEN( string ).

    IF len GT 18.

      DO.

        IF  STRLEN( string ) GT 18.

          off = len - sy-index.

          REPLACE '-' IN SECTION OFFSET off LENGTH -1 OF string WITH space.
          CONDENSE string NO-GAPS.


        ELSE.

          EXIT.

        ENDIF.

      ENDDO.

    ENDIF.

    WRITE :  string.

&lt;/CODE&gt;&lt;/PRE&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;Arun Sambargi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Arun Sambargi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2006 07:08:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449057#M212778</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-17T07:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: replace in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449058#M212779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jon&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       You can use the following code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  data: str(50 )type c.&lt;/P&gt;&lt;P&gt;  data: len type i.&lt;/P&gt;&lt;P&gt;  data: diff type i.&lt;/P&gt;&lt;P&gt;  str = 'njiodjjjiojsjfgj----&lt;/P&gt;&lt;HR originaltext="-----" /&gt;&lt;P&gt;'.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;len = strlen( str).&lt;/P&gt;&lt;P&gt;diff = len - 18.&lt;/P&gt;&lt;P&gt;if diff &amp;gt; 0.&lt;/P&gt;&lt;P&gt;  SHIFT str RIGHT DELETING TRAILING '-'.  &lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this must solve out yor problem. If problem presists do reply.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2006 07:31:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449058#M212779</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-17T07:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: replace in a string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449059#M212780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi.&lt;/P&gt;&lt;P&gt;and thanks to everyone helping!&lt;/P&gt;&lt;P&gt;this does not quite do what i need.&lt;/P&gt;&lt;P&gt;ie. i could get a string looking like this:&lt;/P&gt;&lt;P&gt;1234-678-12-34-56789 &lt;/P&gt;&lt;P&gt;It's 19 char long and i need to remove the last '-' so that the string will be 1234-678-12-3456789&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when testing all the possible solutions i'm only able to remove all the '-'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i was thinking about writing the string in reverse to a temp_string and just replace first occ. of '-', but i cant find a easy way to reverse the string either...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/jon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2006 07:41:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/replace-in-a-string/m-p/1449059#M212780</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-17T07:41:24Z</dc:date>
    </item>
  </channel>
</rss>

