cancel
Showing results for 
Search instead for 
Did you mean: 

message mapping issue

Former Member
0 Kudos

Hi folks,

I need to create file from PI side...

File name is to create like this Tax_Provision_From_IS_<borid>_<timestamp>.dat

Borid we need take from fileds only...

time stamp should be like this yyyymmddhhmmss.

I think for this need to write udf..I am having 0% java knlwkedge ..

Can anyone help me on this...Send me the mapping structur  also for this..it will be very helpfull

Regards

Kalyan

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

once you have to try below logic:

constant (Tax_Provision_From_IS_<borid>_) -> TIMESTAMP(UDF) + CONCAT ->.dat + concat -> dynamic conf ( UDF) -> target main node.

time stamp udf:

public String AddTimestamp(String var1, Container container) throws StreamTransformationException{

  
String DATE_FORMAT_NOW = "yyyyMMddHHmmss";

   Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);


    return sdf.format(cal.getTime());

dynamic conf udf:

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 "";

and also refer below wiki for more clarification:

http://wiki.sdn.sap.com/wiki/display/XI/Combining+three+different+aspects+of+PI+in+one+shot

former_member190624
Active Contributor
0 Kudos

Hi Kalyan,

Use the following code in ur UDF . One important point , u can't test dynamical configuration through ur Message mapping or operation mapping. you have to test it end to end.

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

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

String myFileName = "" ;

myFileName = FileName + "_" + Date + ".dat";

conf.put(key, myFileName);

return myFileName;

If still ur facing error's ,Pleaselet me know


Message was edited by: HARI

baskar_gopalakrishnan2
Active Contributor
0 Kudos

What error do you get?  The above UDF will return desired filename as string. You need to map the output of the udf to the target field that needs filename. If you don't have field in the target structure then don't map it to the target structure. You use UDF to set the value using dynamic configuration and using AF module write it in a variable and use variable substitution to set the receiver filename as explained by this blog

http://scn.sap.com/people/madanmohan.agrawal/blog/2009/05/20/combining-three-different-aspects-of-pi...

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>I think for this need to write udf..I am having 0% java knlwkedge ..

Greg has already covered coding part. Just one thing I want to highlight. Please make sure you return String from the method signature.

former_member184681
Active Contributor
0 Kudos

Hi Kalyan,

Use the following UDF for that purpose:

String filename = new String("");

Calendar cal = Calendar.getInstance();

SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");

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

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

filename = "Tax_Provision_From_IS_" + borid + "_" + sdf.format(cal.getTime()) + ".dat";

conf1.put(key1,filename);

return filename;

It only needs one input, which is the BORID field. It also has to import the following libraries:

java.util.Calendar

java.text.SimpleDateFormat

For more details about the configuration, use this Wiki:

http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=272171407

By the way, please always make sure to provide more detailed topic to questions you post in SDN, as per Rules of Engagement. In this particular case, something like "Dynamic target file name on receiver side" or so would be much better.

Regards,

Greg

Former Member
0 Kudos

Hi Greg,

As per your code ,can you send the mapping structure also,

Itried with this mapping but getting an error.

it will be helpful if you provide this