cancel
Showing results for 
Search instead for 
Did you mean: 

Get dynamic filename in a Java Mapping (NOT UDF)

michael_buchli
Participant
0 Kudos

Hi,

we are using a Java Mapping step in XI (not UDF). We need to have access to the filename. In the File Adapter we set the message attributes and can see the filename value in the SXMB_MONI.

We use the following code fragment to have access to the filename:

Container container = new Context(new FunctionWrapper(0));

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

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

String sourceFileName = conf.get(key);

This doesn't work. We think the declaration of the container class is wrong. Does anybody have some information about using the dynamic attributes in Java Mappings?

Thanks in advance

Michael

Accepted Solutions (1)

Accepted Solutions (1)

former_member181985
Active Contributor
0 Kudos
import com.sap.aii.mapping.api.*;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

public class JavaProgram
    implements StreamTransformation
{

    public JavaProgram()
    {
    }

    public void setParameter(Map map)
    {
        param = map;
        if(param == null)
            param = new HashMap();
    }

    public void execute(InputStream inputstream, OutputStream outputstream)
    {

        try
        {
            DynamicConfiguration dynamicconfiguration = (DynamicConfiguration)param.get("DynamicConfiguration");
            DynamicConfigurationKey dynamicconfigurationkey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
            String s = dynamicconfiguration.get(dynamicconfigurationkey);

	    //Your logic

        }
        catch(Throwable throwable)
        {
            throwable.printStackTrace();
        }
    }

    private Map param;
}

Answers (2)

Answers (2)

michael_buchli
Participant
0 Kudos

Hi Praveen,

thanks a lot. Your solution solved our problem.

Where can I find information about this kind of stuff (Java Mapping ...)?

Cheers

Michael

former_member181985
Active Contributor
0 Kudos

Check Prateek's reply.

prateek
Active Contributor
0 Kudos