UDF help

Dear All,
Kindly let me know what am I doing wrong in the below code? I am getting errors in the UDF ...
int I_Length = 0;
int H_Count = 0;
String flag;
H_Count = I_Val.replaceAll("-","").length();  // Count all "-" in the string
I_Length = I_Val.length();                              // Count the length of the string
if ( (H_Count.equals("3")) && (I_Length.equals("21")) )
     flag = "x";
else flag = "y";
return flag;
"I_Val" is a variable that I am passing in the UDF. I getting error as - Error in source code.
Please help. Thanks,
--Abhi

Hi,
>>>Yes Michal ... it worked !! Thanks for your kind help.
no problem
>>> You are extra cool
I know hehe
Thanks Abhi,
Regards,
Michal Krawczyk

Similar Messages

  • Java UDF help

    hello
    I have a string that I recieve from a WS. the string is flat XML. I would like to take only sum of the string.
    I would the out put string to be from the begining tag <NS8:EzlifeInsuranceFile and to end </NS8:EzlifeInsuranceFile>.
    I would like to transfer the substring of the string the start with the tag above and ends with the string above. does any body has a UDF that does it?
    and example XML:
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xml="http://www.w3.org/XML/1998/namespace">
         <SOAP-ENV:Header>
              <NS1:MessageID xmlns:NS1="http://schemas.xmlsoap.org/ws/2004/03/addressing">82851a66-374c-4847-bf53-437755c45654</NS1:MessageID>
              <NS2:From xmlns:NS2="http://schemas.xmlsoap.org/ws/2004/03/addressing">General</NS2:From>
              <NS3:StartTime xmlns:NS3="http://migdal.com/soap/header/">2008-12-23 10:32:29.077</NS3:StartTime>
              <NS4:ServiceName xmlns:NS4="http://migdal.com/soap/header/">MortgageProposalDetailService</NS4:ServiceName>
              <NS5:ServiceVersion xmlns:NS5="http://migdal.com/soap/header/">1.0</NS5:ServiceVersion>
              <NS6:CallIdentifier xmlns:NS6="http://migdal.com/soap/header/">176226f3-8c67-4dda-a069-ce8495e44236</NS6:CallIdentifier>
              <NS7:CurrentCallMetaData xmlns:NS7="http://migdal.com/soap/header/">
                   <NS7:ServiceName>MortgageProposalDetailService</NS7:ServiceName>
                   <NS7:ServiceVersion>1.0</NS7:ServiceVersion>
                   <NS7:StartTime>TIMESTAMP &apos;2008-12-23 10:32:29.171&apos;</NS7:StartTime>
                   <NS7:Provider>SAPCRM</NS7:Provider>
                   <NS7:Protocol>HTTP</NS7:Protocol>
                   <NS7:Server>mgnt371</NS7:Server>
                   <NS7:Destination>https://mgnt371:50001/XISOAPAdapter/MessageServlet?channel=:SOAP_Services:ProposalDetailsService_SOAP_Sender</NS7:Destination>
                   <NS7:Mode>Sync </NS7:Mode>
                   <NS7:User>xisuper</NS7:User>
                   <NS7:Password>mgdsap</NS7:Password>
              </NS7:CurrentCallMetaData>
         </SOAP-ENV:Header>
         <SOAP-ENV:Body>
              <NS8:EzlifeInsuranceFile xmlns:NS8="http://Migdal.co.il/ProposalDetailsRequest/Input">
                   <userName>CRM_SYS_USER</userName>
                   <password>Qaz9Pl@5</password>
                   <TransferType>2</TransferType>
                   <Agent>
                        <ID>237cb1f3-19e6-48b5-9e92-bdc1592f145b</ID>
                        <FirstName>סוכן</FirstName>
                        <LastName/>
                        <FullName>סוכן </FullName>
                        <AgentNumber>1254</AgentNumber>
                        <SupervisorName/>
                   </Agent>
                   <InsuranceFile>
                        <ID>222069cd-cf2c-45dd-a72d-e52e2c0e1c8a</ID>
                        <Family>
                             <ID>222069cd-cf2c-45dd-a72d-e52e2c0e1c8a</ID>
                        </Family>
                        <AdditionalQuestionsSelection>
                             <CapitalPensionPrimeDivisionSelection>5</CapitalPensionPrimeDivisionSelection>
                             <SalaryInNIS>0</SalaryInNIS>
                             <SalaryInPercents>0</SalaryInPercents>
                             <InvestmentTypeSelection>1</InvestmentTypeSelection>
                             <RewardRouteSelection>1</RewardRouteSelection>
                             <CompensationRouteSelection>1</CompensationRouteSelection>
                             <DangerousHobbySelected>False</DangerousHobbySelected>
                             <DangerousHobbyDescription/>
                             <IsCourseNoEmployerAproved>False</IsCourseNoEmployerAproved>
                             <IsCourseWithEmployerAproved>False</IsCourseWithEmployerAproved>
                             <StartWorkingDate/>
                             <SpouseSmokingStatusDetails>
                                  <SmokingStatus>0</SmokingStatus>
                                  <CigarettesPerDay>0</CigarettesPerDay>
                                  <YearsOfSmoking>0</YearsOfSmoking>
                                  <YearsOfNotSmoking>0</YearsOfNotSmoking>
                             </SpouseSmokingStatusDetails>
                             <ProposalReceivingDate>23/12/2008 10:32:27</ProposalReceivingDate>
                        </AdditionalQuestionsSelection>
                        <Note/>
                        <Title/>
                   </InsuranceFile>
              </NS8:EzlifeInsuranceFile>
         </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    Hi Grzegorz Glowacki,
    I am sorry this is not working :(.
    Sample input: 4E2D56FD     -->basically this hexavalues are chinese character representation.
    Output for it: ?????????
    +for verification:open Wordpad-->copy the hexcode >select 4chars at a time> hit <altx> and you will get corresponding conversion value.++
    String result = new String();
    try {
      byte[] bytes = new byte[input.length()/4];
        for (int i = 0; i < input.length()/4; i++) {
          byte value = Integer.valueOf(input.substring(i*4,i*4+4), 16).byteValue();
          bytes<i> = new Byte( value );    *//Byte cannot be stored in byte*
        result = new String(bytes, "UTF-16");
    catch (UnsupportedEncodingException e){}
    return result;
    Also this is PI7.0 system. please do help.
    thanks in advance.
    Regards,
    Prakash.
    Edited by: senthilprakash selvaraj on Feb 2, 2012 9:38 AM

  • Message mapping/UDF help..

    Hi experts,
    Can someone let me know whether there is a chance to fulfill the below requirement:
    Input file:
    In the Input CSV file, there is a fixed length field with length 9 char and has leading zeroes (ex: 000000650)
    Output file:
    In the O/p XML file, the corresponding value should be displayed as "6.50" (Have to remove the leading zeroes, right justified and the last two digits should be allocated for decimals)
    Can anyone let me know if we can handle in Message mapping or should we write a UDF? If so can you please provide the code..
    Any help would be highly appreciated !!
    Thnx
    - Ravi

    Hi Ravi,
    UDF:
    Create a function zerosuppress and take the cache as value and take one argument input. Then put the code below:
    //Put this code
    String output = input.replaceFirst("^0+","");
    return output;
    With this function your leading zeros will remove.
    Then map like this:
    source field --> zerosuppress (udf) --> divide by 100 --> target field.
    This should solve your issue.
    Regards,
    ---Satish

  • UDF help -break statement

    Hi all,
    I have a problem with my UDF. <i>A break statement doesnt break out of the for loop. </i>Please go thru the follwing and offer your helping hand.
    <b>The Issue:</b>
    In need to <i>check the value of a "child" element for each occurrence of the parent node </i>and if the condition is true then <i>map the value of "1" to the target element </i>with the same name and a same parent.
    <b>Source Structure:</b>                 
    ParentNode1 <1..1>                        
    ...Child Node1 <1.unbounded>             
      .... Flag_Source  <1.1> 
    <b> Target Structure</b>
    ParentNode1 <1..1>
    ....Child Node <1. unbounded>
    Flag_Target <1.1.>    Mapping
    <b>GUI Mapping:    </b>                  
    (Flag Source) -
    [UDF]>>>>>>FlagTarget
                                        ^-
    (ChildNode1) -
    ^
    <b>Condition:</b>
    for each child node1
    If ParentNode1>ChildNode1>FlagSource = 1
    then Flag-Target = 1
    <b>Global Integer Element flag</b>
    int flag;
    <b>UDF:</b>
    <i>Info:</i> Type is Context;
    Takes 2 Arguments
    1. Flag_Source- <i>Context Set to ParentNode</i>
    2.ChildNode1
    AbstractTrace trace = container.getTrace();
    for ( int j = 1; j < ChildNode1.length; j++)<i>
         if ( Flag_Source[j].equals(" 1")){ 
         trace.addInfo("retrieved the value"+Flag_Source[j]);
                    flag = 1;
                   break;  <b>// the for loop does not terminate here</b>
           }else
           flag= 0;
    if ( flag == 1) {
    result.addValue("1");
    else
    result.addValue("0");
    <b>Testing</b>
    Also when i test the mapping , I get the following error
    <b>
    "Cannot produce target element..
    Check xml instance is valid for source xsd and target-field mapping fulfills..."</b>
    Please help me with your suggestions
    Thanks
    regards
    krishna

    Hi all,
    I have successfully mapped the source to the target.
    I was working simultaneously on the issue. I just saw your responses and i appreciate all of your feedback.
    Mudit,
    As per your soultion, I would not achieve the desire result because I need to read the value of "flag_source" for every instance of childnode1 and i can only achieve this by havin
    ffor(int i=0; i< childnode1.length;i++) and not flagnode.length as you have suggested.
    Samarajit,
    Nice observation about the blanks space:)  but you know what I spent a lot of time just to figure that there was a blank comming up before 1:)
    Amit,
    Your solution closely matches up my "Working" function though I had to fix some context related issues. I used "SplitByValue"for that .
    Thank you all again for your inputs
    Regards
    krishna

  • UDF Help Please

    Hi,
    I have a scenario where I have input strings. Within this string there are up to 10 characters (it can be 8, 6, 4, 2, or 0), all of which are 2 character codes. So for example my string may be
    abcdefghij
    within the above the 2 character codes would be
    ab,cd,ef,gh,ij
    Now I have a basket of codes that could be present in the above string. Lets say I have 10 codes. So what I need to do is assess the string and see if any of my basket of codes exists within that string. If any one of the 10 2 character codes exist then I want to return confirmation string "Present" the none of the codes are found then I want to return "Not Found".
    Could someone help me with this logic for the UDF?
    Thank you and points will be rewarded of course.
    SA

    Hi SA,
                You have not specified if the basket of codes are being supplied as input to the UDF or not. In case they are not being supplied as input field please follow this UDF
    public  String codes(String s,Container container)
              try
                   String codes[]={"ab","fg","yy"};
                   int i,length=0,j;
                   if(s!=null && s!="")
                        //test if string is null
                        length=s.length();
                   if(length<=0)
                        return "Not Found";
                   for(i=0,j=i+2;j<length;i=j+1,j=i+2)
                        //check presence of 2 charcater code
                        // break original string into 2 chars each.
                        String temp=s.substring(i,j);
                                                                                    //now compare with basket od values
                        for(int k=0;k<codes.length;++k)
                             if(temp.equals(codes[k]))
                                  return "Present";
              catch(Exception e)
                   e.printStackTrace();
              return "Not Found";
    Thus if your input is
    abcdefghij
    the UDF breaks it into pieces as follows ab|cd|ef|gh|ij
    the basket is String codes[]={"ab","fg","yy"};
    output you get is "Present"
    again for the same input string
    if the basket of codes is      String codes[]={"kk","fg","yy"};
    output you get is "Not Found"   (as "fg" are not in same segment.).
    Please kindly modify the basket of codes in the above UDF as per your requirement. so for ten different codes the string might be
    String codes[]={"ab","cd","ef","gh","ij","kl","mn","op","qr","uu"}
    In case the basket of codes is an input itself then you can input this as an array of strings to the UDF
    public  String codes(String s,String codes[],Container container)
              try
                   int i,length=0,j;
                   if(s!=null && s!="")
                        //test if string is null
                        length=s.length();
                   if(length<=0)
                        return "Not Found";
                   for(i=0,j=i+2;j<length;i=j+1,j=i+2)
                        //check presence of 2 charcater code
                        // break original string into 2 chars each.
                        String temp=s.substring(i,j);
                        for(int k=0;k<codes.length;++k)
                             if(temp.equals(codes[k]))
                                  return "Present";
              catch(Exception e)
                   e.printStackTrace();
              return "Not Found";
    Regards
    Anupam
    Edited by: anupamsap on Feb 6, 2012 4:58 PM

  • User Defined Function (UDF) help required. Pls advice urgent.

    Hi ,
    CRM -- XI (UDF) -- Socket Connection
    Now in User Defined Function (UDF) of Message Mapping I will open Socket Connection.
    Send CRM XML request to socket and get XML response from Socket and then map to some system.
    Can I write Java Class code in User Defined Function (UDF)  of Message Mapping instead of Java Mapping in blog below?
    /people/saravanakumar.kuppusamy2/blog/2005/12/15/socket-integration-with-xi
    Regards

    Henry,
    Do you have a structure for your response...if you do then you can do extended reciever det with sync/async..shouldent matter, i just tried it and i dont get any error.
    in your reciever determination..Check the box for standard rec det then add your first condition..of the value of a field to true..then send to A..
    then you select add condition..and add for second reciever..that should be it, you shouldent need a bpm for such a simple scenario..it definetly is an overkill.
    Regards
    Ravi Raman

  • UDF help required.

    Hi,
    <data>
    ..<Person>
    ....<Contact>
    ............<Telephone>
    ...................<Number>984574123658</Number>
    .............</Telephone>
    ......</Contact>
    ....<Contact>
    ............<Telephone>
    ...................<Number>984574123658</Number>
    .............</Telephone>
    ......</Contact>
    ..</Person>
    </data>
    Target filed 'PHONE' needs to be mapped only to Contact[0].Telephone.SubscriberNumber, and not Contact[1].Telephone.SubscriberNumber.
    How can this be done in UDF?
    Thanks,
    Vishal

    <data> First Occurence
    ..<Person>
    ....<Contact>
    ............<Telephone>
    ...................<Number>1</Number>
    .............</Telephone>
    ......</Contact>
    ....<Contact>
    ............<Telephone>
    ...................<Number>2</Number>
    .............</Telephone>
    ......</Contact>
    ..</Person>
    </data>
    <data>2nd occurence
    ..<Person>
    ....<Contact>
    ............<Telephone>
    ...................<Number>3</Number>
    .............</Telephone>
    ......</Contact>
    ....<Contact>
    ............<Telephone>
    ...................<Number>4</Number>
    .............</Telephone>
    ......</Contact>
    ..</Person>
    </data>
    When 2 records are coming, I need to create 2 IDocs. The field PHONE(0..1) in the second IDoc should get the first 'Number' of 2nd data. Instead it's taking second 'Number' of 1st data.
    Regards,
    Vishal

  • UDF , help needed

    Hi
    It's a file to file scenario. I need to read three input files from the source. I need to generate only one output file. The three input files are Header, Container and Container Item. I have to read two values, say A and B from Header and go to the Container file. Then I have to pick the values C and D from the Container file. These vales, C and D, should correspond to the values of A and B. A and B also appear in the Container file. Now with all these values, I have to go to the Container Item file and read the values E and F, which correspond to the previous set of already read values.
    The values E and F should be sent to the target file. This is the scene !
    How do I use UDFs here ? Can anyone give inputs. I am using BPM and wana do the mapping logic usig BPM
    Harish Babu

    Hi Raja,
    No, we cant use look ups here.
    All files are text files. I need to fetch two values from first file, header. Then with these values you need to go to the second file. From the second file, I need to read two ther values. These values correspond to the first two values. Now after this I go to the third file and read few values and then map two values to output file.
    Each file we need to read values and these values correspond to the values in previous file.
    Ex, I need to read values A and B from first file. Assume the values are 2 and 5, then I go to second file, take the C and D values that have values 2 and 5 in the second file.
    Then go to third file and pick few more values that match with this and map to the target
    Regards
    Harish

  • Java UDF help: Hexadecimal to Chinese Unicode converison

    Hi Experts,
    can someone help me in a design solution to convert Hexadecimal Values to Chinese Characters while sending the data to receiver system.
    I am not able to get any methods in Java to do the conversion.
    Help is appreciated.
    Regards,
    Prakash.

    Hi Grzegorz Glowacki,
    I am sorry this is not working :(.
    Sample input: 4E2D56FD     -->basically this hexavalues are chinese character representation.
    Output for it: ?????????
    +for verification:open Wordpad-->copy the hexcode >select 4chars at a time> hit <altx> and you will get corresponding conversion value.++
    String result = new String();
    try {
      byte[] bytes = new byte[input.length()/4];
        for (int i = 0; i < input.length()/4; i++) {
          byte value = Integer.valueOf(input.substring(i*4,i*4+4), 16).byteValue();
          bytes<i> = new Byte( value );    *//Byte cannot be stored in byte*
        result = new String(bytes, "UTF-16");
    catch (UnsupportedEncodingException e){}
    return result;
    Also this is PI7.0 system. please do help.
    thanks in advance.
    Regards,
    Prakash.
    Edited by: senthilprakash selvaraj on Feb 2, 2012 9:38 AM

  • BigDecimal UDF Help

    Hi all,
    I have a requirement for a UDF:
    Should be of type Context:
    a (Amount goes here from source)           
    b (Posting Key goes here from source)     
    Result list: Goes to Target Amount
    Below is my current code:
    for(int x = 0;x<a.length;x++){
      if (b[x].equalsIgnoreCase("50")){
         float m = Float.parseFloat(a[x]);
         Float n = new Float(m);
         if (m > 0){
           Float q = new Float(-1.0);
           float r = n.floatValue() *   q.floatValue();
           Float s = new Float(r);
           result.addValue(s.toString());
        else {
          result.addValue(a[x]);
       else if(b[x].equalsIgnoreCase("40")){
          float m = Float.parseFloat(a[x]);
         Float n = new Float(m);
          if (m > 0){
           result.addValue(a[x]);
        else {
           Float q = new Float(-1.0);
           float r = n.floatValue() *  q.floatValue();
           Float s = new Float(r);
           result.addValue(s.toString());
    All it does it that if posting key = 50 and amount is > 0 then it multiplies by -1 and adds to result list or if < 0  then adds straight to result list. If posting key is 40 and amount is > 0 then it adds straight to the results or finally if its < 0 then again multiplies by -1.
    Problem is that due to PI having issues with Floats and even though I have applied the SAP note for BigDecimal, I still get erroneous values coming out on large amounts.
    I'm not great at Java and have tried to implement using the BigDecimal Class and its methods to no success (get various compilation errors)
    Please could someone re-write the above UDF but not using Floats but rather BigDecimal??
    I'm sure anyone with half decent skills in Java can do this in no time!
    Many thanks in advance,
    Saqib.

    Hi,
    Ok here is the solution.... It was not because of Float or Double problem. It is something different. Actually java simply changes the large values to precisions.
    To Solve the problem Simply import
    import java.text.DecimalFormat;
    then before all the lines having
    result.addValue
    put this code
    DecimalFormat myFormatter = new DecimalFormat("###,###,#####.##");
    String output = myFormatter.format(s);
    This will solve your problem. If still there is something please revert.
    Regards,
    Jitender

  • Complete-guide on UDFs

    hi
    am basically an Abaper,i need complete guide from basics of how to write udfs in xi,with screen shots if possible.....
    points will be awarded for helpfull answers
    regards
    chandrakanth.k

    Hi,
    UDF STEPS *
    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.
    Check this for UDF's
    UDF Links *
    http://java.sun.com/j2se/1.5.0/docs/api/
    /people/krishna.moorthyp/blog/2006/07/29/documentation-html-editor-in-xi
    /people/sap.user72/blog/2006/02/06/xi-mapping-tool-exports
    http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
    UDF -
    http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm
    + UDF Help +
    http://help.sap.com/saphelp_nw04/helpdata/en/d9/718e40496f6f1de10000000a1550b0/content.htm
    regards,
    Kishore

  • Characters such as apostrophes and smart quotes turning into boxes or question marks

    We recently upgraded from CF5 to CF7 and are having a problem
    with previously saved text that no longer displays correctly. Some
    characters (apparently, non-ASCII characters such as curly
    apostrophes and smart quotes) are rendering as boxes or question
    marks. We recently upgraded to Oracle 10g from Oracle 8i, but this
    problem appears to be independent of the database that the text is
    stored in. Here is sample code that will illustrate the problem:
    <CFSET string1="Department’s">
    <CFSET string2="hey—there">
    <CFOUTPUT>
    string1 is #string1#
    <BR>
    string2 is #string2#
    </CFOUTPUT>
    output looks like this:
    string1 is Department?s
    string2 is hey?there
    These are rendered as boxes when viewed in Internet Explorer.
    (They show up as question marks when I copy and paste them here.)
    The Demoronize UDF helps *some* of the time, but this is
    still happening with a lot of text, especially text that gets
    pasted from a website into a form, then saved to a database. Does
    anybody have a solution for this? This is breaking my applications
    and is incredibly annoying. I'd like to either replace the
    problematic characters at the time they are displayed, or replace
    them when they are input in the database in the first place (and go
    back and update all the previously saved data to replace the
    problematic characters with plain text equivalents).
    Any suggestions appreciated.

    I finally isolated the problematic characters so I edited the
    DeMoronize UDF (available at cflib.org) by adding the following
    text replacements at the bottom:
    text = Replace(text, chr(8208), "-", "ALL");
    text = Replace(text, chr(8209), "-", "ALL");
    text = Replace(text, chr(8210), "&ndash;", "ALL");
    text = Replace(text, chr(8211), "&ndash;", "ALL");
    text = Replace(text, chr(8212), "&mdash;", "ALL");
    text = Replace(text, chr(8213), "&mdash;", "ALL");
    text = Replace(text, chr(8214), "||", "ALL");
    text = Replace(text, chr(8215), "_", "ALL");
    text = Replace(text, chr(8216), "&lsquo;", "ALL");
    text = Replace(text, chr(8217), "&rsquo;", "ALL");
    text = Replace(text, chr(8218), ",", "ALL");
    text = Replace(text, chr(8219), "'", "ALL");
    text = Replace(text, chr(8220), "&ldquo;", "ALL");
    text = Replace(text, chr(8221), "&rdquo;", "ALL");
    text = Replace(text, chr(8222), """", "ALL");
    text = Replace(text, chr(8223), """", "ALL");
    text = Replace(text, chr(8226), "&middot;", "ALL");
    text = Replace(text, chr(8227), "&gt;", "ALL");
    text = Replace(text, chr(8228), ".", "ALL");
    text = Replace(text, chr(8229), "..", "ALL");
    text = Replace(text, chr(8230), "...", "ALL");
    text = Replace(text, chr(8231), "&middot;",
    "ALL");

  • Combining Multiple occurrencesof the same field value into one and Sum prob

    Hi
    I am trying to combine the multiple occurrences of the field values and sum the amount to the target
    Source
    <Record>
    <Item>
    <Item1>1</item1>
    <item2>2</item2>
    <item3>3</item3>
    <item4>4</item4>
    <Amount1>5</Amount1>
    <Amount2>5</Amount2>
    </Item>
    <Item>
    <Item1>1</item1>
    <item2>2</item2>
    <item3>3</item3>
    <item4>4</item4>
    <Amount1>15</Amount1>
    <Amount2>15</Amount2>
    </Item>
    <Item>
    <Item1>1</item1>
    <item2>2</item2>
    <item3>3</item3>
    <item4>4</item4>
    <Amount1>5</Amount1>
    <Amount2>5</Amount2>
    </Item>
    </Record>
    Target
    <Record>
    <Item>
    <Item1>1</item1>
    <item2>2</item2>
    <item3>3</item3>
    <item4>4</item4>
    <Amount1>25</Amount1>
    <Amount2>25</Amount2>
    </Item>
    </Record>
    I am using MM at present. All fields are KeyFields here. Should check against each other.
    I followed Context setting to the Root Item and Sort, SplitByValue and CollapseContext to achieve the functionality.
    But it checks against each field and not all fields. So either one field has different value, only that perticular field gets into New Node and not the entire record. In this case, i might need UDF i guess. Any UDF help is much appreciated
    Bad Target example of what i am getting
    Source
    <Record>
    <Item>
    <Item1>1</item1>
    <item2>2</item2>
    <item3>3</item3>
    <item4>4</item4>
    <Amount1>5</Amount1>
    <Amount2>5</Amount2>
    </Item>
    <Item>
    <Item1>1</item1>
    <item2>2</item2>
    <item3>3</item3>
    <item4>4</item4>
    <Amount1>15</Amount1>
    <Amount2>15</Amount2>
    </Item>
    <Item>
    <Item1>2</item1>
    <item2>2</item2>
    <item3>3</item3>
    <item4>4</item4>
    <Amount1>5</Amount1>
    <Amount2>5</Amount2>
    </Item>
    </Record>
    Target
    <Record>
    <Item>
    <Item1>1</item1>
    <item2>2</item2>
    <item3>3</item3>
    <item4>4</item4>
    <Amount1>25</Amount1>
    <Amount2>25</Amount2>
    </Item>
    <Item>
    <Item1>2</Item1>
    </Item>
    </Record>
    In the above scneario, only Item1 returns the value into different node. But i like to have entire node values into the record, if one value changes in the entire record.
    Appreciate your help with the UDF in advance
    </Record>

    I think you are looking for string aggregation.
    The following are the replies posted by me in the forum recently on the same case.
    they might help you.
    Re: Concatenating multiple rows in a table - Very urgent - pls help
    Re: Doubt in a query ( Urgent )
    Re: How to remove words which consist of max 2 letters?
    Re: output like Name1,Name2,Name3...

  • Need Help in writing a UDF

    Hi,
    Please help in writing a UDF for these fields in mapping, which I need for the object Iu2019m doing currently.
    The fields are like this:
    1)         batch_no = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/5000)+1",
    2)         lot_id = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/500)+1",
    3)        How to use JDBC connection factory class in the UDF.
    Some logic I can provide which I know i.e. Power (2, 28) means 2 to the power of 28 (2 multiplied 28 times), Trunc means truncate, X_TXN_SAP_Parts is a database table.The Target fields are Batch_no, lot_id & Objid.Actually, objid is mapped initially to a source field i.e. Object ID and in this function it is only being used for the calculation of the batch_no.
    Thanks in Advance,
    Sreedhar.

    Hi,
    Following with my query I've tried to use this code but still I'm unable to execute the mapping.
    import java.util.*;
    import com.sap.aii.mapping.lookup.*;
    import com.sap.aii.mapping.lookup.*;
    DataBaseAccessor accessor = null;
    DataBaseResult JDBCOutPayload = null;
    String BusinessSystem="clarify_dev_bizsys";
    //give your business system having channel name
    String CommunicationChannel="JDBC_TO_CDEV";
    //give your channel name
    String InputPayload= " select X_TXN_PRE_SITE_XFACE.nextval from dual;";
    //give your sql query
    try {
    Channel channel =
    LookupService.getChannel(BusinessSystem,CommunicationChannel);
    accessor = LookupService.getDataBaseAccessor(channel);     
    DataBaseResult resultSet = accessor.execute(InputPayload);
         for(Iterator rows = resultSet.getRows();rows.hasNext();){  
         Map rowMap = (Map)rows.next();
         Object cValue = rowMap.get("batchno");
    //field name of field required , as in database
          catch (Exception e) {}
          finally {
                  if (accessor != null)
                  accessor.close();
           result.addValue((String)cValue);
    --> I don't know what are the parameters to be used and how to be used in the UDF because this is the first time I'm writing a UDF.
    --> The problem in using this query is that both OBJID & BatchNo. are on the target side and the value for the OBJID is retrieved by a SELECT query from the database.
    Kindly help me how to resolve this query of mine.
    Thanks in Advance.
    Sreedhar.

  • Mapping Problem . or help in UDF

    Hi...
          I am having problem in mapping.
    I am having 3 messages in the source structure and 1 message in the target structure. 3:1 mapping.
    Source Messages:
    Message1: Warehouse Details(plant name,warehouselocation)
    Message2:Supplier Details(suppid,suppname,leadtime,matname,cost)
    Message3:Input(matname,plant,unit,item,itemname,ReqQty,OrderQty,Cost,suppid,suppname,leadtime,date,warehouseloc)
    Target Message:
    Output
    If the Availability field in Message3 !=0, then it should map warehouseloc of message 1 to the Output mesage. or else it should map 0 to the warehouse and map message 2 items to the output message.
    Source messages are 0:unbounded.
    Could you please help me out in this issue. or else can you please tell how to write the userdefined function for that.
    Below is the structure.
    Source Message:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
       <ns0:Message1>
          <ns1:getWareHouseDetailsResponse xmlns:ns1="http://DefaultNamespace">
             <getWareHouseDetailsReturn>
                <Plant>
                   <plantName/>
                   <wareHouseLocation>W001</wareHouseLocation>
                </Plant>
             </getWareHouseDetailsReturn>
          </ns1:getWareHouseDetailsResponse>
       </ns0:Message1>
       <ns0:Message2>
          <ns2:GetPreferredSuppliersResponse xmlns:ns2="http://tempuri.org/">
             <ns2:GetPreferredSuppliersResult>
                <ns2:Supplier>
                   <ns2:SupplierId>S001</ns2:SupplierId>
                   <ns2:SupplierName>TRW</ns2:SupplierName>
                   <ns2:LeadTime>1111</ns2:LeadTime>
                   <ns2:MaterialName>M001</ns2:MaterialName>
                   <ns2:Cost>1000</ns2:Cost>
                </ns2:Supplier>
             </ns2:GetPreferredSuppliersResult>
          </ns2:GetPreferredSuppliersResponse>
       </ns0:Message2>
       <ns0:Message3>
          <ns3:MT_Output xmlns:ns3="http://BlockTest">
             <Material>
                <Matname>M001</Matname>
                <Plant>P001</Plant>
                <Unit>KG</Unit>
                <Item/>
                <Itemname/>
                <ReqQty>5</ReqQty>
                <AvailQty>0</AvailQty>
                <Cost/>
                <Suppid/>
                <Supname/>
                <LeadTime/>
                <Date>12.05.2008</Date>
                <OrderQty>0</OrderQty>
                <WarehouseLoc/>
             </Material>
             <Material>
                <Matname>M002</Matname>
                <Plant>P002</Plant>
                <Unit>PC</Unit>
                <Item/>
                <Itemname/>
                <ReqQty>5</ReqQty>
                <AvailQty>5000</AvailQty>
                <Cost/>
                <Suppid/>
                <Supname/>
                <LeadTime/>
                <Date>12.05.2008</Date>
                <OrderQty>0</OrderQty>
                <WarehouseLoc/>
             </Material>
             <Pcost/>
             <Tcost/>
             <Ocost/>
          </ns3:MT_Output>
       </ns0:Message3>
    </ns0:Messages>
    Target Message:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
    <ns0:Message1>
    <ns3:MT_Output xmlns:ns3="http://BlockTest">
    <Material>M001</Material>
    <Plant>P001</Plant>
    <Unit>KG</Unit>
    <Item></Item>
    <Itemname></Itemname>
    <ReqQty>5</ReqQty>
    <AvailQty>0</AvailQty>
    <Cost>1000</Cost>
    <Suppid>S001</Suppid>
    <Supname>TRW</Supname>
    <LeadTime>1111</LeadTime>
    <Date>12.05.2008</Date>
    <OrderQty>0</OrderQty>
    <WarehouseLoc>0</WarehouseLoc>
    </Material>
    <Material>M002</Material>
    <Plant>P002</Plant>
    <Unit>KG</Unit>
    <Item></Item>
    <Itemname></Itemname>
    <ReqQty>5</ReqQty>
    <AvailQty>0</AvailQty>
    <Cost>1000</Cost>
    <Suppid/>
    <Supname/>
    <LeadTime/>
    <Date>12.05.2008</Date>
    <OrderQty>0</OrderQty>
    <WarehouseLoc>W001</WarehouseLoc>
    </Material>
    </ns3:MT_Output>
    </ns0:Message1>
    </ns0:Messages>
    Edited by: leelaratnam morampudi on Oct 14, 2008 1:13 PM

    I think there is no need to use UDF, you can achive this by using IF function.
    to make your mapping simple, in your message mapping on MT_Output, right click your mouse and click on duplicate subtree. you will now have two structure in your target.
    first one is for if AvailQty != 0 then warehouseloc of message 1 to the Output mesage
    and second one is for if AvailQty = 0 now map 0 to the warehouse and map message 2 items to the output message.
    try this and let us know if you face any issues.

Maybe you are looking for

  • Error While Inserting Data into table using OAF

    Hi Experts, I am learning OAF; i am trying into insert the data into table using OAF. I followed the below procedure. My table(OLF_TEST_TBL) Columns: EmpID (Number), Ename(VARCHAR2 100), Sal Number, and who columns. 1. created Application Module (AM)

  • Can see files on Mac Mini from Macbook Aire on same network

    I can see the MacMini in the side bar from the Air but when I click through i can only see the public folders.  I have File Sharing checked in the System Preferences so I dont understand why i cannot see the files on the mini.  I can only see the dro

  • Where can i find the TRACKING NUMBER on my macbook pro?

    before i bought my mbp, i was told that i should write down its tracking number in case it got stolen. where do i find it?

  • Viewing videos on pc

    Hi I just got an Xperia Z2, shot videos in normal mode, 4k and Timeshift. I can see them perfectly on the phone but when I transfer them to my PC they are very low quality, pixelled and unnatural. I tried QuickTime, MPC-HC (x64) and VLC Media Player.

  • Crystal XI

    Is there a way to take a Crystal XI report and open it in Crystal 8.5?