User - defined functions for calculating the taxes of state and country

hi expects,
    how can write user-defined function in message mapping in which i want to calculate the states taxes (2500) and country taxes (5000) and give the result as grand total in output.please help me?

Hi,
Activities
1. To create a new user-defined function, in the data-flow editor, choose Create New Function (This
graphic is explained in the accompanying text), which is located on the lower left-hand side of the
screen. In the menu, choose Simple Function or Advanced Function.
2. In the window that appears, specify the attributes of the new function:
Name
Technical name of the function. The name is displayed in the function chooser and on the data-flow
object.
Description
Description of how the function is used.
Cache
Function type (see above)
Argument Count
In this table, you specify the number of input values the function can process, and name them. All
functions are of type String.
3. In the window that appears, you can create Java source code:
a. You can import Java packages to your methods from the Imports input field, by specifying them
separated by a comma or semi-colon:
You do not need to import the packages java.lang., java.util., java.io., and java.lang.reflect. since
all message mappings require these packages and therefore import them. You should be able to
access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the
package under Import. In other words, you do not have to import it as an archive into the Integration
Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the
SAP Logging Service (see also: Runtime Environment (Java-Mappings)).
In addition to the standard packages, you can also specify Java packages that you have imported as
archives and that are located in the same, or in an underlying software component version as the
message mapping.
b. Create your Java source text in the editor window or copy source text from another editor.
4. Confirm with Save and Close.
5. User-defined functions are limited to the message mapping in which you created the function. To
save the new function, save the message mapping.
6. To test the function, use the test environment.
The new function is now visible in the User-Defined function category. When you select this category,
a corresponding button is displayed in the function chooser pushbutton bar. To edit, delete, or add the
function to the data-flow editor, choose the arrow next to the button and select from the list box
displayed.
Regards
Seshagiri

