cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Exception during Dynamic file configuration

Former Member
0 Kudos

Hello,

I have to configure the file adapter such that the file name is configured dynamically.

I wrote a UDF which gives the following error.

<SAP:Stack>com.sap.aii.utilxi.misc.api.BaseRuntimeException thrown during application mapping com/sap/xi/tf/_GSFt_AccountReconciliation_Format_: RuntimeException in Message-Mapping transformatio</SAP:Stack>

<SAP:Retry>M</SAP:Retry>

</SAP:Error>

The code is :

DynamicConfiguration conf = (DynamicConfiguration)

container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String FileName = conf.get(key);

String newFN = FileName.substring (11,15) ;

String FN = "<abc>+ newFN + "_" + ".dat";

conf.put(key,FN);

return FN;

Am I missing something here?

I have also specified the variable substitution in Receiver Channel.

Kindly help me out ppl.

Regards,

Sanjay

Accepted Solutions (0)

Answers (7)

Answers (7)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Modify code as below...

String FN="";

try{

DynamicConfiguration conf = (DynamicConfiguration)

container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String FileName = conf.get(key);

if(FileName != null && FileName !=""){

String newFN = FileName.substring (11,15) ; //make sure u do substring rite way... index 10 is 11th char of the string

FN = "<abc>+ newFN + "_" + ".dat";

conf.put(key,FN);

}catch{

}

return FN;

Former Member
0 Kudos

Hi,

When it is taking substring, it is really surprising to see that it is taking a value from the Target Filename

instead of the source.

How can this happen?

Am I missing something in the code or configuration part?

I have enabled ASMA for both adapters.

How should I name the file scheme in ID. I have done that also in a proper way.

Former Member
0 Kudos

Following will fail if you do not process this via file adapter:

String FileName = conf.get(key);

String newFN = FileName.substring (11,15) ;

because FileName then is null and you will get a null pointer exception. So better check for null:

if (FileName != null) {

....

}

former_member200962
Active Contributor
0 Kudos
I have also specified the variable substitution in Receiver Channel.

This is wrong.

Enable ASMA in Sender and receiver channels and check on File Name

deepak_shah
Contributor
0 Kudos

Hi,

Check in mapping trace for more detials on mapping error.

Regards,

Deepak

Former Member
0 Kudos

Hi Sanjay,

The Dynamic configuration code seems to be fine but a small change. Test with the below code because the syntax is wrong in your code.

Use the below code"

DynamicConfiguration conf = (DynamicConfiguration)

container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String newFN = FileName.substring (11,15) ; 

String FN = "<abc>" + newFN + "_" + ".dat";

conf.put(key,FN);

return FN;

Thanks,

Thanks,

Former Member
0 Kudos

Hi Hareen,

I checked my UDF and I made a mistake while copying it here. UDF looks fine. and I think if there is a syntax error,

It doesn't get activated.

But mine got activated.

Former Member
0 Kudos

Hi,

Did you enabled Adapter specific message attributes in sender adapter?

Rgds

Rajesh

Former Member
0 Kudos

Hi,

In addition to the above suggestion, please chk ur code syntax:

Should be like this:

String FN = "<abc>" + newFN + "_" + ".dat";

Thanks

Amit

Shabarish_Nair
Active Contributor
0 Kudos

Are you testing this in message mapping or are you doing an end to end testing?

/people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name

Former Member
0 Kudos

hi shabz,

I did an end - to - end testing.

But still ..

Have got a silly doubt. But in your blog, I got a bit confused.

If we use dynamic config, is it necessary to use the Variable substitution?

I am not clear on this.

let me know.

former_member200962
Active Contributor
0 Kudos
If we use dynamic config, is it necessary to use the Variable substitution?

No...use only ASMA...dynamic config.....not variable substitution.

Shabarish_Nair
Active Contributor
0 Kudos

dynamic configuration is an alternative to variable substitution.

So you dont have to use both together.

Former Member
0 Kudos

Have Mapped the root nodes.

Is there any chance that my UDF is wrongly mapped to element.

I have mapped it with the root nodes.

aashish_sinha
Active Contributor
0 Kudos

Hi,

I hope you following below steps

- Create an UDF and include the piece of code that captures the Filename and Timestamp from source side via ASMA.

- Map the UDF to any of the top level node so that the modified filename will be available for the target communication channel

test mapping also from test tab in Message mapping

regards

Aashish Sinha

Former Member
0 Kudos

Hi Sanjay,

There are many solutions to set target filename.

refer this link for more info

http://wiki.sdn.sap.com/wiki/display/XI/CombiningthreedifferentaspectsofPIinoneshot