cancel
Showing results for 
Search instead for 
Did you mean: 

Filename based on varying payload elemet.

Former Member
0 Kudos

Hi All,

My file name is dependent on the payload.The file name is not based on a fixed element in the payload but varies with the payload type (although the schema is the same for all).

Variable Substitution will not work as the substitutation itself is not fixed.

I thought of writing a module and change the file name before CallSAPAdapter is invoked.

Basically I am planning to use Adapter Specific Attibute.This way the Dynamic configutaion will be filled and I an provide the value in my module.

Has anyone tried this.

Any other idea on how to manipulate the Filename otherwise without having multiple Receiver defined.

Please note ,the Sender Adapter in this case is IDoc and using UDF (in mapping) to update DYNAMIC_CONFIGURATION using Adapter Specific Atribute may not work.

Thanks in Advance,

Regards,

Bikram

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

If u insist setting fileName in module take a look at this thread.

Regards,

Sudharshan

Former Member
0 Kudos

Hi Sudarshan,

The reason I am looking at setting file name in adapter module is because in mapping ConfigurationObject is null .How do I set the file name without the ConfigurationObject ?

However,as per your comment in the referred thread following code should work.

I will try this but if you have any alternative idea about setting the name in Mapping,I would prefer that.

Thanks and regards,

Bikram

public ModuleData process(ModuleContext moduleContext,

ModuleData md)

throws ModuleException {

Object obj = md.getPrincipalData();

com.sap.aii.af.ra.ms.api.Message msg = (Message) obj;

msg.setMessageProperty("http://sap.com/xi/XI/System/File", "FileName","FileNameModule");

}

Former Member
0 Kudos

Sridhar,

In ur UDF

String nameofFile = "your FileName" ;

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

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

conf.put(key, nameofFile);

return "dummy";

Dont test it in mapping.

Execute the scenario and make sure that u have set the Adapter Specific Attributes for File type in receiver communication channel

Regards,

Sudharshan

Former Member
0 Kudos

Hi Sudharshan,

My problem is solved,thanks for your answers .

Regards,

Bikram

Former Member
0 Kudos

Hello Sudharshan

I m tryin to use your code. But I ve stuck.

In the code line

"DynamicConfiguration conf = (DynamicConfiguration) <b>container</b>.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); "

How do we declare container ? I m gettin error, that variable container is unresolved ?

can you help me with this ?

awaiting your reply.

Regards

Kapil

bhavesh_kantilal
Active Contributor
0 Kudos

Kapil,

Where are you trying to use the Code?

This code should be used in user Defined Functions in your messsage mapping.

All user defained function be default , take the container as one of its input parameters.

Regards

Bhavesh

Former Member
0 Kudos

Hello Bhavesh

I m tryin to use this code in my custom module which i m developin to get the file name from the dynamic configuration.

Regards

Kapil

Former Member
0 Kudos

Hi,

Check this thread

Regards,

Sudharshan

bhavesh_kantilal
Active Contributor
0 Kudos

Kapil,

You cannot use the code above.

To get the filename inside your module code, you can refer to the SAP note : 819761

Regards

Bhavesh

Former Member
0 Kudos

Hello Sudharshan and Bhavesh

I forgot to mention that I m implementing a module for mail adapter.

Regards

Kapil

bhavesh_kantilal
Active Contributor
0 Kudos

Kapil,

What filename are you trying to access?

Is it the mail's adapter attachments or is it that your sender adapter is a file adapter and you wnat to access the file attachment's name?

Regards

Bhavesh

Former Member
0 Kudos

Yes Bhavesh

We are tryin to acces the mail adapter's file name.

Regards

Kapil

bhavesh_kantilal
Active Contributor
0 Kudos

Refer to the mail adapter FAQ on the service marketplace, it provides inputs on the same.

Regards

Bhavesh

Answers (4)

Answers (4)

STALANKI
Active Contributor
0 Kudos

Bikram,

I think the key we will create in DynamicConfigurationKey object and we use put and not get method as you donot have sender file adapter and the technical name is FileName in the reciever adapter and name space remains the same.

Former Member
0 Kudos

I dont think I understood what you mean.Please explain.

This is the code I will use.

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System/File”,

“FileName”);

//set the new filename

conf.put(key, valueNew);

Now if "conf" is null,this will not work.

Regatrds,

Bikram

STALANKI
Active Contributor
0 Kudos

Bhavesh,

We donot require to write the adapter module for that.

https://media.sdn.sap.com/javadocs/NW04/SPS15/pi/com/sap/aii/mapping/api/DynamicConfiguration.html

check that out.

Former Member
0 Kudos

Hi Sravya,

In the example you mentioned, "conf" or the "valueOld" will be null as there is no dynamic configuration defined in the sender adapter (IDoc in my case).

// access dynamic configuration

DynamicConfiguration conf = (DynamicConfiguration) param.get(

StreamTransformationConstants.DYNAMIC_CONFIGURATION);

// read value

String valueOld = conf.get(KEY_FILENAME);

if (valueOld == null) {

throw new StreamTransformationException(

"Filename is missing. ");

}

I tried the following in UDF and "conf" is null.

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

Any other idea ?

How Can I access the DynamicConfiguration in a module ?

Regards,

Bikram

Former Member
0 Kudos

Thanks Sravya,

You indicated me to the right direction.

I was making some mistake in my code.

Now its is all fine.

Regards,

Bikram

STALANKI
Active Contributor
0 Kudos

You can do that.See the java test mapping closely.you can use and put that

https://media.sdn.sap.com/javadocs/NW04/SPS15/pi/com/sap/aii/mapping/api/DynamicConfiguration.html.

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Have you seen in this blog?

/people/daniel.graversen/blog/2006/10/05/dynamic-configuration-in-adapter-modules

It discusses Access of adapter specific attributes in a module.

Regards

Bhavesh