User define function-remove leading zeros

Hi All,
i want java coding for mapping function rule "remove leading zeros" early.
kindly give me response as early as possible.
regards
Peera

Hi  Mahaboob
Write UDF to parse data .
String dataVal="0230";
int parseVal = Integer.parseInt(dataVal);
System.out.println("parseVal is "+parseVal);
result.addValue(parseVal); or return parseVal;
Have a look at this thread...
Re: User-defined function in multiple Message Mappings
http://help.sap.com/saphelp_erp2005/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/22/e127f28b572243b4324879c6bf05a0/frameset.htm
Thanks !!!

Similar Messages

  • Remove leading zeros using MDX function

    Hello,
    BO XI R3.1 SP2 FP2.5, SAP BW 7.0
    This seems simple, but I cannot find a solution.
    How do I remove leading zeros from a character field in a OLAP universe. Is there any MDX function?
    I tried
    <EXPRESSION>
    Value([0MATERIAL].[LEVEL01].[[20MATERIAL]].[Value])
    </EXPRESSION>
    <EXPRESSION>
    StrToValue([0MATERIAL].[LEVEL01].[[20MATERIAL]].[Value])
    </EXPRESSION>
    I can remove the leading zeros in Webi, but we require it for ad-hoc reporting? Is there a way to do this in the universe?
    Thanks,
    Nikhil

    Hi,
    SAP BW MDX only allows calcuated expressions that return numeric values: this is one if the main SAP MDX limitations.
    By the way there is the abilitiy to return string only for those expressions:
    [Dimension].currentmember.name
    [Dimension].currentmember.uniquename
    So you can do this:
    <EXPRESSION>
    (right([0MATERIAL].currentmember.name, 4))
    </EXPRESSION>
    <EXPRESSION>
    (right([0MATERIAL].currentmember.uniquename, 4))
    </EXPRESSION>
    <EXPRESSION>
    (left([0MATERIAL].currentmember.name, 3))
    </EXPRESSION>
    <EXPRESSION>
    (left([0MATERIAL].currentmember.uniquename, 3))
    </EXPRESSION>
    Otherwise you can use WebI formulas as described in the thread.
    Regards
    Didier

  • Function mudule to remove leading zeros of curreny and decimal type field

    Hi Expers,
    can any body suggest me the function mudule to remove leading zeros of curreny and decimal type  fields.
    plz do reply as early as possible.
    Thanks .....
    sunil.

    Hi,
    Use this FM CNIF_CONVERT_CURRENCY2EXT
    Import parameters               Value
    I_CURRENCY                      USD
    I_AMOUNT                        00000001233
    I_DECIMALS                      2
    Export parameters               Value
    E_AMOUNT                                           1.233,0000
    Regards
    Shiva

  • Function module to remove leading zeros

    hi,
       is der any functional module to remove leading zeros
    thanks and regards
    Nikesh kumar

    Hi,
    You can use the <b>FM CONVERSION_EXIT_ALPHA_OUTPUT</b> and if you want to do in program do as below :
    shift <fieldname> left deleting leading '0'.
    Thanks,
    Sriram Ponna.

  • To remove leading zeroes and take directly from IDOC(Segment field) to file

    Hi SapAll.
    i have got a simple requirement in a idoc to file Interface.
    here in a sender Idoc there will be one segment with one field,the requirement is to remove leading zeroes and take directly the data from this field and map to one of the field in  reciever  file structure.
    i had used the formatnumber (under arithmatic functions)in PI 3.0 but now when iam using it in PI7.1 it was raising some jave exception error.
    it would be preferable if any body can give me the solution without user defined functions.
    regards.
    Varma.

    from your first post:
    i had used the formatnumber (under arithmatic functions)in PI 3.0 but now when iam using it in PI7.1 it was raising some jave exception error.
    use the same formatting that you used in 3.0 .... try with just a # in the FormatNum function.
    Regards,
    Abhishek.

  • Removing Leading zeros from query output.

    Hello Experts,
    Is it possible to remove leading zeros from the query output for a particular column?
    I have a characteristics 'Reference Document' which has values like '000001386'. The users just need '1386' to be displayed and have asked us to remove the leading zeros.
    Is there something that can be done for this at a query level? I can't modify the underlying InfoProvider because this requirement is just for one set of users, the other users need the document nmber in the original format.
    Thanks
    Arvind

    Hi,
    you can use ALPHA conversion option in the definition of that particular characteristic.
    Try this code  in a routine.,in query designer;
    data a(9) value '000001386'.
    SHIFT a LEFT DELETING LEADING '0'.
    write:/ a.
    Output will be : 1386
    Or use this method also
    data a(9) value '000001386'.
    Call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
    Exporting
    input = a
    Importing
    output = a.
    write a.
    output:
    1386
    Regards
    CSM Reddy

  • Determine Element maxLenght in User-Defined Function

    Hi,
    I have the problem, that I have to fill up several fields with leading 0. I wrote a User-Defined Function for this. But the function doesn't know how long this element is, so I have to give the function the length of the element.
    Is it possible to determine the length of the current element in an extended User-Defined Function
    Yours
    Thomas

    Hi,
    >use a simple user defined function with the desired
    >source element as input and give the following code...
    >int k = a.length();
    >String len = Integer.toString(k);
    >return len;
    That function will only give me the actual lenght of the input element, what I need is the max lenght of the target element...
    >You can also use the built-in FormatNumber function to
    >insert leading 0s.
    How can I use this function to add leading zeros?
    "'000'#" ? But there I have to do this for every element
    >I think an easy solution for this is, just have a
    >simple function with two arguments. The first is the
    >element, the second is a constant, where you put the
    >length.
    Well I have this function. But I am looking for way to the safe the second argument ;o)
    Thank you all for your help
    Thomas

  • Add and remove leading zeroes

    Hi all,
           Iam having a requirement where in a enduser enters the vendor number and after pressing enter key it should display the vendor num along with vendor name concatenated in the same field. But the end user is provided the facility that he may not enter the exact vendor number ( I mean if vendor number is for example 0000055,  the enduser may enter simply 55). The system should convert it with leading zeroes internally. And in display it should display removing leading zeroes.
    like     input:  55              output : 55 Vendor_Name
    my approach
    iam using conversion_exit_alpha_input    for adding leading zeroes       before select query ( to fetch the vendor name for vendor number the user supplies)
    before displaying the output after concatenation,
    iam using  conversion_exit_alpha_output.
    after execution,
    it is asking the exact vendor number .  But in the output, it is giving the vendor number along with vendor name by removing leading zeroes ( as expected).
    how to make the system accept the number without leading zeroes. please suggest me.
    tthanking you in advance
    regards
    Bikash

    Hi Bikash,
    Since you have to display the Vendor number concatenated along with the Vendor Name, why do you need to use the Alpha Exit Function Module. As you have the Vendor number without the zeros in the input field, you can store it in a temporary variable and then once the Vendor name is available you can concatenate it along with the number in the same field.
    If you need a code snippet, you can provide the Technical details of the fields of input. We can use the implicit ABAP    type casting feature to get the Vendor Number without any leading zeros.
    Hope this helps.
    Thanks,
    Samantak.

  • Error while using user defined function in reports

    Hi,
    When I use the below user defined function in oracle reports I got the wrong number of arguments error
    select test_function(id,a_number,v_date-14,b_number) from dual;
    If I remove -14 from the argument it works. But iIneed to subtract 14 days from the date.
    Thanks for your help.

    select test_function(id,a_number,v_date-14,b_number) from dual;
    you have to give the command like this to_date(v_date,'dd-mon-yyyy')-14
    because the v_Date you choose in the parameter form is not having the corrent date format
    the format dd-mon-yyyy is the format in which v_date is passed by the user.

  • User-Defined Function and Context Manipulation

    Hi Mapping Gurus, I need your help.
    I have a user-defined function and one of my input parameter (c) is in a loop (EDI segment).  So one, if I execute my function I get:
    Exception:[java.lang.ArrayIndexOutOfBoundsException: 0]
    If I change the context or use the remove context node function it’s working but it’s always taking the first row in consideration since I'm using c[0] .  Here is the logic:
    String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[0]"'";
    So since c is an array [], I have tried different logic to get to the right row.
    1- I tried using another parameter (e) to pass a counter or an index to my function.  So each time it's looping, it's passing a new value to the function but I’m still getting the first row and I’m not to sure why?
    int G = Integer.parseInt(e[0]);  // e[] = My counter field
    String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
    2- I tried using a parameter stored in the container:
    String Num;
    Num = (String)getParameter(“counter”);
    if (Num == null)  G = 0;
    else
    G = Integer.parseInt(Num);
    G = G + 1;
    String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
    Num = "" + G;
    setParameter(e[0], Num);
    and I’m still getting the first one, look like it’s using a different container each time it’s looping so the Value is always the same?
    4- I created a new user-defined function with the container logic, then it’s working but I’m back to the same problem in my main function, it’s only looking at e[0] for my counter all the time.
    5- I tried using the Seeburger Java Variables and guess what in the main fonction, as new UDF,... and guess what, same result!
    So anybody out there that was able to get UDF's working into a multiple context scenario?
    Am I missing something?
    I will reward points and beer for any help!

    This is one of the text with passing a counter to the function to try to go to the right row in the array since I'm doing a remove context and I'm getting all the d_234's:
    public void ReadTable(String[] a,String[] b,String[] c,String[] d,String[] e,ResultList result,Container container){
    int G = Integer.parseInt(e[0]); // My counter
    String var;
    String DBTABLE = a[0];
    String lookUpField = d[0];
    String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
    Now this one was with the internal container logic:
    int G;
    String DBTABLE = a[0];
    String lookUpField = d[0];
    String Num;
    Num = (String)getParameter(e[0]);
    if (Num == null)  G = 0;
    else
    G = Integer.parseInt(Num);
    G = G + 1;
    Num = "" + G;
    setParameter(e[0], Num);
    String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
    And now with the Seeburger Variables:
    int G;
    try {
    VariableBean be=VariableFactory.getVariableInstance("");
    G = Integer.parseInt(String.valueOf(be.getStringVariable("yves")));
    } catch (Exception f) {
    throw new RuntimeException(f);
    String DBTABLE = a[0];
    String lookUpField = d[0];
    String WHERE_CLAUSE = "A"" = ""'"b[0]"'"" and B = ""'"c[G]"'";
    try {
    G = G + 1;
    Num = "" + G;
    VariableBean be=VariableFactory.getVariableInstance("");
    be.setStringVariable("yves",Num);
    catch (Exception f) {
    throw new RuntimeException(f);
    All 3 logics were returning always the first row or a counter of 1 if the logic is in the main ReadTable function.

  • User defined function to find difference between dates

    format of dtActivityStartDate/dtActivityFinishDate: 2010-09-17 14:50:51.150
    usdFuncTimeCalc (vcActivityName,dtActivityStartDate, dtActivityFinishDate) -- user defined function
    i need to calculate time elapsed for that type of activity following are the rules:
    (If Process Request is the activity)
    Working Days: Monday through Saturday
    Hours of Operation: 9AM – 5PM
    only working hours of day need to the counted like for example if it is sep 15 11 Am is dtActivityStartDate & Sep 17 is dtActivityFinishDate is 10 Am. then time elapsed is 11am to 5pm on sep 15 , 9 to 5 on sep 16 & 9 to 10 on sep 17 so total should be
    6+ 8 + 1 = 15 hours + minutes.
    format of date time: 2010-09-17 14:50:51.150
    vcActivityName = Process Request
    Don't worry about process request...

    I hv modified the code to make it more generic inorder to suit any timings (customizable) from Monday - Saturday.
    declare
      -- ** b u s i n e s s _ h o u r s **
      -- business_hours returns the number of work houts (9 am through 5 pm,
      -- Monday through Saturday) between in_start_dt and in_end_dt.
      -- If in_start_dt > in_end_dt, the results will be <= 0.
      -- Holidays are not considered.
      in_start_dt DATE := to_date('15-SEP-2010 11:00:00','DD-MON-RRRR HH24:MI:SS');
      in_end_dt   DATE := to_date('17-SEP-2010 10:00:00','DD-MON-RRRR HH24:MI:SS');
      d          NUMBER; -- Hours of either start_dt or end_dt after midnight
      end_dt     DATE := GREATEST(in_start_dt, in_end_dt); -- In case dates were in wrong order
      return_val NUMBER; -- Total number of working hours
      start_dt   DATE := LEAST(in_start_dt, in_end_dt); -- In case dates were in wrong order
      start_time number := 9;
      end_time   number := 17;
    BEGIN
      WITH all_days AS(
        SELECT start_dt + LEVEL - 1 AS a_dt
          FROM dual
        CONNECT BY LEVEL <= 1 + TRUNC(end_dt) - TRUNC(start_dt))
          --SELECT SUM(12)
           SELECT SUM(end_time-start_time)
            INTO return_val
            FROM all_days
           WHERE TO_CHAR(a_dt,'Dy','NLS_DATE_LANGUAGE = ''ENGLISH''') NOT IN ('Sun');
      dbms_output.put_line('Return_Val_1 : '||return_val);
      -- Adjust hours from start_dt, if necessary
      IF TO_CHAR(start_dt, 'Dy', 'NLS_DATE_LANGUAGE = ''ENGLISH''') NOT IN ('Sun') THEN
         -- Calculate nbr of hours passed from midnight
         d := 24 * (start_dt - TRUNC(start_dt));
         dbms_output.put_line('d:'||d);
         IF d >= end_time THEN -- d has passed 5 PM (end_time)
            -- Don't count start_dt if it has passed the closing hours
            return_val := return_val - (end_time-start_time);
            dbms_output.put_line('if-d:'||return_val);
         ELSIF d > start_time and d < end_time THEN -- d has passed 9 AM but less than 5 PM
            -- Don't count the part of start_dt which has passed the opening hours
            return_val := return_val - (d - start_time);
            dbms_output.put_line('else-d:'||return_val);
         END IF;
      END IF;
      dbms_output.put_line('');
      dbms_output.put_line('Return_Val_2 : '||return_val);
      -- Adjust hours from end_dt, if necessary
      IF TO_CHAR(end_dt, 'Dy', 'NLS_DATE_LANGUAGE = ''ENGLISH''') NOT IN ('Sun') THEN
         d := 24 * (end_dt - TRUNC(end_dt));
         dbms_output.put_line('d:'||d);
        IF d <= 9 THEN -- d < 9 AM
           -- Don't count end_dt itself
           return_val := return_val - (end_time-start_time);
           dbms_output.put_line('if-d:'||return_val);
        ELSIF d > start_time and d < end_time THEN -- d > 5 PM
          -- Don't count part of end_dt
          return_val := return_val - (end_time - d);
          dbms_output.put_line('else-d:'||return_val);
        END IF;
      END IF;
      dbms_output.put_line('');
      dbms_output.put_line('Return_Val_3 : '||return_val);
      IF in_start_dt > in_end_dt THEN
          return_val := -return_val;
      END IF;
      dbms_output.put_line('');
      dbms_output.put_line('Return_Val_4 : '||return_val);
    END;Plz note the following points of the code :
    1) You'll need to convert it a function, I just made it a declare..begin..end; block.
    2) I hv used the same timings for start & end as you hv mentioned.
    3) The 2 variables "start_time" and "end_time" take the opening & closing business hours respectively in a 24 hour format.
    4) You might want to remove the DBMS_OUTPUT ... stmts which I had added for debugging.
    It was an interesting code block to analyze ... :-)

  • XmltoQuery removing leading zero

    Hi,
    I have a function that takes in a raw xml and covert to query.  The problem is any leading zeroes are gone.  For example, 000123 will become 123.  Is there any way or function in CF that will stop from removing leading zeroes?
    Thanks,

    Oh, sorry.  It's not the XML to Query problem but it's the cfquery problem.  When I cfdump the data, it shows 000123, but when I use <cfquery> to insert the data into a dabase, it strips the leading zeroes and in the db table it shows only 123.  Is there a function or something to prevent this?
    <cfoutput query="get_xml_data">
    <cfquery name="test" datasource="db">
         INSERT INTO table (id, name)
         VALUES (#get_xml_data.id#, #get_xml_data.name#)
    </cfquery>
    </cfoutput>

  • Remove leading zeros in report

    Hi all,
    I do a clasical reoporting. Data in the internal table numeric types. But when writing in the report, is appearing as 000056 etc. I want to remove this leading zeros in the report output. Any helps?
    Regards,
    Mic.

    Hi Michael,
         u can use the function module for removing leading zeros
          CONVERSION_EXIT_ALPHA_INPUT (adding zeros)
          CONVERSION_EXIT_ALPHA_OUTPUT (removing zeros)
    Regards
    Nagesh

  • How to remove leading zero from Material Number

    Hello Everyone,
    I need to figure it out how to remove leading zero from material number. Cureently extractor is sending material number as 100663. But when comes into BI i am getting as "000000000000100663" and similariy in report it is appearing as "000000000000100663". Now my client wants me to exclude preceeding zero for a material in all the reports.
    Is there any setting in query desinger to handle this issure or in the backend.
    Need your inputs.
    Thanks,
    Lasya.

    Hi
    you can use the function Module
    CONVERSION_EXIT_ALPHA_OUTPUT in the start routine
    to test this go to SE37  --- give the CONVERSION_EXIT_ALPHA_OUTPUT -
    >display -
    > F8
    in the input give 000000456
    and execute
    the out put will be 456
    for getting Zeros you can use
    CONVERSION_EXIT_ALPHA_INPUT--- to remove leading zeros
    Santosh
    Edited by: Santhosh Nagaraj on Oct 29, 2009 10:52 PM
    Edited by: Santhosh Nagaraj on Oct 29, 2009 10:54 PM

  • To remove leading zeros

    hi,
    how to remove leading zeros. can anyone suggest

    Hi ,
    U can either use this function module also
    CONVERSION_EXIT_ALPHA_OUTPUT
    or
    SHIFT <yourField> LEFT DELETING LEADING '0'
    or
    try NO-ZERO option of WRITE statement
    or
    Another way is to create another variable of type I and assign the value into it
    example:
    DATA: L_NUMC(08) TYPE N.
    DATA: L_INT TYPE I.
    L_NUMC = '00000018'.
    L_INT = L_NUMC.
    Result will be = 18.
    Hope this helps
    Regards,
    Prasanth
    Reward all the helpful answers

Maybe you are looking for

  • Error message: The procedure entry point sqlite_3wal_checkpoint could not be located in the dynamic link library SQLite3.dll.

    I get the error message when I boot up: The procedure entry point sqlite_3wal_checkpoint could not be located in the dynamic link library SQLite3.dll. This happended after I downloaded latest version of I Tunes and Safari. How do I fix it?

  • Trouble with iCloud Contacts & Calender / duplicates from system failure

    Duplicates do appear on iPad Contacts and even duplicate birthday entries. Even on iCloud.com the birthday entries are duplicate. The problem is when you delete a duplicate contact on iPad you lose both! Check on iCloud.com if the contact is really a

  • Why is the photo quality poor when view on TV?

    Before I burn a slideshow on a dvd I check to see the quality of my images and they look perfect on my mac however, the quality is greatly reduced when I watch a photo slideshow on a TV. This has occurred for one than 1 tv also (all pretty new). Any

  • Inspoke data logic

    Hi all, I have created an Ispoke which is getting the data from an infocube and feeding the data to a flat file. The number of records transferred from infocube to Ispoke are not same. For example, infocube is getting 16 records and Ispoke is getting

  • GLOBAL ATP WITHOUT APO

    When I was at Sapphire in 2007, SAP demo'd a global ATP from within SD that utilized enhancement pack 1 or 2. Now I need to implement something like this, without using APO. However, I can't find any references to in through Enhancement Pack 3 (our c