cancel
Showing results for 
Search instead for 
Did you mean: 

Generate target filename dynamically / Receiver File Adapter

Former Member
0 Kudos

Hi Community Members,

First of all I would like to say hello to everybody, as this is my first post in this forum.

I start with PI and would like to prepare a simple DEBMAS -> .csv interface.

In fact it is already done, but the requirement is to name .csv files according to customer number (KUNNR).

Hence is my question ... how to set CC to be assigning KUNNRs to file names? (like 123456.csv)

From what I can in the net people are using ASMA, but isn't there any simpler solution?

@

What I tried inside message mapping was to bound KUNNR field from my source message to root element of target message.

In addition I also set Field Name Scheme to *.csv in CC settings. Unfortunately I am receiving a CC error

The parameter "argument" has the value "/interfaces/PI/inbound/test/.csv", so it contains the character "/interfaces/PI/inbound/test/.csv" which is not allowed

@

But anyway if I would like to use ASMA I see I need to write a Java funciton as UDF.

Example tutorial [http://www.saptechnical.com/Tips/XI/ASMA/Index.htm]

But what next? How would I implement it into message mapping, to which xml element should it be assigned and what should be passed as function input, to make java function work?

Regards,

bob

Accepted Solutions (1)

Accepted Solutions (1)

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,

use below code and input to the UDF is KUNNR from source,create UDF in message mapping , then map UDF to target root element and enable ASAMA in Receiver channel.

DynamicConfiguration conf1 = (DynamicConfiguration) container

    .getTransformationParameters()

    .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String NFname= Var1+".csv";


return NFname;

Regards,

Raj

baskar_gopalakrishnan2
Active Contributor
0 Kudos

I think variable Var1 is not referenced in your code.

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

String Var1 = conf1.get(key1);
 
String NFname= Var1+".csv";
 
 
return NFname;

rajasekhar_reddy14
Active Contributor
0 Kudos

Var1 is input to your UDF, i.e KUNNR from source.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Use the "viarable substitution" concept, that will resolve your problem.

By using variable substitution you can prepare your file name with the value of the pay load(like kunnr).

google it you will get lot of pages, how to do.

Edited by: maridu on Dec 2, 2011 11:48 AM

Former Member
0 Kudos

For those who are on xI 3.0 > SP 14 , it is better to use ASMA insted of variable substiution

Best REgards,

Krish

Former Member
0 Kudos

hI bobens ,

you have to follw bellow steps because dynamicalluy we had call file name as same as your requirement.

STEP1: WRITE dynamic configuratio:

Public String DynamicConfig(String a, Container container) throws StreamTransformationException{

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

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

conf.put(key,a);

return "";

step2: in mapping

KUNNR + constant(.CSV) -> Concat -> udf(dynamic configuration) -> target root node

Configuration objects:

3. Receiver communication channel:

file name : ConfiguredDynamically

in Adavnce mode :

you have to enable these check boxes: use asma , fail if asma, filename.

thanks,

anupam_ghosh2
Active Contributor
0 Kudos

Hi Bob,

Welcome in the SDN Forum family.

Here are the steps to get the filename as per contents of KUNNR field in source xml message.

The input to the UDF is the contents of the field CustomerNumber.


public String getFileName(String CustomerNumber,Container container){ 
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION); 
 
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");  
String s = CustomerNumber+".csv"; 
conf.put(key, s); 
return s; 
} 

Map this UDF to root element or any dummy field in target XML.

In Receiver CC you need to set these

1. Receiver Comm Channel has ASMA , file name and "fail if ASMA missing" ticked.

2. in receiver communication channel -> File access parameters-> File name scheme -


> put any value say "*". This step is not compulsory.

3. In target directory of receiver CC put the name of the directory where you need the file to be formed.

Hope this solves your problem.

Regards

Anupam