parameters : p_locpth type RGGRAP-FILENAME. " Parameter where user input the full path
    DATA : lv_w_string TYPE string,
                  lv_string TYPE rlgrap-filename.

    DATA : lv_i TYPE i,
                  lv_j TYPE i.

    lv_string   = p_locpth.
    lv_w_string = lv_string.

    DO.
      SEARCH lv_w_string FOR '\'.
      IF sy-subrc EQ 0.
        lv_i = sy-fdpos + 1.  " sy-fdpos gives the location of the character you are searching and it *starts with 0
        lv_j = lv_i + lv_j.
        lv_w_string = lv_w_string+lv_i.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.

    lv_dir = lv_string+0(lv_j).

write : / lv_dir.


Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP MM SD Consultant