<?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 String Manipulation in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049807#M1611686</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am quite new to abap and I am trying to produce some output.  I have a string variable containing an address, but it stores the street name first and then the house number.  I want the output to display the house number first.  Any ideas on what code I would need to achieve this?  i.e if the string contained  "Moss Rd 26",  I want the output to read "26 Moss Rd".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Jul 2011 10:53:37 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-07-07T10:53:37Z</dc:date>
    <item>
      <title>String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049807#M1611686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am quite new to abap and I am trying to produce some output.  I have a string variable containing an address, but it stores the street name first and then the house number.  I want the output to display the house number first.  Any ideas on what code I would need to achieve this?  i.e if the string contained  "Moss Rd 26",  I want the output to read "26 Moss Rd".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 10:53:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049807#M1611686</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T10:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049808#M1611687</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 offset to fetch particular characters from string.Provided you know position of character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg:&lt;/P&gt;&lt;P&gt;v_string = 'Moss Rd 26'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v_house_no = v_string+2(7).&lt;/P&gt;&lt;P&gt;v_street = v_string+0(7).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 11:04:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049808#M1611687</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T11:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049809#M1611688</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;as these kind of data fields are pretty dynamic, the offsets have to be dynamic too. If it's given, that the house number is after the last blank, you can do this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
lf_s = 'Moss Rd 26'.

lf_i = STRLEN( lf_s ) - 1.
'--- where's the last blank?
DO.
  IF lf_i = 0. EXIT. ENDIF.
  IF lf_s+lf_i(1) = ' '. EXIT. ENDIF.
  lf_i = lf_i - 1.
ENDDO.

IF lf_i &amp;gt; 0.
'--- If there's any, split the string
  lf_l = STRLEN( lf_s ) - lf_i.
  WRITE: lf_s+lf_i(lf_l),
         lf_s(lf_i).
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps you can also add several check (numeric, length of field,...) for security reasons...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dirk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 11:21:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049809#M1611688</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T11:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049810#M1611689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Sap_Wiz, only problem is, this might not work if the house number is longer than 2 characters.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 12:15:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049810#M1611689</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T12:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049811#M1611690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you do if there's an apartment number?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 13:14:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049811#M1611690</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T13:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049812#M1611691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;At first you need to determine how your string is built. Is there something which uniqueley idetifies the house number? Is it always  after the last space? May it happen that after your housenumber something else is beeing added to that string?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If all those questions are answered, THEN you can think of how to do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Until then its more like "if you have A then doing B would be good, but if you have C doing D would be better".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 13:29:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049812#M1611691</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T13:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049813#M1611692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes the house number is coming in always after the last space, so I am hoping as Dirk suggested, that establishing this last space should be able to isolate the house number.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 13:35:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049813#M1611692</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T13:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049814#M1611693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It works if apartment number is not there. Regex is used.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA input TYPE char100 VALUE 'Moss Rd 26'.
DATA output TYPE char100.

DATA match TYPE match_result.
DATA submatch1 TYPE submatch_result.
DATA submatch2 TYPE submatch_result.

FIND FIRST OCCURRENCE OF REGEX '(\D*)(\d*)' IN input RESULTS match.

READ TABLE match-submatches INDEX 1 INTO submatch1.

READ TABLE match-submatches INDEX 2 INTO submatch2.
CONCATENATE input+submatch2-offset(submatch2-length)
            input+submatch1-offset(submatch1-length)
            INTO output SEPARATED BY space.
WRITE:/ output.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 13:53:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049814#M1611693</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T13:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049815#M1611694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Below code is longer but it works even if apartment number is present.&lt;/P&gt;&lt;P&gt;String is reversed first, then regex is used for swapping, then string is reversed again for final output.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA input TYPE char100 VALUE 'Moss 12 Rd 26'.
DATA output TYPE char100.

DATA match TYPE match_result.
DATA submatch1 TYPE submatch_result.
DATA submatch2 TYPE submatch_result.

CALL FUNCTION 'STRING_REVERSE'
  EXPORTING
    string    = input
    lang      = sy-langu
  IMPORTING
    rstring   = input
  EXCEPTIONS
    too_small = 1
    OTHERS    = 2.
IF sy-subrc EQ 0.
  FIND FIRST OCCURRENCE OF REGEX '(\d*)(.*)' IN input RESULTS match.
  READ TABLE match-submatches INDEX 1 INTO submatch1.
  READ TABLE match-submatches INDEX 2 INTO submatch2.
  CONCATENATE input+submatch2-offset(submatch2-length)
              input+submatch1-offset(submatch1-length)
              INTO output SEPARATED BY space.

  CALL FUNCTION 'STRING_REVERSE'
    EXPORTING
      string    = output
      lang      = sy-langu
    IMPORTING
      rstring   = output
    EXCEPTIONS
      too_small = 1
      OTHERS    = 2.
  WRITE:/ output.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 14:02:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049815#M1611694</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T14:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049816#M1611695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I have been able to use this, to form a solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Great help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 14:34:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049816#M1611695</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T14:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049817#M1611696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Next time, please assign polnts to helpful answers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 14:43:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049817#M1611696</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T14:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049818#M1611697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok Rob, I have done it now, hopes its not too late.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 14:53:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049818#M1611697</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T14:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: String Manipulation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049819#M1611698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's never too late.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2011 15:00:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/string-manipulation/m-p/8049819#M1611698</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-07T15:00:35Z</dc:date>
    </item>
  </channel>
</rss>

