Skip to Content
author's profile photo Former Member
Former Member

Hi Experts,

can any one suggest me how to do DYNAMIC Configuration,here is my requirement for example,

i'm getting one file i.e. 12345_7899.txt but i need to get the target file name as 12345.txt and if i get the file 4567_2345.txt but target is expecting 4567.txt only like that i need to get the first part only(Quote_File)i.e. Quote only.

Please can any one suggest the exact UDF for this case.

Thanks,

Prasad.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Mar 31, 2015 at 11:31 PM

    After reading the filename just take the substring from starting position to index of "_".

    If you always have "_" in your filename then something like below.

    SourceFileName = SourceFileName.substring(0,SourceFileName.indexOf("_"));

    conf.put(key,SourceFileName)


    Just search for dynamic filename UDF, you'll find numerous threads.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 31, 2015 at 11:44 PM

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

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

    String FileName = conf.get(key);

    String newFileName = FileName.substring (0,5) ;

    conf.put(key,newFileName);

    return newFileName;

    You can return anything it needs to maintain your UDF syntax. Does not require from Logic point of view.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2015 at 05:25 AM

    Nabendu, can u please give me the java mapping program for dynamic file name for bypass scenario (file 2 jdbc ) with above file name schema.i.e.

    Logic for my Requirement is:

    String SourceFileName = conf.get(key);

    SourceFileName = SourceFileName.substring(0,SourceFileName.indexOf("_"));

    conf.put(key,SourceFileName);

    return SourceFileName;

    ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

    for example: Like this,please give me the valid code.

    package com.javaMapping;

    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_JavaMapping extends AbstractTransformation

    {

    public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput)

    throws StreamTransformationException

    {

    try

    {

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

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

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

    // a) Set Output File name

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

    String SourceFileName = conf.get(key);

    SourceFileName = SourceFileName.substring(0,SourceFileName.indexOf("_"));

    1. conf.put(key,SourceFileName);

    return SourceFileName;

    // b) Just copy Input file content to Output file content

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

    inputstream.read(b);

    outputstream.write(b);

    } catch (Exception exception)

    {

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

    throw new StreamTransformationException(exception.toString());

    }

    }

    }


    Thanks,

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.