UDF for leading zero's in message mapping

Dear team,
I need UDF for leading zero's in my message mapping.
Source and Target both structures contains matnr field.But we have to maintain total 18 chars at target matnr , because RFC in R/3 needed.So I want to add leading zero's when mapping. Can anybody provide the UDF code.
Matnr[source]--->split by value(eachvalue) ->UDF->Matnr[Target]
Ex::if source matnr conatains value "9846538" ; I need matnr value at target side like "000000000009846538"[total 18 chars].
-Drumi

Hi Ambrish,
Good day...
I have enterd what you said and I got below error... and I gave "input" in place of var1, 18 in place of filedlenght in below program...
=================================
int len = Integer.parseInt(18);
int inputLength = input.length();
try {
Integer.parseInt(input);
// If it is an integer, add 0 (len - inputLength) times
for (int i=0; i< len-inputLength;i++)
    input = "0" + input;
return input;
} catch (NumberFormatException numForEx) {
// return as it is, if alphanumeric
return input;
====================================
ERROR:
Source text of object Message Mapping: Lubrisur_SHPMNT_SHPMNT05_TO_WMMBXY_WMMBID02_TransferPosting | urn:bp:xi:dwn:lu:common:Logistics:100 has syntax errors:
Function LeadingZeros, Line 1:
cannot find symbol symbol  : method parseInt(int) location: class java.lang.Integer int len = Integer.parseInt(18);                  ^ 1 error
=======================
Please suggest

Similar Messages

  • Adding leading zeros in a field mapping

    Hi,
    I am getting account as a 5 char field in the input file. I need to map this to a 10 char field in XI and add leading zeros in case the value is all numeric. Is there any standard data type/ mapping that can achieve this or I need to write a UDF.
    Thanks,

    formatNum field will cause an exception if your input isnt all numeric...
    I'd go for UDF id your input isnt always numeric.
    Regards,
    Henrique.

  • UDF for padding zeroes

    Hi
    I need a UDF Code for the following requirement ,which is used in various fields across a lot of mappings
    Requirement is that if it is a fixed length file and the field length is 10 then whatever value thats coming should be right alligned and there shud be zeroes padded to the left of it
    for e.g
    field length is 10
    input value os 3456
    then the output should be 0000003456
    I want to make it a generic function wher i can take the field length and the input value as inputs
    Dev

    Hi,
    You can edit my function. What you can do is send the length as one input and then it should work. Add this code:
    Create a value udf with two input arguments a and input. Then add this code:
    Imports:  java.*;
    int len=input.length();
    int b = Integer.parseInt(a);
    for(int i=0; i<b-len;i++)
    input="0"+input;
    return input;
    Here pass the total length of the field in first argument and then send the input value to teh second argument. Then it should work for you.
    Regards,
    ---Satish

  • UDF to get the systemdetails in message mapping

    Hi,
    Written a UDF to get a system details, iam getting the systemid with "System.getProperty"
    Bases on the system id returned, i must pass the values.
    By using the below UDF, iam getting error.
    public String Get(Container container){
    //write your code here
    String sysName = (String) System.getProperty("SAPSYSTEMNAME");
    if ( 'DEV' .equals(sysName) )
    sysName  =  "DEVCLNT120";
    elseif ( 'QA' .equals(sysName) )
    sysName  =  "QACLNT120";
    return sysName;
    Please anyone can help me incorrecting the above UDF.
    Thanks
    Srinivas

    You have not mentioned what error, but i think the error ur getting is because of the single quotes on 'DEV'- i tried a simple udf in my XI system and it worked.
    String sysName = (String) System.getProperty("SAPSYSTEMNAME");
    if ("XID".equals(sysName))
    return "XIDCLNT100";
    else
    return sysName;

  • Add leading zero's function

    Hey,
    can anyone tell me what is the java function for add leading zero's in xi mapping.
    TX

    Hi Zevik,
    As other threads mentioned used FormatNum and double click and put Zeros. Like if the lenght is 10 then put 10 zeros. Here one thing you should analyse is, if your input value has a string value it will fail in FormatNum becuase it expects only the numeric value.
    So if you dont know whether your input has numeric or alphanumeric then go to UDF. So create a udf with name AddZeros and as Value with one argument as input.
    Imports:  java.*;
    Then add this code:
    int len=input.length();
    for(int i=0; i<10-len;i++)
    input="0"+input;
    return input;
    Here I am assuming the total length is 10. If yours is 20 then put 20 instead of 10 in the second line of the code.
    Regards,
    ---Satish

  • Need to add leading zeros to the field if field length is less than 6

    Actually the field length is 16.
    But for some manual entries it is comming as 4 chars.
    so if field length is less than 6 then it should be replaced by leading zeros.
    Moderator message: very basic, please (re)search yourself before asking, @all: please do not reply to basic questions, points removed.
    locked by: Thomas Zloch on Sep 9, 2010 11:43 AM

    Hi Ravi,
    Do it in 2 steps.
    1. check the length of your entry by strlen function and get the length.
    2. If the output is less than 6 call the FM CONVERSION_EXIT_ALPHA_INPUT to get leading zero
    Regards,
    anirban

  • XI Configuration Design questions with multi-mapping message mapping object

    Hello,
    I'm having trouble designing a particular scenario for multi-mapping.  Currently i'm working with a Vendor create and change.  BPM is not being used.
    This is what i need:
    I need a CREMDM04 to turn into one or multiple ADRMAS/CREMAS IDocs and potentially a CLFMAS IDoc based on the values in the inbound CREMDM04 IDoc.
    This is what i currently have:
    A CREMDM04 inbound idoc is multi-mapped to a CREMDM03 (1...9999), another CREMDM03 (0...9999), and a CLFMAS01 (0...9999).  At a minimum only the first CREMDM03 IDoc will be created and at a maximum all three will be created.  The parameters on creating the second CREMDM03 IDoc and the CLFMAS01 IDoc are based on the values in the inbound CREMDM04 IDoc, whereas the first CREMDM03 IDoc will always be created and the values will just be converted/mapped from the inbound CREMDM04 IDoc.  This multi-mapping is currently set-up via a graphical message map and works successfully in the test-tab of the mapping object.  It has a main message and has sub-messages which are the IDocs.  I’m mapping the CREMDM04 to a CREMDM03 to then map it through an ABAP-Class and then to an XSL where the CREMDM03 inbound structure is expected to split into ADRMAS and CREMAS Outbound IDocs for Vendor Create/Change in the remote R/3 systems.
    After the graphical map we have a necessary ABAP Class call that calls a BAPI to the remote system.  This ABAP Class must come after the graphical map since the parameter for the BAPI is based on a converted value from the graphical multi-map.
    After the ABAP Class call there is finally an XSL message split the CREMDM IDoc into an ADRMAS and CREMAS IDoc.  There need to be two interface mappings (one per ADRMAS and CREMAS) since the ABAP classes and XSLs are specific to the ADRMAS and CREMAS.
    The CLFMAS IDoc can go directly to the remote system, but since it’s within this one multi-map, I’m not sure if is possible?  I’m not sure if it will fail once it tries entering the XSL mapping (this is the standard CREMDM message split offered from SAP).
    There are three interface mapping scenarios I can think of, but cannot get to work:
    CREMDM04 to ADRMAS02
    CREMDM04 to CREMAS03
    CREMDM04 to CLFMAS01
    Currently I have the Interface Mapping structured as follows:  (I cannot get this to activate as it appears it does not work)
    Multi-Mapping ==> ABAP Class Call ==> Standard XSL Message Split
    How should i design the interface mapping objects and the configuration objects for this scenario?
    Any help is appreciated and I definitely will reward points (no need to include it in your response).

    Hi,
    I suggest you may use multiple steps interface mapping. It's composited with 3 message mappings as step by step.
    Mapping 1: One to one mapping. For the output schema, use a composition schema which includes those 3 IDOCs you want.
    Mappign 2: ABAP Mapping. I am not sure the ABAP class you mentioned is an ABAP mapping or not. If it does, That's ok. If not,
    call that ABAP class in your ABAP mapping and do corresponding change for your message. Return back the same structure as output.
    Mapping 3: One to multiple mapping to split the message.
    So basically as interface mapping, it's one to multiple mapping. And internally, you have 3 steps to realize the mapping.
    And as my experience, for both one to multiple message mapping & multiple steps interface mapping, it works well in my project. And
    in ID, you have to configure it via "advance" function in receiver determination or interface determination.
    Let me know if any confusion.
    Thanks
    Nick

  • Missing message mapping in SXMB_MONI

    Hi All,
    I am doing a mapping from XI to 2 receivers CRM proxy and JMS adapter.
    When I executed the whole process, I can see success flags in both XI MONI with 2 nodes one for receiver grouping and other for response. The request message mapping node is missing. When i checked CRM MONI for the same message, the inbound message payload is blank. What could be the reason for the missing message mapping IN sxmb_moni.
    Thanks

    Hi,
    Are you copying the source xml from message test tab to trigger the scenario.
    If so you need to remove <messages> <message> node from the input type.
    Always the root of your input xml should be your message type name.
    Regards,
    P.Venkat

  • Leading zeros are not carried from the pivot table to exported Excel (9927815)

    Hello All -
    I am just wondering if there is a fix available for -- Leading zeros are not carried from the pivot table to exported Excel (9927815)
    can anybody suggest when it will be fixed and if there is any-workaround for this issue if there is no fix available.
    Thanks
    Ram

    Thanks Timo -
    Studio Edition Version 11.1.1.2.0
    About
    Oracle JDeveloper 11g Release 1 11.1.1.2.0
    Studio Edition Version 11.1.1.2.0
    Build JDEVADF_11.1.1.2.0_GENERIC_091029.2229.5536
    Copyright © 1997, 2009 Oracle and/or its affiliates. All rights reserved.
    IDE Version: 11.1.1.2.36.55.36
    Product ID: oracle.jdeveloper
    Product Version: 11.1.1.2.36.55.36
    I will check on support.oracle.com

  • Pad leading zeros in a string.Format function

    How could use the string.Format function and in the format text pad a leading zero? 
    Pseudo code is:
    string parm = “5”;
    string format = “Some number formatted as 3 dig: Format({0}, 000)”;
    string output = string.Format(format, parm);
    Where the output would look like this:
    “Some number formatted as 3 dig: 005”
    Thanks.

    Thanks everyone. Unfortuantly there's a constraint where the padding operation needs to be embedded in the format string. This entire operatin is being put together dynamically where the format strings are being pulled from a library of format strings stored
    in a database. at runtime we don't know how which format will be used and how many parameters will be passed in. we have logic to handle the unknown number of paramters as there is metadata which helps us with that.
    the need for leading zeros needs to be part of the overall format defined in the format string.  for example, a real format string stored in the database looks like this:
    "LINE_NO = '{0}',  AND GEO_LOCATION = 'T{1}, {2},  R{3}, {4}, , Sec. {5}'"
    and its output from the string.Function is:
    "LINE_NO = 'TG-G2469',  AND GEO_LOCATION = 'T155, N,  R93, W, , Sec. 5'"
    the last parameter (param 5) had a value of 5.  In another case the output requirement might need to look like this:
    "LINE_NO = 'TG-G2469',  AND GEO_LOCATION = 'T155, N,  R93, W, , Sec. 05'"
    note the "05" at the end...
    the logic of using the leading zero needs to be embedded in the overall format string text.
    Thank you.

  • How to remove pound symbol # and preserve leading zeros in BEx Query

    Hi,
    I have two questions regarding the display in BEx Query.
    1. How can I remove the pound symbol # for blanks in BEx Query?
    2. How can I preserve leading zeros? At the moment, value "001" will be displayed as "1". But I need the leading zeros.
    Thanks.
    Joon

    Hi ,
    You can apply these settings in Bex query designer.
    If you need to remove pound symbol jsut make a new formula and use NODIM function you will find this function under data functions.
    So NODIM(Your price keyfigure) this will remove the Pound symbol.
    For # just find out against which  characterstic you are getting # then go to default values panel there you will find all your characterstic which you are using in report---Rt click -Restrict-single valuesdirect input-#-Move to selection(That forward arrow)--select that # and choose exclude from selection (That red square icon).
    And yes for leading zeros check out this thread
    Leading zeros not displaying
    Hope it helps you.
    Regards,
    AL
    Edited by: AL1112 on Jun 9, 2011 1:43 PM
    Edited by: AL1112 on Jun 9, 2011 1:47 PM

  • Leading zeros problem with custom popup

    I've implemented a custom popup page following the How-To docs on the topic. The value I'm return to the calling page in the passback function most often will have leading zeros. So from the custom popup I do a call like this: javascript:passback(00363644). When my value arrives back on the calling page it's converted to 124836 (haven't yet figured out what kind of conversion is happening there).
    I realize this is not a javascript forum (and I've Googled for leading zeros in javascript to no avail - yet) but the HTML DB field type Popup LOV seems to accomplish this just fine so I was wondering how Oracle might be doing it. Anyone have any ideas?
    Earl

    Vikas,
    See
    http://tinypic.com/ibbfoy.jpg
    So, just use
    javascript:passback("00363644")and it should do what you want.You would think. But I've tried:
    wrapping it in single quotes:
    opener.document.getElementById('P6_CONTACT_ID').value = "'" + myVal + "'";
    wrapping it in single quotes:
    opener.document.getElementById('P6_CONTACT_ID').value = """ + myVal + """;
    and the other 'trick' that I've seen mentioned several places, concatenating an empty string to the value:
    opener.document.getElementById('P6_CONTACT_ID').value = "" + myVal;
    All to no avail! This is really frustrating. Supposedly, any string concatenation action will 'force' the value to retain it's original 'string-ness'.
    Working off this assumption and thinking that the conversion had already taken place by the time I assigned the value I backed up a step and assigned the value to a variable before trying to set the value, ala:
    var myVal = p_Value.toString();
    opener.document.getElementById('P6_CONTACT_ID').value = myVal;
    and still no joy.
    Following this logic one step further, do I need to get the value to a string in the original call. This will be a challenge because the link in the popup report is a is set to a URL with javascript call, like this: javascript:passback(#CONTACT_ID#);
    Further, when I float over the links with the mouse I can see the URL in the status bar of the browser as javascript:passback(00363644); So, how do I go about wrapping this in quotes in the link?
    Any help???
    Earl

  • Leading zero check got activated in production .

    Hi,
    We had a DIMP ( Discrete Industries Mill Products) addtional installation to our existing landscape on last weekedn.  we have a strange issue after that.
    Most of the select queries based on material number,vendor,customer are failing. with further analysis it was observed that select queries are failing because of leading zero's missing .
    we are surprised since the same queries worked perfectly fine before ( and it still runs perfectly fine in qulaity client) but now it is failing.
    we know workaround to change all custome programs with conversion exit addtion to material,lifnr,kunnar ect.. but does anybody know if there is any business function which got activated to check leading zero's in select queries and this got activated along with DIMP.
    let me know if you have any helpful inputs.
    PS: i wnat to restore my original settings for leading zero so we dont need to change nay programs.

    Hi Santosh,
    some more analysis is required: For the failed selects, where do the missing-leading-zero kunnr/matnr/lifnr come from?
    If from screen input, check the screens are active, check the input fields data type, active, conversion exit correct?
    It may be a good idea to check the whole system for inactive objects.
    If from other sources, check the complete way the data goes before use in SELECT WHERE clause.
    If you have found one errors source, this will lead to more.
    There are a couple of SAP notes on DIMP, at least the activation process of DIMP should be checked.
    Regards,
    Clemens

  • SaveAsCSV() truncating leading zeros

    Hi
    We have used applet call saveAsCSV() and are experiencing the typical "leading zero" truncation since the value is being treated as numberic.
    I would like to know if there is any way of specifying certain fields as text other than inserting a character to force it to be a text field
    Thanks
    Deepa

    Hi Deepa
    This is actually a Microsoft Excel issue.  You cannot save a leading 0 in an csv file.
    I have tried doing this external to xMII and got to the conclusion that the file type CSV does not allow for leading zero's (I think this is the case with special characters in CSV files as well).
    Your best bet is to call a function to add leading zero's (something like a padding/stretch function) once you open the saved file.
    Regards

  • Delete leading zeros for material in mapping.

    Hi,
    How to delete leading zeros for material like 0000000128736 if so I am expecting 128736 only.
    We need to consider if I get  material number is like RPG2389 .
    Thanks,
    Vinay.

    Hi,
    If you will be getting alphanumeric codes, it would be best to use a UDF with a regex-expression.
    UDF Type:
    ContextType
    imports:
    java.util.regex; (if you are using PI 7.1 you must remove the semicolon)
    arguments:
    input1
    Here's the code (courtesy of Sun Developer Network):
            Pattern p = Pattern.compile("[^a-zA-Z]");
            Matcher m = p.matcher(input1[0]);
            StringBuffer sb = new StringBuffer();
            boolean output = m.find();
            while(output) {
                m.appendReplacement(sb, "");
                output = m.find();
            m.appendTail(sb);
    result.addValue(input1[1]);
    Now to solve the leading zeroes, just add formatNumber: 0 after the UDF and it will work.
    Hope this helps,

Maybe you are looking for

  • IMovie Going Crazy-- Copy/Paste Problems

    When I am trying to copy/paste pictures and transitions from one project to another, iMovie is copying a totally DIFFERENT picture multiple times into my existing project. Also, when I try to create a new project and paste, it doesn't paste anything.

  • My G4 won't open iTunes correctly.  It appears open in the dock but

    my G4 won't open iTunes correctly. It appears open in the dock but no window will open and it won't show in the menu on top. When I click on an mpe on the decktop or load a CD, nothing happens. I have reloaded the program, upgraded, etc.

  • Automated deployment of OSB artifacts

    Hi, I have 4 webservices in OSB I want to automate the deployment of 4 services at a time can anyone suggest me how to write the python script accordingly. Thanks in advance :)

  • What is "gc cr disk read" event?

    hi, Do you know what "gc cr disk read" event exactly means? I could not find any useful information on oracle documentation, metalink and web? I suspect that it is related to parallel disk reads on RAC nodes. I mean for a query assume that all rac no

  • ICal sharing

    hey there! i tried for several hours to share a calender with my brother. he has an iphone 5, i have an iphone 4s. (if that matters..) the thing is, i can invite him, and he accepts. although, he is allowed to make changes on my calenders, they don't