cancel
Showing results for 
Search instead for 
Did you mean: 

how name file with a word on the file?

Former Member
0 Kudos

Hi experts

I need to name the target file VOLUM_yyyymmdd.txt separated by ,

I have the interfaces and have the interface mapping but I dont now how can i get the string of the field 4th named "fecha" of the source file. I dont now how do I it. The "fecha" field change is different each day.

The field 4th source is yyyymmdd (see image below)

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos


Hi,

         you can try putting this UDF in the message mapping, the field  "fetcha" should be input to the mapping.

 

 
  1. public String TargetFilename(String fetcha,Container container){  
  2.  
  3.   //write your code here  
  4. public String getFileName(String CustomerNumber,Container container){   
  5. DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);   
  6.  
  7. DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");    
  8. String s="VOLUM_"+fetcha+".txt" ;  
  9. conf.put(key, s);   
  10. return " ";   

public String TargetFilename(String fetcha,Container container){      //write your code here  public String getFileName(String CustomerNumber,Container container){  DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");   String s="VOLUM_"+fetcha+".txt" ;  conf.put(key, s);  return " ";  }  

  

Map this UDF to root element  or any dummy field in target XML.

In Receiver CC you need to set these

1. Receiver Comm Channel has ASMA , file name and "fail if ASMA missing" ticked.

2. in receiver communication channel -> File access parameters-> File name scheme -


> put any value say "*". This step is not compulsory.

3. In target directory of receiver CC put the name of the directory where you need the file to be formed.

Hope this solves your problem.

Regards

Anupam

Hi All :

I put the UDF between  fecha-->UDF-->main and I configurated the Comm Channel as you said, but the file isn't created and saw in Runtime Workbench there is a error: The Adapter Message Property 'FileName' was configured as mandatory element, but there is no 'DynamicConfiguration' element in the XI Message header: com.sap.aii.adapter.file.configuration.DynamicConfigurationException

If I put the UDF between main-->UDF-->main only the file is created as VOLUM_.txt.

The "fecha" field is used to "dia_natural" field and would be used to get the string and be used to complete the name of the file .txt

Thanks

anupam_ghosh2
Active Contributor
0 Kudos

Hi ,

           Try this code

public String TargetFilename(String fetcha,Container container){    

  //write your code here  

public String getFileName(String CustomerNumber,Container container){   

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

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

String s="VOLUM_"+fetcha+".txt" ;  

conf.put(key, s);   

return fetcha;   

Map it like this "fetcha" ->UDF-> "dia_natural" .

Lets hope the error resolves.

Regards

Anupam

Former Member
0 Kudos

Excellent ¡¡¡¡

Thanks Anupam

Answers (5)

Answers (5)

anupam_ghosh2
Active Contributor
0 Kudos

Hi,

         you can try putting this UDF in the message mapping, the field  "fetcha" should be input to the mapping.

public String TargetFilename(String fetcha,Container container){

  //write your code here

public String getFileName(String CustomerNumber,Container container){

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

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

String s="VOLUM_"+fetcha+".txt" ;

conf.put(key, s);

return " ";

}

Map this UDF to root element  or any dummy field in target XML.

In Receiver CC you need to set these

1. Receiver Comm Channel has ASMA , file name and "fail if ASMA missing" ticked.

2. in receiver communication channel -> File access parameters-> File name scheme -


> put any value say "*". This step is not compulsory.

3. In target directory of receiver CC put the name of the directory where you need the file to be formed.

Hope this solves your problem.

Regards

Anupam

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Use Dynamic configuration in UDF to write the filename of your requirement.  The below link will give idea about dynamic configuration.

http://www.saptechnical.com/Tips/XI/ASMA/Index.htm

You pass the value of the fecha field name as argument in UDF and use above logic in dynamic configuration.  

Satyagadadas
Active Participant
0 Kudos

Hi,

   Pass this value to target structure and use that field in variable substitution of receiver communication channel.

regards,

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

in order to give the new name for the file (any name) you need to use ASMA = filename

then inside your mapping you can set the file name from the content of the source message

Please have a look at ASMA blogs on SDN to have the ready to use code

Regards,

Michal Krawczyk

Ryan-Crosby
Active Contributor
0 Kudos

Hi Lizet,

Looking at the message mapping I see that you main is 0...unbounded as well as fecha.  How would you designate which element to map to a file name that exists only once?  If you were talking about current date then you could create a UDF that uses Java Calendar (or whichever date you need) and places it into Dynamic Configuration so it can be read on the receiver side.

Regards,

Ryan Crosby

Former Member
0 Kudos

Hi Ryan, thanks

I cant use current date because i only need get the string of the fecha field. In fact is as get anything string of the source structure and put in the name of the target file, but i dont now how

can someone explain the code?

thanks