Skip to Content
avatar image
Former Member

message mapping issue

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

2.PNG (23.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Aug 23, 2012 at 01:34 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

      2.PNG (4.4 kB)
  • Aug 23, 2012 at 01:39 PM

    >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.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 23, 2012 at 03:36 PM

    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-asma-af-module-and-variable-substitution-in-one-shot

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 24, 2012 at 06:13 PM

    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


    test.JPG (22.6 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 27, 2012 at 06:46 AM

    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

    Add comment
    10|10000 characters needed characters exceeded