cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic extract from right

former_member203645
Active Participant
0 Kudos

Hi All,

Please share any function or idea to extract file name from right left.From the below path, File name will change dynamically ( using wait_for_file function to get the file name but it is returning complete path )  and I need to extract only the file name which is before "/" from right.

$GV_FILE_NAME /test/eRW/MainFrame/Acknowledge_Files/Correct_Confirm_1.TXT

Accepted Solutions (1)

Accepted Solutions (1)

former_member187605
Active Contributor
0 Kudos

word_ext( $GV_FILE_NAME, -1, '/');

former_member203645
Active Participant
0 Kudos

Awesome and it worked.

former_member187605
Active Contributor
0 Kudos

What had you expected ?

But this time, I cannot say RTFM, because it's one of those undocumented DS features. The DS Reference Guide says about word_ext(<string>, <word_num, separator(s)>):

<word_num>:

A nonnegative integer specifying the index of the target word in the string. The first word in a string is word number 1. If <word_num> is 0 or greater than the number of words in <string>, then the word function returns a NULL string.

But it works for negative integersn, as well!

former_member187605
Active Contributor
0 Kudos

Correction! The DS Reference Guide does include an example with a neagtive number. And there it says: "A negative word number means count from right to left."

Contracdiction between function definition and example

former_member187605
Active Contributor
0 Kudos


8. Be responsive. Mark the discussion as “answered,” so that other members can find the answers more easily.

Answers (1)

Answers (1)

chethan_lingaraju
Active Participant
0 Kudos
  1. Reverse it
  2. Search location of first occurrence of /
  3. Get sub-string from position zero to that location
  4. Reverse it again
former_member203645
Active Participant
0 Kudos

Can you provide me an example ??

Is this something similar ?? but it is not quite understandable.

https://scn.sap.com/thread/1901457