Application Development and Automation 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: 
Read only

SHIFT statement

Former Member
0 Likes
447

Hi,

I have a string value like this. /usr/sap/temp/test.txt .

I want the text before the last slash / .

I mean, I want /usr/sap/temp into one variable.

There can be any number of slash / symbols in the main text. But, I need only the text before the last slash /. I think, we have to use SHIFT statement to do this. But, I am not able to get it. Can someone help me on the same. it is quite urgent. Please share your thoughts.

Thanks & Regards,

Paddu.

Edited by: Paddu K on Feb 13, 2008 7:45 PM

3 REPLIES 3
Read only

Lakshmant1
Active Contributor
0 Likes
424

Hi,

Check FM SO_SPLIT_FILE_AND_PATH

Thanks

Lakshman

Read only

Former Member
0 Likes
424

Try using SPLIT statement.

Read only

Former Member
0 Likes
424

Hi,

Try this one,It will work

DO.
        FIND '\' IN SECTION OFFSET l_offset OF p_file MATCH OFFSET l_off
                                                      MATCH LENGTH l_length .
        IF sy-subrc EQ 0.
          l_offset = l_off + l_length .
        ELSE.
          p_file = p_file(l_offset).
          EXIT.
        ENDIF.
      ENDDO.

in the above code p_file is the file path.

Thanks,

Balaji.