Skip to Content

How to add timestamp in receiver channel in the below format?

Hi All,

I have a ECC to FTP pass through scenario i.e. no ESR objects.

ECC will send FILE.DAT. After adding timestamp it should look like FILE_DDMMYYYY.DAT. Using Add Time Stamp it will add time stamp but not in the desired format.

How to achieve this?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • Apr 02, 2013 at 10:20 AM

    Hi Shaibayan,

    AS you don't using ESR object so it is difficult to require file name with time stamp with dynamic configuration.

    but you can go for RUN OS command and use the rename command after message processing and try to achieve this using OS command.

    if you want to go for dynamic configuration then check blow blog that may help you.

    http://scn.sap.com/community/pi-and-soa-middleware/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name

    Regards

    Gagan

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 02, 2013 at 10:25 AM

    Hi Shaibayan,

    They is a Similar thread like this, you can check here,

    https://scn.sap.com/thread/192751

    Thanks,

    Seshu.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 02, 2013 at 10:29 AM

    Hi Shaibayan,

    Yes, You can achieve by using Dynamic configuration UDF and well Adapter specific message attributes. Also please find the below step by step documents:

    http://scn.sap.com/thread/1389680

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

    " saptechnical "

    Thanks,

    Maruthi

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 02, 2013 at 12:35 PM

    Overall you have three possibilities..

    > Create dummy ESR objects and use UDF for Dynamic Configuration

    > Develope Adapter Module with your specific requirement

    > RUN OS Command

    As you are using FTP at receiver end, use of OS Command will be easiest way to achieve your scenario.

    Assosiated threads already provided in above replies.

    Hope it helps.!

    Regards,

    Sunil

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 02, 2013 at 02:55 PM

    Hi,

    If you wish to go for a Java mapping, then below code may be useful:

    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);

    Date obj1 = new Date();

    SimpleDateFormat formatter = new SimpleDateFormat ("DDMMYYYY");

    String dateStr = formatter.format(obj1);

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

    oldFilename = conf.get(key);

    oldFilename = oldFilename+"_"+dateStr;

    conf.put(key, newFilename);

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

    inputstream.read(b);

    outputstream.write(b);

    }

    catch (Exception exception)

    {

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

    throw new StreamTransformationException(exception.toString());

    }

    }

    }

    Also go through:

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

    http://wiki.sdn.sap.com/wiki/display/Snippets/Dynamic+file+name+in+a+File+to+File+pass+through+scenario

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 02, 2013 at 04:02 PM

    The best option for pass through scenario is to create dummy ESR objects and use UDF to name the file name dynamically, as sunil mentioned.

    With this option you are creating only one valid ESR object, other objects shall be dummy ones.

    Thanks,

    Pranav

    Add comment
    10|10000 characters needed characters exceeded