cancel
Showing results for 
Search instead for 
Did you mean: 

Reciever File name Scheme

former_member210677
Participant
0 Kudos
1,047

Hi Team,

We have a requierment for File receiver to create a file with the name SA2345_date_time.txt.

Could anyone please help me how to define it in receiver file adapter.

Appreciate your quick response.

thanks & regards,

Ranganath.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member210677
Participant
0 Kudos

thanks for the answer

Harish
Active Contributor
0 Kudos

Hi Ranganath,

If you need the file name with Fix prefix and date and time stamp, you can use the add time stamp option in receiver comm. channel.

Regards,

Harish

former_member854360
Active Contributor
0 Kudos

Hi ,

You can do dynamic configuration to achive this. Or you can select Add timestamp in receiver file adapter.

Please see this.

Define Processing Parameters
       7.      Select the Processing tab page.

       8.      Select the File Construction Mode.

u25CB       Create 

The file is created. The document received last is saved in each case.

If you want the created file to be overwritten, set the Overwrite Existing File indicator. If you do not set the indicator, processing is stopped until the created file is processed. 

u25CB       Append

The file is written when the inbound documents are appended.

u25CB       Add Time Stamp

A new file is created for each document. A time stamp with the format yyyyMMdd-HHmmss-SSS is added to the file name. The time stamp is added as the last part of the name before the extension.

This mode guarantees that no file is overwritten. In this way, files that originate from the same adapter configuration can be sorted.

In Mapping also you can do dynamic configuration.

UDF

public String setFileName(Container container) throws StreamTransformationException{
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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



String FileName=SA2345+"_"+getDate()+"_"+getTime();

conf.put(key,FileName);

return FileName;

You need to use this UDF in root node mapping.

Dont forget to check Use Adapter specific message attribute in receiver file adapter.

former_member210677
Participant
0 Kudos

HI Debashish,

Thanks for your prompt reply.

Is there any option in achieving the requirement SA764_date_time.txt through variable declaration. AS i have bit low knowledge in using udf.

Thanks & regards,

Ranganath.

former_member854360
Active Contributor
0 Kudos

Hi ranga,

Creting UDF is Very easy thing.

You can use the same code as i have posted.

If you use addtime stamp then timestamp will be added as prefix of the file name.

Your FileName: SA764_.txt

After ADD time stamp: 20110210-023047-618SA764_.txt

So For your particular filename pattern you need to use UDF.

give it a try .........its damm easy.

former_member210677
Participant
0 Kudos

Okay,

Could you please explain how to add this in root node level

my root node is defined as below

serner---removecontext--pgispr_umc

former_member854360
Active Contributor
0 Kudos

Okay,

>

> Could you please explain how to add this in root node level

>

>

> my root node is defined as below

>

> serner---removecontext--pgispr_umc

serner---removecontext--pgispr_umc

You can map it to the parent node(Top most node in graphical editor)

Constant---UDF(SetfileName)---TopMostNODE

former_member210677
Participant
0 Kudos

Hi Debashish,

the root node for my mapping is pgispr_umc.

so i'll do the mapping as per u r suggestion.

Nextly can you please check the below udf which am going to use in my mapping. let me know if i need to modify anything else.

public String setFileName(String ,Container container){

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

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://amat.com/ASNOutBound/SAPECC_to_VendorFTP","FileName");

String FileName=SA84149126"_"getDate()"_"getTime();

conf.put(key,FileName);

return FileName;

Thanks a lot for your prompt reply.

thanks & regards,

Ranganath.

former_member854360
Active Contributor
0 Kudos

Hi Ranga,

If you want add underscore between Date and time then you need to write the line like this:

String FileName=SA84149126+"_"+getDate()+"_"+getTime();

Otherwise you can write

String FileName=SA84149126+getDate()+getTime();

former_member210677
Participant
0 Kudos

Hi Debasish,

I was getting the blow error while using the above udf.

Could you please let me know where did i go wrong.

Source code has syntax error: /usr/sap/D03/DVEBMGS03/j2ee/cluster/server0/./temp/classpath_resolver/Mapdab9a164ac5711e0ab6d00000202eeda/source/com/sap/xi/tf/_MM_SAPECC_DELVRY03_To_AMTPostGoodsSPR_UMC_FILE_.java:332: <identifier> expected public String setFileName$(String ,Container container){ ^ /usr/sap/D03/DVEBMGS03/j2ee/cluster/server0/./temp/classpath_resolver/Mapdab9a164ac5711e0ab6d00000202eeda/source/com/sap/xi/tf/_MM_SAPECC_DELVRY03_To_AMTPostGoodsSPR_UMC_FILE_.java:414: ')' expected } ^ 2 errors

thanks and regards,

Ranganath.

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Dasari,

the UDF code will return file name SA84149126timestamp, but if you want "-" after SA84149126 then change below statement

String FileName=SA84149126"-"""getDate()""+getTime();

Regards,

Raj

former_member210677
Participant
0 Kudos

HI Debashish,

I did place the underscore as per your suggestion only

String FileName=SA84149126"_"getDate()"_"getTime();

there was some typo error when copied to the blog.

thanks

Ranganath.

former_member854360
Active Contributor
0 Kudos

And also

Also in below line you need to use the namespace http://sap.com/xi/XI/System/File instead of your own namespace.

Its a standard namespace which related to the File adapter.

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

former_member210677
Participant
0 Kudos

Hi Raj,

I need " _" in the place of "-"

thanks for your response.

regards,

Ranganath.

rajasekhar_reddy14
Active Contributor
0 Kudos

then add underscore in place of "-" and test interface end to end then only you will see result of Dynaic conf UDF.

former_member854360
Active Contributor
0 Kudos

Hi Ranga,

For testing Dynamic config you need to run the interface end to end.

In test tab you cant test dynamic config.

also Check the ASMA properties in receiver file adapter.

And Change namespace to default one in UDF as i mentioned in earlier reply

former_member210677
Participant
0 Kudos

Hi Debashish,

Did follow all your suggestions.

and placed the udf in rootnode.

I did get the below error when testing. Could you please help me in troubleshooting.

Appreciate your extended help in this.

Thanks & regards,

Ranganath.

former_member854360
Active Contributor
0 Kudos

Hi Ranga,

Please post the error message. i will try to help you.

regards,

Debashish

former_member210677
Participant
0 Kudos

HI Debashish,

sorry, below is the issue.

RuntimeException in Message-Mapping transformation: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._MM_SAPECC_DELVRY03_To_AMTPostGoodsSPR_UMC_FILE_ method setFileName$[, com.sap.aii.mappingtool.tf3.rt.Context@3568552d]

while checking the queue on the udf and

RuntimeException in Message-Mapping transformation: Cannot cast 428-L273 to boolean

got the above issue while testing it with test data.

thanks

ranganath.

former_member854360
Active Contributor
0 Kudos

Hi Ranga,

RuntimeException in Message-Mapping transformation: Exception:http://java.lang.NullPointerException in class com.sap.xi.tf._MM_SAPECC_DELVRY03_To_AMTPostGoodsSPR_UMC_FILE_ method setFileName$, com.sap.aii.mappingtool.tf3.rt.Context@3568552d

You cant test dynamic configuration using Message mapping Queue.

You need to run the scenario end to end

RuntimeException in Message-Mapping transformation: Cannot cast 428-L273 to boolean

It is some mapping error not related to Dynamic configuration.

please check al;l the boolean function(IF-ELSE) used in mapping.