Skip to Content
author's profile photo Former Member
Former Member

Read data between two characters

Hello Experts,

I have the data as follows:

"943/2764//00101/1000/11111/////121/3405\"

The above data is stored in a structure ITAB.

I want to get the characters between the last "/" (forward slash) and the "\" (back slash), that is the value 3405.

Could you let me know how to go about it? Points to be awarded for sure. Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2008 at 05:16 AM

    Hi,

    Try as follows:

    data: begin of itab,

    text(20) type c,

    end of itab.

    str = '943/2764//00101/1000/11111/////121/3405\'.

    SPLIT str AT '/' INTO TABLE itab.

    describe itab lines l_f_lines.

    read itab index l_f_lines.

    len = strlen(itab-text).

    len = len - 1.

    val = itab-text+0(len).

    Write : / val.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2008 at 05:09 AM

    Hi,

    You can do it by do end endo

    use search and split at / and again split / till you wont new one

    finally read the string only the required portin

    Regards

    shiva

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 31, 2008 at 05:11 AM

    hi Prasad

    Assumptions: 3405 will be always 4 characters...

    lv_total = strln (itab-field).

    lv_buff = lv_total - 5.

    lv_final = itab-field+lv_buff(4).

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2008 at 05:40 AM

    Thanks Hiri..the problem is solved.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2008 at 05:46 AM

    Hi Debaprasad,

    try this.

    DATA : test(200) TYPE c,

    len TYPE i,

    result(20) TYPE c,

    flag_done type c.

    test = '943/2764//00101/1000/11111/////121/3405\'.

    condense test.

    DESCRIBE FIELD test LENGTH len IN CHARACTER MODE.

    len = len - 1.

    DO.

    IF test+len(1) = '\'.

    DO.

    len = len - 1.

    If test+len(1) = '/'.

    flag_done = 'X'.

    exit.

    endif.

    IF result IS INITIAL.

    result = test+len(1).

    ELSE.

    CONCATENATE test+len(1)

    result

    INTO result.

    condense result.

    ENDIF.

    ENDDO.

    ENDIF.

    if flag_done = 'X'.

    exit.

    endif.

    len = len - 1.

    ENDDO.

    write result.

    Regards,

    Mohaiyuddin

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.