Extract File name (Last 5 digit only) and upload it in SAP

Hello Team,

Urgent support

I am trying to set up a flow which will read all the files name (only the last 5 digit) present in folder and open SAP and write it in a particular T-code and after that, particular file needs to be attached in SAP and then send an email as confirmation.

please support, I am stuck on it.

@lakshman

@Rahulsinha

Could you please show me some sample filename. So that I can check and help you.

@lakshman thank you for your quick response.

File type will be of mail (.msg)
Name of the file will be like:

  1. tyre12345
  2. mrf98765
  3. st45287

Here I need only the last 5 digit (only numbers basically and the I need to go in one Tcode in SAP and give that 5 digit and upload the file.

example: I have got 12345 – get in sap Tocde given the number 12345 (enter) and in that I have to attach the file which belongs to this number so in this cae I have to attach tyre12345

@Rahulsinha, You can use Substring or regx to get Number from file name.

Cheers,

Hi @Bhavik_Solanki

I thought to do substring first and have all the number in an excel sheet and the use regex to attache the file, I mean lets say:

  1. identity12345 >> first I thought to extract all the digit of the file existing in the folder and the one by one it will go in SAP, I used some t-code and entered 12345>> and the file which is available in the folder with this number (now in case it is identity12345) should get attached, not any other file, so here I believe we need to have regex.

not sure if this will work, and it will really be great if you can share your thoughts or workflow (if you can)

@Rahulsinha

You can use below expression to get last 5 digits.

image

And also if you want to extract only numbers from filename then you can use Regular expression also.

                              \d or [0-9]

Thanks a lot @lakshman.

can you advise on below:

I thought to do substring first and have all the number in an excel sheet and the use regex to attache the file, I mean lets say:

  1. identity12345 >> first I thought to extract all the digit of the file existing in the folder and the one by one it will go in SAP, I used some t-code and entered 12345>> and the file which is available in the folder with this number (now in case it is identity12345) should get attached, not any other file, so here I believe we need to have regex.

not sure if this will work, and it will really be great if you can share your thoughts or workflow (if you can)

How can we proceed on this(any workflow)

@Rahulsinha, May be you can try this:

  1. Get list of files
  2. Loop through each files e.g. fileName in Files
  3. Get the number in seperate variable e.g. number
  4. Use number to go to specific entry in SAP
  5. Since you already have fileName you can use it to attach.

I think this logic should work with little twist as needed in your case :slight_smile:

Cheers

1 Like

@Bhavik_Solanki :slight_smile: :slight_smile:
if you have any process flow similar to this, can you please share, it will help me a lot

@Rahulsinha, I love to do so but at this moment I can’t. Sorry for that.

Hi Rahul,
What Bhavik has recommended is the right way. I don’t think you need any template, go ahead try and do it.

Thanks
Minal

@MinalGupta thank you,
can you please let me know how I can get the last 5 digit of the file name and how I can store it in Excel.

As of now when i am running I am also getting the extension added as (.msg), how it can be removed, and then how it can be written in an excel

1 substring , then use’†