cancel
Showing results for 
Search instead for 
Did you mean: 

Rename FileName @SFTP Receiver Adapter

former_member194011
Participant
0 Kudos

My Scenario: Proxy-to-SFTP(Flat File+PGP Encryp)

We need to create target file with extension .txt.pgp with PI Timestamp.

Expected Target FileName = <abc>_<YYYYMMDDHHMMSS>.txt.pgp

Now challenge is how to change PI timestamp format from YYYYMMDD-HHMMSS-SSS to YYYYMMDDHHMMSS

SFTP Receiver adapter is adding Timestamp between .txt.pgp (i.e <abc>.txt<YYYYMMDD-HHMMSS-SSS>.pgp)

Accepted Solutions (0)

Answers (7)

Answers (7)

former_member190293
Active Contributor
0 Kudos

Hi Kiran!

No, I didn't do that and not going to.

You should understand how "OS command" functionality works: PI runs script on its OS and on its file system and that script should perform all necessary actions. So, if your file is placed on FTP/SFTP server - that means that your script have to establish connection to that server and perform all the actions using ftp client functionality.

I guess you should use other functionality like UDF in message mapping to compose required file name.

Regards, Evgeniy.

former_member190293
Active Contributor
0 Kudos

Hi Kiran!

Did you implement the logic to connect to SFTP server and rename the file on that server in your script?

Regards, Evgeniy.

former_member194011
Participant
0 Kudos

Hi Evgeniy,

Oh Not sure about that could you please help me with that ?

My Code:-

@echo off setlocal enabledelayedexpansion for %%a in (employee_p0086452t5ad_*-*.txt) do ( set "fname=%%~na" set "fname=!fname:~0,-3!%%~xa" ren "%%a" "!fname:-=!.pgp" )

former_member194011
Participant
0 Kudos

Hi All,

I've wrote a Batch Script file and placed .bat file in SAP Server.(My SAP Server is on Windows Env)

In SFTP Receiver adapter "OS Command After Message Processing" is executing. but it seems, Batch Script file not executing.

My Batch Script is working fine when I execute in my local machine.

Followed below blog.

https://wiki.scn.sap.com/wiki/display/XI/SAP+XI+File+Adapter+OS+Command+Line+Feature

former_member306381
Participant
0 Kudos

Hi Kiran,

it should not be like that i have used the same in on of my requirements i.e IDOC-File scenario it worked as expected.

Regards,

Bhaskar

former_member306381
Participant
0 Kudos

Hello Kiran,

yes it is possible -write down a simple dynamic configuration udf below and do not pass any attributes or variables in it then it works.

String filename = new String("");
DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
filename = "ABC" + "_" + ABCD + "_" + EFGH + "-"+".pgptxt";
conf1.put(key1,filename);
return filename;

Please let me know if its helpful..

Regards,

Bhaskar

former_member194011
Participant
0 Kudos

Hi Bhaskar,

That doesn't work I've tried it. because Dynamic Config will always check filename from source.

apu_das2
Active Contributor
0 Kudos

Hi Evgeniy,

Yes you are correct. I have missed it.

@Kiran,

You can achieve this writing an UDF in ESR I guess. Use Simple date formatter to change the date format.

former_member194011
Participant
0 Kudos

Hi Apu,

That doesn't work since sender is Proxy(no file name from source) and no Dynamic Configurations possible when we don't have filename from source

apu_das2
Active Contributor
0 Kudos

When you were using CamelFileName, did you use below for date -

${date:now:YYYYMMDDHHMMSS}

If you are not using current timestamp, then you can use groovy script to change the date format and store the same in a header field and user the header field value at the time of file name construction in CamelFileName.

former_member190293
Active Contributor

Hi Apu!

Are you sure that Cloud Platform Integration is used?

According to question tags, Kiran is talking about PI/PO.

Regards, Evgeniy.

former_member194011
Participant
0 Kudos

We are doing Proxy to SFTP scenario in SAP PI/PO On-premises

We are adding time stamp in receiver SFTP Adapter