Similar Messages

  • User defined function for getting last string in the line

    Hi Experts,
    I am not java expert, can anyone give me user defined function for getting last string in the line.
    for example if the source field is "NEW ARBOUR SQUARE"  i want to pass to target field only last string that is "SQUARE"
    please help me out of this.
    Kind Regards.
    Praveen.

    You don't even need a UDF for this. In the graphical editor look for the standard functions and once you do a scroll over on 'text functions; you will find what you are looking for.
    Just a piece of advice, try keeping UDF's to minimum unless really required or it is complicated without it.
    regards

  • Need user define function for the message  mapping structure

    Hi All
    I am new to XI.I need the java code for Udf for the following structure.
    i have two input and one out put as error.
    order_nos----
    user define function-------error message
    order_details----
    num of orders---- i.e. 10
    order_details------ i.e. whole order records details
    1.i have to compare the 1st  input with 2nd one means if the ist input contain 10 means there are 10 orders in 2nd input.if not then i have to give error message .
    2.then i have to check the fields in 2nd input has no null values.if no values the output will be error message.
    Edited by: Rohit Kumar on Dec 18, 2008 4:43 PM

    Hi Sudhir
    thanks for your continues help.i need some help so that i can fulfill my requirmrnt
    this is my message mapping xml.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:methodCall_MT xmlns:ns0="http://www.dfdsf">
      <num_orders>10</num_orders>
      <test_mode />
    - <order_x>                        ( which is order details)
      <order_id>t78tyu8t</order_id>
      <order_date />
      <mfg_id />
      <catalog_id />
      <first_name />
      <last_name />
      <recipient />
      <message />
      <address1 />
      <address2 />
      <address3 />
      <city />
      <state />
      <zip />
      <country />
      <country_code />
      <phone />
      <subtotal />
      <tax />
      <shipping />
      <total />
      <shopatron_total />
      <fulfiller_total />
      <shipment_id />
    - <additional_info>
      <in_store_pickup />
    - <express_shipping>
      <express_shipping_flag />
      <express_shipping_text />
      <express_shipping_arrival />
      </express_shipping>
      </additional_info>
    - <discount>
      <discount_description />
      <discount_percentage />
      <discount_total />
      </discount>
      <lang_id />
      <currency_id />
      <packing_list />
      <num_items />
    - <items>
      <item_id />
      <quantity />
      <price />
      <part_number />
      <fulfiller_total />
      <shopatron_total />
    - <options>
      <option_x />
      </options>
      </items>
      </order_x>
      </ns0:methodCall_MT>
    this my mapping where under one element number elements are there.when i am excuting the code to check the null value its always giving the there is null val but i have filled evrything.its due to first its checking the order_x and which will be always null.uder this all data will be filled.please suggest what to change in the udf.the code  given by u is working fine but its failing in this scenario because it getting the parent filed is null.

  • SQL User Defined Functions for performing statistical calculations

    Hi!
       I hope you can help.  I just wasn’t sure where to go with this question, so I’m hoping you can at least point me in the right direction.
       I’m writing a SQL Server stored procedure that returns information for a facility-wide scorecard-type report.  The row and columns are going to be displayed in a SQL Server Reporting Services report. 
       Each row of information contains “Current Month” and “Previous Month” numbers and a variance column.  Some rows may compare percentages, others whole numbers, others ratios, depending on the metric they’re measuring.  For each row/metric the company has specified whether they want to see a t-test or a chi-squared statistical test to determine whether or not there was a statistically significant difference between the current month and the previous month. 
       My question is this:  Do you know where I can find a set of already-written user defined functions to perform statistical calculations beyond the basic ones provided in SQL Server 2005?  I’m not using Analysis Services, so what I’m looking for are real SQL User Defined Functions where I can just pass my data to the function and have it return the result within a stored procedure. 
       I’m aware that there may be some third-party statistical packages out there we could purchase, but that’s not what I’m looking for.   And I’m not able to do anything like call Excel’s analysis pack functions from within my stored procedure.   I’ve asked.   They won’t let me do that.   I just need to perform the calculation within the stored procedure and return the result.
       Any suggestions?  Is there a site where people are posting their SQL Server UDF’s to perform statistical functions?  Or are you perhaps aware of something like a free add-in for SQL that will add statistical functions to those available in SQL?   I just don’t want to have to write my own t-test function or my own chi-squared function if someone has already done it.
     Thanks for your help in advance!  Oh, and please let me know if this should have been posted in the TSQL forum instead.  I wasn't entirely sure.
    Karen Grube

    STATS_T_TEST_
    docs.oracle.com/cd/B19306_01/server.102/b14200/functions157.htm 
    STATS_T_TEST_ONE: A one-sample t-test
    STATS_T_TEST_PAIRED: A two-sample, paired t-test (also known as a crossed t-test)
    STATS_T_TEST_INDEP: A t-test of two independent groups with the same variance (pooled variances)
    STATS_T_TEST_INDEPU: A t-test of two independent groups with unequal variance (unpooled variances)

  • Error in User defined function for dynamic file naming

    Hi,
    While creating User Defined function with this following code for dynamic fieldname
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String ourSourceFileName = conf.get(key);
    return ourSourceFileName;
    which options should i select for cache Value, Context, Queue
    for Augument , what name shd i mention.
    Regards,
    Varun

    Hi Varun,
    I guess I have answered a similar question just a few minutes before on very similar post from you. Just pasting the same here .................
    Are you trying to access the ASMA values from the SOAP header of the XI message for the source file name?
    First of all you need to Set the Sender File Adapter for Set ASMA and then file name. So it will work fine when you actually run the scenario end to end.
    But in the mapping tool when you test the mapping - there is not message header updated with the actual source filename - and whenever you try to read the FileName attribute in the message header from the UDF - it cannot find the object and returns a NullPointerException.
    I would suuggest for your mapping tool testing to be successful, have a check in the java code for null values,
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String ourSourceFileName = conf.get(key);
    If (ourSourceFileName != null)
       Return ourSourceFileName;
    Return "NoFileName.txt";
    Let us know if this works.
    Regards,
    Suddha

  • Making a User Defined Function for Mapping in XI

    Hi folks..
    I knw how to make User defined Function in XI,
    i was wondering about can we have any room for making a function for Initializing Purpose, which intializes few fields in source Message to some Global variables, and later we can use these Global Variables to set the the Target field
    My Doubt is this...
    i have Source & target Structure like this Structure like this....
    SOURCE  TEST DATA IS... 
    Parentsrc                   
        child1src a              
        child2src b              
        child3src c                     
        child4src hi
        child4src hello
        child4src hey            
    (On the basis of instances of child4src the istance of the Parentdst will be generated)                                        
    TARGET DATA SHUD BE LIKE THIS....
    Parentdst                    
        child1dst a              
        child2dst b              
        child3dst c                     
        child4dst hi
    Parentdst                     
        child1dst a              
        child2dst b              
        child3dst c                     
        child4dst hello
    Parentdst                     
        child1dst a              
        child2dst b              
        child3dst c                     
        child4dst hey

    Hi
    You have to modify  your target structure:
    <b>Source</b>
    Parentsrc
    child1src a
    child2src b
    child3src c
    child4src hi
    child4src hello
    child4src hey
    <b>Target</b>
    <b>root</b>
    Parentdst
    child1dst a
    child2dst b
    child3dst c
    child4dst hi
    Parentdst
    child1dst a
    child2dst b
    child3dst c
    child4dst hello
    Parentdst
    child1dst a
    child2dst b
    child3dst c
    child4dst hey
    <b></root></b>
    Now map like this:
    child4src -
    Parentdst
    child1src--|
    child4src--| UseOneAsMany -- Splitbyvalue --- child1dst
    child4src--|
    child2src--|
    child4src--|UseOneAsMany --Splitbyvalue --- child2dst
    child4src--|
    child3src--|
    child4src--| UseOneAsMany -- Splitbyvalue --- child3dst
    child4src--|
    child4src -- SplitbyValue -- child4src.
    Regards
    Suraj

  • Java user-defined function for mapping a complex structure

    All,
    Hope one of you can help me with this. I have a structure with over 15 fields and would like to concatenate all the fields into one target field and while I do this, I need to ensure that each field is padded with blanks as defined the data type. Can one of tell me if this is possible with a java user-defined function and if so, what type of logic is needed.
    Input_MT
    Field_1  string len=10 "need"
    Field_2  string len=6 "java"
    Field_3  string len=7 "help"
    Field_4  string len=8  "asap"
    etc,
    Output_MT 
    DataOut string  "need      java  help   asap    "
    (for some reason the exact spaces in between the words disappear in my Preview message)
    I have several fields in the input mt and therefore I find graphical mapping using concatenate and my own user defined function padWithSpace too messy.
    Thank you for you help.

    Hi,
    If your final req is to write all these fields next each other in a file, you can configure this in receiver file adapter by specifying the fixed length for each field.
    If you want the padded string as your MM o/p, you can create a simple user defined funtion with 15 fields as input and 15 constants for their lengths, and find out the length of the each string and pad it with required no of spaces.
    int max_len = 10;
    int actual_len;
    actual_len = a.lengh();
    for(int i=0; i < (max_len-actual_len; i++)
    a = a.append(" ");
    return a;
    praveen

  • UDF(user defined function) for standard date transformate function,

    Hi All,
    Hope you are doing good !!!
    I have a requirement where i need to write an UDF(user defined function). Please help me in writing the code for below logic-
    I am getting my Input as 111213 where 11 denotes HH 12 denotes mm 13 denotes ss. I need ti insert : between hh:mm:ss
    Please help me achieving a code for below logic
    I have used standard date transformate function, there i am getting spaces as separator in my input resulting an errors i am sending without spaces.
    Regards,
    Vijay Kumar.

    Hello,
    I am getting my Input as 111213 where 11 denotes HH 12 denotes mm 13 denotes ss. I need ti insert : between hh:mm:ss
    Please help me achieving a code for below logic
    I have used standard date transformate function, there i am getting spaces as separator in my input resulting an errors i am sending without spaces.
    What do you mean by spaces? Can you try the mapping below?
    inputDate -> replaceString -> dateTrans(inputDateFormat: HHmmss outputDateFormat: HH:mm:ss) -> target
    Constant: -> /
    Constant:-> /
    Hope this helps,
    Mark

  • User defined function for removing wrong data ... !!!

    Hi  Experts,
    I'm having a source data like this
    1001     545     6895895     1584     654     5478
    1002     525     6895895     5084     654     5472
    1003     535     6895895     0584     654     5478
    1004     545     6895895     5184     654     5478     4XXX     &^%%     1004     545
    1005     555     6895895     5824     654     5478     8547     0000     522#     ##00
    1006     565     6895895     5844     654     5478
    1007     575     6895895     5845     654     5478
    1008     585     6895895     5846     654     5478
    Some times I get a wrong data in my source file (above 4 and 5 th rows) .
    My requirement is to remove these kind of wrong lines(entire lines to be removed) whenever XI reads the data. For this what is the standard function i can use in mapping. I thought I can create my own function to remove such kind of false data lines. It would be helpful for me if some body provide me the java code.
    Thanks very much.

    Hi Swarna,
    1001 545 6895895 1584 654 5478
    1002 525 6895895 5084 654 5472
    1003 535 6895895 0584 654 5478
    1004 545 6895895 5184 654 5478 4XXX &^%% 1004 545
    1005 555 6895895 5824 654 5478 8547 0000 522# ##00
    1006 565 6895895 5844 654 5478
    1007 575 6895895 5845 654 5478
    1008 585 6895895 5846 654 5478
    is it the .txt file you are keeping.  Or the input in your mapping.
    You just Tell your requirement properly.
    If it is input in Mapping. Map like this
    input ----->subtring( starting position 0 andNumber of characters 30) ---->Output
    substring is a standard Text function.
    Thanks.

  • User defined function to check the NULL and 0.00 value in a Amount field

    Hi Experts,
    I have one scenario in which i have amount field in Data type.
    I have to create one UDF which will do the following thing.
    1. If the amount field is Null it should throw an exception in mapping.
    2.If the amount field is 0.00 it should throw an exception in mapping.
    3. For all other cases it should pass the amount value to the target.
    Can anyone provide me the code For this UDF.
    Thanks in advance.

    Hi,
      You can add this logic to the UDF. Here var1 is the input string.
    java.math.BigDecimal b=new java.math.BigDecimal(var1);
              if(b.compareTo(new java.math.BigDecimal("0.00"))<=0)
                   //write your logic for values less equal to zero
    One small request, if you think your question has been answered, properly and correctly, could you please kindly if possible close down this thread. It helps people who look for solutions to similar problem.
    regards
    Anupam

  • Error in User defined function for jdbc lookup

    I am getting th error as follows "Method TestJDBCAPI$ with 2 arguments not found in class com.sap.xi.tf._JLU_MM_" when i a m testing in message mapping

    //write your code here
    String Query = " ";
    Channel channel = null;
    DataBaseAccessor accessor = null;
    DataBaseResult resultSet = null;
    //Build the Query String
    Query = "Select role from login where username = " + username[0] + " and password = " + password[0] ;
    try{
    //Determine a channel as created in the configuration
    channel = LookupService.getChannel("JLU_BUSS","JLU_chan");
    //  Get a system accessor for a channel.As the call is being made to the database an database accessor is obtained.
    accessor = LookupService.getDataBaseAccessor(channel);
    // Execute the Query and get the values in the resultSet.
    resultSet = accessor.execute(Query);
    for(Iterator rows = resultSet.getRows();rows.hasNext();)
    Map rowMap = (Map)rows.next();
    result.addValue((String)rowMap.get("role"));
    catch(Exception ex){
    result.addValue(ex.getMessage());
    Above is my udf.My logic is that for the given username and password it should select the corresponding role from the database.

  • User define function for SQL Server

    Hi all,
    it's possible to write an UDF for SQL Server in Java?
    I know that it is possible with DB2 and Oracle.
    My main goal is to write an UDF that works well with all of these DB.
    Thank's

    Hi all,
    it's possible to write an UDF for SQL Server in
    Java?Okay, JDBC can talk to any database (given you have a driver implementation). Also, JDBC is like a conduit. So the real question is likely, will your database let you do this?
    I know that it is possible with DB2 and Oracle.
    My main goal is to write an UDF that works well with
    all of these DB.I also don't know what a UDF is, but if you ARE talking about stored procedures, then no, it's not possible. All databases are different. On that note, I typically recommend NEVER using stored procedures unless absolutely necessary.
    But it also sounds like you want to do this at runtime. I've seen systems that do this (bind stored procs at runtime dynamically) and it's a freakin nightmare! So be careful.

  • Whether i would write user-defined function convert euro into rupee or USD

    hi expects,
       whether it need to right user defined functions for convert the currency into euro or any other currency  into rupee or USD.as my client is having business in different region.please help me.
    Edited by: santosh kumar sethis on Apr 24, 2008 10:39 AM

    I suggest to use a UDF and call an RFC function\BAPI in the ERP system.
    Currency conversion values  are maintained in the ERP system by the Financial people so you'll have the most updated rates.(maybe even according to the date of purchase)
    So 3 scenarios come to mind:
    1. if the message is send from a 3rd party system or from ERP ,the currency must be converted already in the message,
    2.the RFC of the ERP will do the conversion or you.
    3.Find a currency conversion web service that has parameters of date and currency so you'll do the conversion as accurate as possible.
    bare in mind:
    there might be inconsistency of the money values due to the change in currency from the time the order was placed in the system till the time of entering the SAP .ask for the advise of a financial person so you wont do any mistakes in conversion.
    ANY WAY - don't use hard coded constants in XI mapping for currency conversion.
    Good luck.
    Nimrod

  • What is the purpose of User-Defined Functions under Excel Service Application?

    Hello, I have done a lot of research and have concluded that we cannot use VBA present under Excel sheet code in sharepoint.
    Today I was reading on excel services in sharepoint. I came across User-defined functions under Excel Service Application settings. I believe that User defined functions refer to the Calculations and VBA (am I wrong on this?).
    If true, then, does this bring hope that we can use embedded VBA code present into excel sheet in SharePoint also?

    Hi Nachiket,
    When you set  ‘Allow External Data’ to None, it disables all external data connections for the trusted file location.
    When you set  ‘Allow External Data’ to ‘Trusted data connection libraries and embedded’, it enables connections that are embedded in the workbook file or connections that are stored in a trusted data connection library.
    More information, please refer to the link:
    http://technet.microsoft.com/en-us/library/jj219699.aspx
    As your description, when you tried to set Allow External Data to None, the external data also was displayed, it may be caused by data cache or time delay.
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Error in conditional map using User Defined Function

    All,
    In my mapping I basically have a user defined function that returns the filename of my inbound file from the adapter-specific message attributes (file adapter).  I know this is coded properly because if I simply assign this function to my destination field I can see the filename in the payload XML.
    However if I conditionally check that returned value using if,then,else I get an error message stating:
    "During the application mapping com/sap/xi/tf/_MaterialData2ZcustProdMastMulti_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: RuntimeException in Message-Mapping transformation"
    Essentially in my if I'm checking if the value returned by my user defined function is equal to the constant "SOMECONSTANT" then I'm setting my destination field to some other constant value.  Otherwise it's equal to a different constant value.
    Any thoughts?

    Claus,
    Thanks for the help.  I actually had figured the problem out on my own.  Sorry for not updating the thread sooner.  What happened was this (as I suspected it wasn't related to my user defined function).  For the newbies out there (of which I'm one) the problem was I was comparing strings in the graphical mapping tool using the Boolean "EQUALS" rather than the Text "EQUALSS".
    Can you give yourself points for solving

Maybe you are looking for

  • T61-Fan Error on startup and cant boot in system

    after Thinkpad logo, 2 short 'Bee' sound and 'fan error' message appears on the top left screen, then 1 'Bee' sound, laptop shut down. Althought can boot in system by pressing Esc when 'fan error' appears, but dont know this will damage something lik

  • In Unix, main JFrame focus not regained after modal dialog exit.

    Hi all, I'm new to this forum so hopefully this is the right place to put this question. I have a relatively simple GUI application written in Java 6u20 that involves a main gui window (extends JFrame). Most of the file menu operations result in a mo

  • Down payments configuration and condition AZWR value 0.

    Hi, I am trying to configure the standard down payments but I have the following questions: 1º ) I have configured the condition type AZWR with all the requirements from the manual, condition 2 and the calculation formula 48 but I donu2019t know whic

  • Opening File in Illustrator CC

    I just started using the CC version of the design products this weekend, and yesterday I spent all day working on a design in Illustrator. Today if I try to open it, Illlustrator just hangs - and eventually I have to force quit. I get no error messag

  • Save login details on phone

    Is there any way to enter login details on your phone for the Nokia Music Store and haev the phone retain the login details so you don't have to re-enter your name and password every time you open the store?  i have a Nokia 5800.