cancel
Showing results for 
Search instead for 
Did you mean: 

Change in time stamp format in receiver file name

Former Member
0 Kudos

Hi,

We have a scenario as AS2 - PI - FTP Server (AS/400). We want target file name as BMMDDHHSS where B is constant and

MM (month e.g., 01), DD (day e.g., 12), HH (hour e.g.,11), SS (seconds e.g., 12). Is there standard way of doing this, just by changing some configuration in receiver file adpter?

Please let me know, how could we do this using PI. If script is optional, keeping as back-up only.

How come, naming dynamic receiver file names are so difficult in PI. I have been trying to get the answers for our another requirement like to name receiver file as C1.YYMMDD.C2 in a file pass through scenario for more than a month.

It is just file through scenarios, so we can't use variable substitution as we are not going to read content/payload of file

Thanks in advance,

- Riya Patil

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

>

> How come, naming dynamic receiver file names are so difficult in PI. I have been trying to get the answers for our another requirement like to name receiver file as C1.YYMMDD.C2 in a file pass through scenario for more than a month.

>

> It is just file through scenarios, so we can't use variable substitution as we are not going to read content/payload of file

l

actually naming them is much flexible in PI

all you need is to code it the right way. Use the snippet provided in the earlier post and the blog i have mentioned to help you /people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name

Former Member
0 Kudos

Hi Shabarish

Thanks for your reply. I have trying to make this UDF work since almost a month with no luck. Can you please check where am I doing wrong?

-


DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

String SourceFileName = "C1." + a + ".C2";

conf.put(key, SourceFileName);

return " ";

-


In the above code, I am passing date as "a". And mapping CurrentDate (formatted) --> UDF --> Target root node.

I am getting the following error in SXMB_MONI:

<SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>

<SAP:P1>com/sap/xi/tf/_MM_Lockbox_Filename_</SAP:P1>

<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>

<SAP:P3>Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:P3>

<SAP:Stack>com.sap.aii.utilxi.misc.api.BaseRuntimeException thrown during application mapping com/sap/xi/tf/_MM_Lockbox_Filename_: Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:Stack>

Your help would be much appreciated.

Thanks,

Riya Patil

Former Member
0 Kudos

Hi Riya,

You are not returning target file name in your UDF.

===========================================================================================

//write your code here

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

String ourSourceFileName = "C1." + a + ".C2";

String ourTargetFileName = ourSourceFileName;

conf.put(key, ourTargetFileName);

return ourTargetFileName;

===========================================================================================

Also I have used dynamic configuration in IDOC to File scenario. In Sender IDOC scenario, we dont have sender communication channel and hence we can not set any ASMA parameters. Still scenario works perfctly fine. hence this should work for AS2 as well. However please check and confirm.

Regards,

Gouri

Former Member
0 Kudos

Hi Gouri,

What was your source n target structure? In my case, it is just a file through scenario,

1) sender AS2 adapter received the file (picks) n sends it to IS

2) Mapping gets executed (this is a mapping with the same dummy source n target structures with only one root node), this mapping is not related to the actual file to be sent.

3) In receiver file adapter, turn on ASMA with File name

Did you try this to work? I am testing with sender file adapter without ASMA and receiver file adapter with ASMA and UDF.

Is it possible to configure quick test scenario and see if it works or not?? Please give me more idea of how guys done with Idoc-file scenario?

Thanks,

Riya

Former Member
0 Kudos

Hi Riya,

Please close multiple threads for same issue.

Please do following steps.

Define Source Data Type as follows.

DataType

->Row

---> Data

Define message type corresponding to this.

Now in mapping use same message type for source and target. Constant to Data Type, Map Row --> UDF --> Row and Data to Data directly.

(Please use UDF the one which I gave)

In Sender and receiver channel, again use FCC as follows.

Row.fieldNames = Data

Row.fieldSeparator = 'nl'

Row.ProcessFieldNames = fromConfiguration

Row.LastFieldsOptional = YES

ignoreRecordsetName = TRUE

Please activate ASMA parameters in receiver channel. Please create other objects like Message Interface, Sender Agreement, Receiver Agreement, Interface determination, Receiver Determination as per these details.

This should solve your problem.

_Gouri

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Riya,

Please try this solution

Please close multiple threads for same issue.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

use the below code for the date format

Date date = new Date(); // get the current date

DateFormat df = new SimpleDateFormat(dateFmt); // set the format

String dfmt = df.format(date);

after this use concat

String fmt = "B" + dfmt;

and use code for setting file name using dynamic configuration there pass this string...

HTH

Rajesh