<?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: ABAP function check string in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134820#M1366021</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;You may use this :-&lt;/P&gt;&lt;P&gt;data len type i.&lt;/P&gt;&lt;P&gt;data str type string .(String to be checked)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; len = strlen( str ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if len = 7.&lt;/P&gt;&lt;P&gt; FIND - IN SECTION OFFSET off OF &lt;/P&gt;&lt;P&gt;       str&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Prakash&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 Sep 2009 06:21:30 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-09-14T06:21:30Z</dc:date>
    <item>
      <title>ABAP function check string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134815#M1366016</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 a help to write ABAP function which get a string as parameter &lt;/P&gt;&lt;P&gt;The fuction returns true only if the string length is 7 &amp;amp; the string contain only one '-'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thx&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Sep 2009 07:50:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134815#M1366016</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-13T07:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP function check string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134816#M1366017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I dont think that there is any function available for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A few lines of code &amp;amp; thats it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:
V_TRUE TYPE FLAG,
V_LEN TYPE I,
V_LINES TYPE I.

CLEAR: V_LEN, V_LINES, V_TRUE.

V_LEN = STRLEN( V_INPUT ). 

SPLIT V_INPUT AT '-' INTO TABLE ITAB.

V_LINES = LINES( ITAB ).

"If true, then V_LEN = 7 &amp;amp; V_LINES = 2
IF V_LEN = 7 AND V_LINES = 2.
V_TRUE = 'X'.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Sep 2009 07:59:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134816#M1366017</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2009-09-13T07:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP function check string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134817#M1366018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thnak you &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ITAB in not defined, please define it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Sep 2009 08:05:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134817#M1366018</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-13T08:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP function check string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134818#M1366019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Qwart&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As i understand your requirement, you need the following, Test the code given bellow and revert me back if any else requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PARAMETERS: string TYPE string.
DATA: ans(1).

PERFORM: check_string USING string ans.

WRITE: ans. " Here it will write T or F ( T for True and F for False )
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  check_string
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;VALUE(STR) text
*      --&amp;gt;FLAG       text
*----------------------------------------------------------------------*
FORM check_string USING value(str) flag.

  DATA: sub_str1 TYPE string,
        sub_str2 TYPE string,
        slen TYPE i,
        sub_slen1(7),
        sub_slen2(7).

  slen = STRLEN( str ).

  IF slen = 7.
    FIND FIRST OCCURRENCE OF '-' IN str.
    IF sy-subrc = 0.
      SPLIT: str AT '-' INTO sub_str1 sub_str2.
      FIND FIRST OCCURRENCE OF '-' IN sub_str2.
      IF sy-subrc = 0.
        flag = 'F'.
      ELSE.
        flag = 'T'.
      ENDIF.
    ELSE.
      flag = 'F'.
    ENDIF.
  ELSE.
    flag = 'F'.
  ENDIF.
ENDFORM.                    "check_string&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Faisal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Sep 2009 09:26:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134818#M1366019</guid>
      <dc:creator>faisalatsap</dc:creator>
      <dc:date>2009-09-13T09:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP function check string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134819#M1366020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;From the below program logic you can create the  FM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****************************************&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data: v_len type i,v_return(1) type c value 'F'.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;parameters: P_string type string.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;v_len = strlen( p_string ).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if len = 7.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;  &lt;STRONG&gt;if p_string CO '-'.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;    &lt;STRONG&gt;v_return = 'T'.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;  &lt;STRONG&gt;endif.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;endif.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;write :  v_return,len.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;********************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Smart Varghese&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2009 06:03:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134819#M1366020</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-14T06:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP function check string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134820#M1366021</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;You may use this :-&lt;/P&gt;&lt;P&gt;data len type i.&lt;/P&gt;&lt;P&gt;data str type string .(String to be checked)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; len = strlen( str ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if len = 7.&lt;/P&gt;&lt;P&gt; FIND - IN SECTION OFFSET off OF &lt;/P&gt;&lt;P&gt;       str&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Prakash&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2009 06:21:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134820#M1366021</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-14T06:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP function check string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134821#M1366022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;data s1 type string value 'asdf-dfgd-234-asd'.
data: d1 type i,l1 type i.
d1 = strlen( s1 ).
DATA : res_tab TYPE MATCH_RESULT_TAB,
       res TYPE MATCH_RESULT.
find ALL OCCURRENCES OF '-' in s1 RESULTS  res_tab .

DESCRIBE TABLE res_tab LINES l1.
WRITE : 'length:', d1, ' occurance:', l1.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2009 07:01:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134821#M1366022</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-14T07:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP function check string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134822#M1366023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

DATA: I_STRING TYPE STRING VALUE '-------'.
DATA: L_STRING TYPE I.
*
L_STRING = STRLEN( I_STRING ).
*
IF L_STRING = 7 AND I_STRING = '-------'.
  WRITE: 'OK'.
ELSE.
  WRITE: / 'ERROR'.
ENDIF.
 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards, Dieter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2009 07:10:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134822#M1366023</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-14T07:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP function check string</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134823#M1366024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;Chk the following code.. it works acc to the requirement..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FUNCTION ZFM.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(W_STRING) TYPE  STRING
*"  EXPORTING
*"     REFERENCE(W_RESULT) TYPE  STRING
*"----------------------------------------------------------------------
data: w_len type i.
w_len = strlen( w_string ).

if w_len eq 7.
do.
  if w_string ca '-'.
    w_result = 'True'.
    replace '-' in w_string with space .
    if sy-index ge 2.
    w_result = 'False'.
    exit.
    endif.
  endif.
  check sy-index gt 2 .
  exit.
enddo.
else.
w_result = 'False'.
endif.

ENDFUNCTION.

&lt;/CODE&gt;&lt;/PRE&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>Mon, 14 Sep 2009 07:26:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-function-check-string/m-p/6134823#M1366024</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-14T07:26:12Z</dc:date>
    </item>
  </channel>
</rss>

