on 09-16-2009 7:16 AM
Hi All,
Can any body give me the code for below logic.
Logic is From the source field Plant i am getting two characters for which we have to add
two more characters(i.e contry code) and send it to target field.But this country code
is available in the filename.
USPCSSC20090609122334 is the filename.
US is the countrycode for which we have to capture and add it to the plant field and send it to the target field.
So we have capture the countrycode dynamically so that this interface works fine for all countrys.
Good points will be given.
Thanks
Hi suraj,
yes there are two other udfs used in MM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi suraj,
Tried both returns but showing same errors while activating the MM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi suraj,
public String DynamicFileName(String plant, 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");
String filename = conf.get(key);
return filename.substring(0,1)+plant;
}
this is the code used in udf
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this
public String DynamicFileName(String plant, 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");
String filename = conf.get(key);
*return (filename.substring(0,1)+plant);*
}
Change return (filename.substring(0,1)+plant);
or better use return ((filename.substring(0,1)).concat(plant));
Regards
Suraj
Edited by: S.R.Suraj on Sep 16, 2009 6:28 AM
hi
I am getting these errors in mapping when i tried to activate the mapping
Function init, Line 1:
'class' or 'interface' expected public void init(GlobalContainer container) throws StreamTransformationException{ ^
com/sap/xi/tf/_InventoryData_To_ZINV_SYNC_MM_.java[207] 'class' or 'interface' expected public static void main(String[] args) throws Exception{/!_$ClNRep_/_InventoryData_To_ZINV_SYNC_MM_ st = new /!_$ClNRep_/_InventoryData_To_ZINV_SYNC_MM_(); st.testExecute(); } ^
com/sap/xi/tf/_InventoryData_To_ZINV_SYNC_MM_.java[208] 'class' or 'interface' expected } ^
com/sap/xi/tf/_InventoryData_To_ZINV_SYNC_MM_.java[209] 'class' or 'interface' expected ^ 4 errors
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
return filename.substring(0,1)+plant;
change the above code as follows
return filename.substring(0,2)+plant;
public String substring(int beginIndex,
int endIndex)
Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.
Example:
"USPCSSC20090609122334".substring(0, 2) returns "US"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks suraj,
So i will create udf with one argument i.e plant so code will be
public String DynamicFileName(String plant, 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");
String filename = conf.get(key);
return filename.substring(0,1)+plant;
}
IN MM
Plant -> DynamicfileName->Target file
Is this right
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
create a UDF with one argument plant
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);
return filename.substring(0,2)+plant;
}
plant(SourceField)--->UDF---->Target field
select use adapter specific identifiers in the sender communication channel and select filename
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks suraj
I will try with this code.But countrycode should be added before the plantfield two characters.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this code, i hope it will work,if little modification required to accordigly,
Take first argument plant,that is your source filed from source message,then get the file name using Dynamic configuration,then use substing function to get the first two values from Filaname,
finally append the Ccode with Plat,
retrunt this one ,
String Ccode;
public String DynamicFileName(Container container) throws StreamTransformationEx {
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String valueOld = conf.get(key);
Ccode=valueold.substring(2);
Result = Ccode + Plant;
return Result;
}
I have complied the code,but this logic work fine..
Cheers,
Raj
Hi,
Get the file name using this UDF
public String DynamicFileName(Container container) throws StreamTransformationEx {
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String valueOld = conf.get(key);
return valueOld;
}
Do a sub string to get first two characters and append with source field
Make sure use set the use adapter specific identifiers in the sender communication channel and select filename
Hope this helps
Regards
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.