cancel
Showing results for 
Search instead for 
Did you mean: 

File Adapter - ASMA

Former Member
0 Kudos

Hi,

Scenario:

FTP - XI - FTP

File is retrieved using FTP and does not have extension. Example "abc"

File is to be stored by appending ".txt" to the filename.

So filename on receiver FTP channel should be abc.txt

Source file name is dynamic.

How do I add an extension (.txt) to a dynamic source filename ?

I was thinking abt Variable substitution like %fname%.txt but filename is not passed in the payload, so how do I replace fname ?

Any other ideas ?

Thanks

Bhaven

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Shah,

Using ASMA select Filename option in sender comm. channel.

Using ASMA select Filename option in receiver comm. channel.

In mapping write the user defined funciton for getting the filename only, not the extension and map it to a segment or field.

Then in filen name give FileName.txt. You should have your desired output.

Regards,

---Satish

Answers (5)

Answers (5)

Former Member
0 Kudos

If you are not using any IR objects, the writing AM is the solution.

Also if you requirement permits you can also go for Command line parameter at receiver file adapter side.

thanks

farooq

Former Member
0 Kudos

Hi Aamir,

Ok, I did create message mapping by just mapping the UDF to the target node.

But how do I create IM for this as it does not have any source message type ?

I was hoping to use it in my current IM where I map source MT to receiver MT (which in my case are same message type (STRING) ). In my current map, I call a ABAP class which I am supposed to use for some other purpose. This is already working.

I then did use it in my current IM as an additional mapping step and ran the interface and failed.

BTW, I am using %FileName%.txt in the file scheme and NOT using any variable substitution in the recvr comm channel.

I get error as:

<SAP:Category>Application</SAP:Category>

<SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>

<SAP:P1>com/sap/xi/tf/_Test_</SAP:P1>

<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>

<SAP:P3>Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:P3>

<SAP:P4 />

<SAP:AdditionalText />

<SAP:ApplicationFaultMessage namespace="" />

<SAP:Stack>During the application mapping com/sap/xi/tf/_Test_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: Fatal Error: com.sap.engine.lib.xml.parser.Parser~</

Regards

Bhaven

Former Member
0 Kudos

Aamir,

If the UDF does not have any input params, that means I just map that UDF to my target structure/field ?

I tried that and it gives mapping error ?

Where do I use this UDF ?

Thanks

Bhaven

Former Member
0 Kudos

Hey

Yeah,you wont have any input parameters in this,simply map it to the root node of the receiver structure.

Whats the error you are getting?

Thanx

Aamir

Pl:Since this is dynamic configuration,it will not work if you test under Test tab in Message mapping,It will only work when you actually send the file from sender system.

Former Member
0 Kudos

Hey

Use the following code in UDF

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String Source_File = conf.get(key);
Source_File=Source_File +".txt";
DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
conf1.put(key1, Source_File);
return "";

This UDF first reads(gets) the input filename via variable key and then adds .txt to it and then puts in ASMA via key1 The UDF will not have any input parameters.you need to enable ASMA on both sender and receiver side and use FileName as the filename on the receiver side.

Thanx

Aamir

Edited by: Aamir Suhail on Sep 3, 2008 3:18 PM

Former Member
0 Kudos

Thanks Satish.

But my payload does not have any structure as we do not have to do any conversion. Its just one field "PlainText" of type STRING.

So i/p file is loaded into this data element/MI and same is used for o/p.

Basically its just a interface for grabbing a file from a external server and pass it to our business for further processing . But our app needs the file as .txt !

???

Bhaven