<?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: Validate String with a pattern in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-string-with-a-pattern/m-p/4206640#M1005336</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT itab.

  IF itab-f3+0(1) CA sy-abcde.
    IF itab-f3+1(1) EQ '-'.
      IF itab-f3+2(3) CO '0123456789'.
*     Valid
      ELSE.
* Invalid
      ENDIF.
    ELSE.
* Invalid
    ENDIF.
  ELSE.
* Invalid.
  ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Jul 2008 07:49:06 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-07-15T07:49:06Z</dc:date>
    <item>
      <title>Validate String with a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-string-with-a-pattern/m-p/4206639#M1005335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can we validate the string with a pattern?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg. Value should always be of the format C-DDD, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where C is a character (A-Z or a-z) and &lt;/P&gt;&lt;P&gt;          D represents a digit(0-9)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Valid forms are A-001, A-987, Z-098 and &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;not valid forms are A-01, 1-A01, 1- 0A0, A-A01, A-0001&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say internal table contains values like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;F1     F2      F3&lt;/P&gt;&lt;P&gt;1     00001  A-001&lt;/P&gt;&lt;P&gt;2     00001  A-A01&lt;/P&gt;&lt;P&gt;3     00001  B-909&lt;/P&gt;&lt;P&gt;4     00001  Z-01&lt;/P&gt;&lt;P&gt;5     00001  k-0001&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Valid records are 1 and 3.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 07:38:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/validate-string-with-a-pattern/m-p/4206639#M1005335</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-15T07:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Validate String with a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-string-with-a-pattern/m-p/4206640#M1005336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT itab.

  IF itab-f3+0(1) CA sy-abcde.
    IF itab-f3+1(1) EQ '-'.
      IF itab-f3+2(3) CO '0123456789'.
*     Valid
      ELSE.
* Invalid
      ENDIF.
    ELSE.
* Invalid
    ENDIF.
  ELSE.
* Invalid.
  ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 07:49:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/validate-string-with-a-pattern/m-p/4206640#M1005336</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-15T07:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Validate String with a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-string-with-a-pattern/m-p/4206641#M1005337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use this logic&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

data: char,
         num type n,
         str(4),
        strn(6).

char = 'A'. " u can take from user as well
num = 1000.
str = num.

concatenate char str into strn." u can also use saperate key word as well

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Prakash Varun&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 08:04:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/validate-string-with-a-pattern/m-p/4206641#M1005337</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-15T08:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: Validate String with a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-string-with-a-pattern/m-p/4206642#M1005338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there any other possible way of coding it, this actually leads to performance issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or say for example if the pattern is C-LOCATION or C-location?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where c can be (A-Z or a-z)...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 08:14:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/validate-string-with-a-pattern/m-p/4206642#M1005338</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-15T08:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Validate String with a pattern</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/validate-string-with-a-pattern/m-p/4206643#M1005339</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 regular expressions for this, e.g.:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  FIND ALL OCCURRENCES OF REGEX '[a-z,A-Z]-[0-9]{3}[ [:blank:] ]'
       IN TABLE t_data
       RESPECTING CASE
       RESULTS t_results.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that in the above example all fields in the table will be checked. If this is not practical for your use you can use a LOOP and FIND on the table field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that line 5 in your example also matches the pattern you have given. If you really do not want to see this as valid you will have to use the pattern: '[A-Z]-[0-9]&lt;SPAN __jive_macro_name="3"&gt;&lt;/SPAN&gt;[ [:blank:] ]'. The addition of [ [:blank:] ] is only needed if your field is longer than the pattern, i.e. 5 characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gert.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: This will also be pretty efficient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Gert Beukema on Jul 15, 2008 10:36 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 08:34:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/validate-string-with-a-pattern/m-p/4206643#M1005339</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-15T08:34:35Z</dc:date>
    </item>
  </channel>
</rss>

