cancel
Showing results for 
Search instead for 
Did you mean: 

instead of file name need time stamp in reciever adapter

Former Member
0 Kudos

Hi Frndz,

I have scenario where i am getting Flat file from source system.I need to read the file and process to target directory.

No IR is in place.(Just pick and drop)

I need to modify file name as ccyymmddhhmmss format and ignore the actual file name.

How we can achieve this using reciver file channel.??

Regards,

Naren

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Naren,

If you are PI system is unix/linux system then you can use the below OS command in your receiver file adapter in Run Operating System Command After message processing. It will replace your file name to the current time stamp.

mv %f `date +'%Y%m%d%H%M%S'` or mv %F `date +'%Y%m%d%H%M%S'`

Regards,

Stephen Rouvier

Former Member
0 Kudos

Hi Stephen,

yes i am using unix Os.and tried giving above commands and tested it is giving filename with current date time stamp.whats needs to be do if i want ignore the file name.

Regards,

Narendra

Former Member
0 Kudos

Hi Naren,

I am not sure why file name is coming with time stamp. As per the command only time stamp should come as file name. 'mv' command in unix will actually rename the file name.

Regards,

Stephen Rouvier

baskar_gopalakrishnan2
Active Contributor
0 Kudos

IMO, if you generate all the filenames with timestamp,  it is possible that some files could be generated with same timestamp period. To avoid duplicates, we use filename + timestamp. I know that your timestamp format is different from the standard file adapter option Add timestamp yyyyMMdd-HHmmss-SSS. If you are flexible to use the above use this with some prefix and later using OS script you can remove the prefix.   You don't use ESR for this scenario. So might need to go with OS level script.

Former Member
0 Kudos

Hi Gopal/Raja

I heard that os script is bit easier to achieve this.But i dont have an idea on scripting Can you suggest me the steps how to aproch for that.

Former Member
0 Kudos

Hi Adarsh,

I tried to do with ur code giving some error..Where can i find this below calsses.

com.sap.aii.mapping.api.TransformationInput

RMaii_map_api.jar
com.sap.aii.mapping.api.AbstractTransformation

Forgot to mention i am working in PI7.0.

Please suggest...

Regards,

Narendra

Former Member
0 Kudos

Hi Frnds,

Still i am stuck up with the issue....now i am creating IR objects and thinking to go with dynamic configuration

now i have created IR objects:

Created DT with one Field considering each line as string and given max lenght is 500.i confirmed from the business that max lenght will be 300.

Here Configured CC with Content conversion and channel is picking perfectly.When it comes mapping it is throwing Empty data to target structure.

it is one to one mapping still facing the problem.Please suggest.

Bhargavakrishna
Active Contributor
0 Kudos

Hi Narendra,

something is missing in mapping..

can you past your mapping screen shot?

Former Member
0 Kudos

Hi Bhargava,

It is just 1 to 1 mapping.....pls check the screenshot

rajasekhar_reddy14
Active Contributor
0 Kudos

google it you will find many links,very easy

Bhargavakrishna
Active Contributor
0 Kudos

do this. and see..

Map the MT_outboundextract_out with MT_outboundextract_IN it should work..

Regards

Bhargava krishna

former_member184789
Active Contributor
0 Kudos

The link for the jar is discussed here:

http://scn.sap.com/message/7407872

Former Member
0 Kudos

Hi Bhargava,

no i mapped and tested that yesterday only it didn't work.....

May be flat file is not able covert in to xml ?Actually i tried giving manually in test mode of MM,it worked.because it is 1 to 1 mapping only.

Please suggest....

Bhargavakrishna
Active Contributor
0 Kudos

Hi Narendra,

for this requirement you can use Add time stamp option to generate the file with the format yyyyMMdd-HHmmss-SSS.

or you can go for dynamic file name or variable substitution or ASMA or use OS command.

go through the below link to understand better..

http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=272171407

former_member184789
Active Contributor
0 Kudos

Can you try if below code works:

package com.sap.pi.java.mapping;

import java.io.InputStream;

import java.io.OutputStream;

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Map;

import com.sap.aii.mapping.api.AbstractTransformation;

import com.sap.aii.mapping.api.DynamicConfiguration;

import com.sap.aii.mapping.api.DynamicConfigurationKey;

import com.sap.aii.mapping.api.StreamTransformationConstants;

import com.sap.aii.mapping.api.StreamTransformationException;

import com.sap.aii.mapping.api.TransformationInput;

import com.sap.aii.mapping.api.TransformationOutput;

public class DynamicFileName extends AbstractTransformation{

     public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException

     {

         String oldFilename = "";

         String newFilename = "";

      try

      {

           InputStream inputstream = transformationInput.getInputPayload().getInputStream();

           OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();

           Map mapParameters = (Map) transformationInput.getInputHeader().getAll();

           mapParameters.put(DynamicConfigurationKey.create("http://sap.com/xi/XI/Dynamic",StreamTransformationConstants.DYNAMIC_CONFIGURATION), "");

           DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

          

          

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

         

           DateFormat dateFormat = new SimpleDateFormat("YYYYMMDD");

          

           conf.put(key, dateFormat);

           byte[] b = new byte[inputstream.available()];

           inputstream.read(b);

           outputstream.write(b);

      }

      catch (Exception exception)

      {

       getTrace().addDebugMessage(exception.getMessage());

       throw new StreamTransformationException(exception.toString());

      }

}

}

You may change the format as you wish. You can also take help from:

https://wiki.sdn.sap.com/wiki/display/XI/Sample+JAVA+Mapping+code+using+PI+7.1+API

http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

Former Member
0 Kudos

You can write Java mapping where you read the whole input messages as steam along with that you can set the ASMA property - file name to the output steam.

Regards,

Ashish

Former Member
0 Kudos

Hi Ashish,

We are not creating any objects in IR.How i can use java mapping .pls let me know

Regards,

Narendra

rajasekhar_reddy14
Active Contributor
0 Kudos

I would prefer OS script for this requirement.

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

>>>>How we can achieve this using reciver file channel.??

custom adapter module would be one way - just setting the ASMA for filename to this format ccyymmddhhmmss

Regards,

Michal Krawczyk

Former Member
0 Kudos

Hi Michal,

Can you suggest how i can use custom module here.