<?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 Write a string separated by Hyphens. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108417#M1973387</link>
    <description>&lt;P&gt;I have a string,&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;lv_serial = 'ABCDEFGHIJKL1237'.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Want to write like this below,&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;'AB-CD-EF-GH-IJ-KL-12-37'.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Need help.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jan 2020 09:46:01 GMT</pubDate>
    <dc:creator>former_member634045</dc:creator>
    <dc:date>2020-01-10T09:46:01Z</dc:date>
    <item>
      <title>Write a string separated by Hyphens.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108417#M1973387</link>
      <description>&lt;P&gt;I have a string,&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;lv_serial = 'ABCDEFGHIJKL1237'.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Want to write like this below,&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;'AB-CD-EF-GH-IJ-KL-12-37'.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Need help.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 09:46:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108417#M1973387</guid>
      <dc:creator>former_member634045</dc:creator>
      <dc:date>2020-01-10T09:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: Write a string separated by Hyphens.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108418#M1973388</link>
      <description>&lt;P&gt;As it is a string and you do not know the size of the input, you cannot use REGEX, WRITE ... MASK, CONCATENATE, ... &lt;/P&gt;&lt;P&gt;You need to do a loop in the character of the input and every 2 insert the character - &lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 10:05:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108418#M1973388</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2020-01-10T10:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: Write a string separated by Hyphens.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108419#M1973389</link>
      <description>&lt;P&gt;I think that the goal of the exercise is to let you search in the ABAP documentation and find the right functions. For instance, start here: &lt;A href="https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/index.htm?file=abenstring_processing_expr_func.htm"&gt;string expressions and functions&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 10:14:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108419#M1973389</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-01-10T10:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Write a string separated by Hyphens.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108420#M1973390</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;frdric.girod&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;I have written a code for this. But need to reduce garbage code. Complexity level is high.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;lv_serial = 'ABCDEFGHIJKL1237'.


lv_pos = strlen( lv_serial ).


DO lv_pos TIMES.
  IF sy-index = 2.
    MOVE lv_serial+0(2) TO lv_serial2.
  ELSEIF sy-index = 4.
    MOVE lv_serial+2(2) TO lv_serial3.
  ELSEIF sy-index = 6.
    MOVE lv_serial+4(2) TO lv_serial4.
  ELSEIF sy-index = 8.
    MOVE lv_serial+6(2) TO lv_serial5.
  ELSEIF sy-index = 10.
    MOVE lv_serial+8(2) TO lv_serial6.
  ELSEIF sy-index = 12.
    MOVE lv_serial+10(2) TO lv_serial7.
  ELSEIF sy-index = 14.
    MOVE lv_serial+12(2) TO lv_serial8.
  ELSEIF sy-index = 16.
    MOVE lv_serial+14(2) TO lv_serial9.
  ENDIF.


ENDDO.
CONCATENATE lv_serial2 lv_serial3 lv_serial4 lv_serial5 lv_serial6 lv_serial7 lv_serial8 lv_serial9 INTO lv_serial10 SEPARATED BY '-'.
&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jan 2020 10:37:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108420#M1973390</guid>
      <dc:creator>former_member634045</dc:creator>
      <dc:date>2020-01-10T10:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Write a string separated by Hyphens.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108421#M1973391</link>
      <description>&lt;P&gt;Even if you don't know the size, you can do it with a REGEX but it's not worth the pain for a so simple algorithm.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 10:48:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108421#M1973391</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-01-10T10:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Write a string separated by Hyphens.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108422#M1973392</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt;  - I don't think it is that much of pain if the parts have the same size&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;matcher = cl_abap_matcher=&amp;gt;create( pattern = '([A-Za-z0-9]{2})' text = serial ).

WHILE matcher-&amp;gt;find_next( ).
  INSERT matcher-&amp;gt;get_submatch( 0 ) INTO TABLE tokens.
ENDWHILE.

CONCATENATE LINES OF tokens INTO result SEPARATED BY '-'.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jan 2020 11:27:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108422#M1973392</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-01-10T11:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Write a string separated by Hyphens.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108423#M1973393</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/4022/gabmarian.html"&gt;Gábor Márián&lt;/A&gt; The pain of people who don't know REGEX or REGEX within ABAP &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 11:41:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108423#M1973393</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-01-10T11:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: Write a string separated by Hyphens.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108424#M1973394</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/4022/gabmarian.html"&gt;Gábor Márián&lt;/A&gt; you should post your proposal as an answer &lt;/P&gt;&lt;P&gt;I was searching for REGEX to replace directly, not imagining this solution. Good idea !&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 12:25:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108424#M1973394</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2020-01-10T12:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Write a string separated by Hyphens.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108425#M1973395</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;DATA:gv_string       TYPE string VALUE 'ABCDEFGHIJKLMNOPQR',

     gv_string_final TYPE string,
     lv_mod          TYPE i,
     gv_length       TYPE i,
     gv_offset       TYPE i.

gv_length = strlen( gv_string ).

DO gv_length TIMES.
  CONCATENATE gv_string_final gv_string+gv_offset(1) INTO gv_string_final.

  lv_mod = gv_offset MOD 2.

  IF sy-index = gv_length.  "exit on reaching last caracter
    EXIT.
  ENDIF.

  IF lv_mod = 1.
    CONCATENATE gv_string_final '-' INTO gv_string_final.
  ENDIF.

  gv_offset = gv_offset + 1.
ENDDO.

WRITE:/ 'Input string: ', gv_string .
WRITE:/ 'Result: ', gv_string_final .&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jan 2020 13:33:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-a-string-separated-by-hyphens/m-p/12108425#M1973395</guid>
      <dc:creator>dev_parbutteea</dc:creator>
      <dc:date>2020-01-10T13:33:55Z</dc:date>
    </item>
  </channel>
</rss>

