Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Extraction of a particular string from a line of text

Former Member
0 Kudos

Hi Experts,

Can anyone help me in fetching the required string from a line of text which is coming from an internal table.

For Eg: Form routines for view cluster maint. (EI_DD_026)

In the above sentence i need to extract only EI_DD_026.

Let's take another example.

Eg: The link DS_FS_023_MN is available in (Repository).

In the above senetence i need to extract only DS_FS_023_MN.

Only the Hint I have is that text will have DD / FF format.

I tried using Split ,CP but did not get desired results due to Dynamic changes in the text .

Thanks in Advance.

Regards

Ullas

2 REPLIES 2

Former Member
0 Kudos

From the examples you gave, it looks like you might have a underscore in all your required string. Why dont you try splitting and looking for underscore?

naimesh_patel
Active Contributor
0 Kudos

Will this kind of work around help?


TYPES: BEGIN OF TY_DATA,
       TEXT  TYPE CHAR200,
       END   OF TY_DATA.

DATA: IT_DATA TYPE STANDARD TABLE OF TY_DATA,
      IT_SPLIT TYPE STANDARD TABLE OF TY_DATA.


DATA: LA_DATA TYPE TY_DATA,
      LA_SPLIT TYPE TY_DATA.

LA_DATA-TEXT = 'Form routines for view cluster maint. (EI_DD_026)'.
APPEND LA_DATA TO IT_DATA.
CLEAR LA_DATA.


LA_DATA-TEXT = 'The link DS_FS_023_MN is available in (Repository).'.
APPEND LA_DATA TO IT_DATA.
CLEAR LA_DATA.

LOOP AT IT_DATA INTO LA_DATA.
  SPLIT LA_DATA AT SPACE INTO TABLE IT_SPLIT.
  LOOP AT IT_SPLIT INTO LA_SPLIT.
    REPLACE '(' IN LA_SPLIT-TEXT WITH ' '.
    CONDENSE LA_SPLIT-TEXT.
    REPLACE ')' IN LA_SPLIT-TEXT WITH ' '.
    CONDENSE LA_SPLIT-TEXT.

    IF LA_SPLIT-TEXT+2(1) = '_'.
      WRITE: / LA_SPLIT-TEXT.
    ENDIF.
  ENDLOOP.
ENDLOOP.

Regards,

Naimesh Patel