How to insert spaces in elements in message mapping

Hi All,
         I have scenario, where in the incoming data is put into a file, but if there is no incoming data for any element it should insert spaces equivalent to the lenght of the field. how can this be done?
XIer

Xier,
your problem is that the MapWithDefault function will fill only the fields which have no value, for example, if that tag is like <field2/>. When you have <field2></field2>, you have a value, even though this value is an empty string.
To test your scenario properly, change your input xml to:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_Countresult xmlns:ns0="urn:sce.com:xi:FI:TestProjectStructureUpload">
     <record>
          <field1>a</field1>
          <field2/>
          <field3>b</field3>
     </record>
</ns0:MT_Countresult>
If your requirement is to insert spaces when you have empty string as the input (<field2></field2> case), then you can't use MapWithDefault. In this case, you have to use an if logic: if input = "" (empty string) then output = "    " (4 blankspaces), else output = input.
If you don't know how the input will come, best scenario would be to combine the MapWithDefault + If logic, in order to solve both cases (no input or empty string input).
Regards,
Henrique.

Similar Messages

  • How to find length of integer elements using message mapping

    Hi all,
             How can I find the number of digits in an element using message mapping
    XIer

    Satish,
               Cause I have to write the code for 100 elements, I have decided to have a AUDF with two inputs;
    1) for the element
    2) for the length of the data type (I am passing length using Constant message mapping func).
    Now when I change my UDF and try running it I get the following error:
    <b><i>Start of test
    Source code has syntax error:  /usr/sap/B06/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map0999e66045cf11dcc83b4ebcfc11da82/source/com/sap/xi/tf/_MM_Recordcount1_.java:160: operator >= cannot be applied to int,java.lang.String if(Element_Name.length()>=Element_Length) ^ /usr/sap/B06/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map0999e66045cf11dcc83b4ebcfc11da82/source/com/sap/xi/tf/_MM_Recordcount1_.java:166: operator <= cannot be applied to int,java.lang.String for(int i=Element_Name.length();i<=Element_Length;i++) ^ 2 errors</i></b>
    The code I have used is:
    public String Include_Space(String Element_Name,String Element_Length,Container container)
    {StringBuffer sb= new StringBuffer();
    if(Element_Name.length()>=Element_Length)
    return""Element_Name"";
    else
    for(int i=Element_Name.length();i<=Element_Length;i++)
    if(i==Element_Name.length())
    sb.append(Element_Name);
    else
    sb.append(" ");
    return ""sb.toString()"";
    Pls advice, where I am going wrong...
    XIer
    Message was edited by:
            XIer

  • How to insert textedit ui element in ALV

    hi experts,
    i need to insert textedit ui element in one of the column of ALV.
    thanks

    No you cann't use the TExtedit in ALV cell.
    Check out the thread [Line break in ALV cells|Re: Line break in ALV cells?] for more details.

  • How to insert new line break in XSLT mapping

    Hi experts,
    I am doing file to mail scenario, i am sending the text file as an attachment using reciever mail adapter.
    I did everything, i can able to send the mail with text file attachment, but with in the file i got multiple rows, i need to put line break in XSLT mapping.
    I did use following statement but it is inserting small rectangle between the records, the records are not separating with new lines, all are in one line.
    <xsl:text>*#xA;</xsl:text>   
    note: in real coding replace * with &
    Can anyone suggest me how to insert new line in XSLT mapping.
    My XSLT mapping as look like:
    <?xml version='1.0'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:ns0="http://www.Coj.co.za/SapIsuToABSA/DirectDebitFile">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:variable name="break">&lt;br/&gt;</xsl:variable>
    <xsl:variable name="space"> </xsl:variable>
    <xsl:variable name="newline"><xsl:text></xsl:text></xsl:variable>
    <xsl:template match="/">
    <ns1:Mail xmlns:ns1="http://sap.com/xi/XI/Mail/30">
    <Subject>Please Check Attached Direct Debit File</Subject>
    <From>S@za</From>
    <To>P@za</To>
    <Content_Type>text/plain</Content_Type>
    <Content>
    <xsl:for-each select="MT_SapIsuToABSA_DirectDebitFile/DirectDebitRec/Body">
    <xsl:value-of select="Space1"/>
    <xsl:value-of select="Cust_AccNo"/>
    <xsl:value-of select="Reserve_1"/>
    <xsl:value-of select="Cust_Name"/>
    <xsl:value-of select="Cust_Name1"/>
    <xsl:value-of select="Cust_Bank_AccNo"/>
    <xsl:value-of select="Space2"/>
    <xsl:value-of select="Cust_Bank_BranchNo"/>
    <xsl:value-of select="Reserve_2"/>
    <xsl:value-of select="Space3"/>
    <xsl:value-of select="Cust_AccNo_1"/>
    <xsl:value-of select="Space4"/>
    <xsl:value-of select="Reserve_3"/>
    <xsl:value-of select="Deduction_Amnt"/>
    <xsl:value-of select="Space5"/>
    <xsl:value-of select="Reserve_4"/>
    <xsl:value-of select="Space6"/>
    <xsl:value-of select="Action_Date"/>
    <xsl:value-of select="Space7"/>
    <xsl:value-of select="Reserve_5"/>
    <xsl:text>*#xA;</xsl:text>   
    note: in real coding replace * with &
    </xsl:for-each>
    </Content>
      </ns1:Mail>
      </xsl:template>
      </xsl:stylesheet>
    Kind regards,
    Praveen

    Hi,
    I think <xsl:text>#xa;</xsl:text> should do the trick, but depending on which OS (ux or win), the "new line" chars sequence is different (win would require a CRLF like <xsl:text>#xd;*#xa;</xsl:text>)
    Chris
    -> &
    Edited by: Christophe PFERTZEL on Apr 14, 2010 2:16 PM

  • Get the value of Container element in message mapping

    Hi,
    Is it possible to read the value of container elements(bpm) in a UDF defined in message mapping. If yes, please tell me how?
    Thanks and regards,
    Siji

    Siji,
    Refer thread - Creating the container Object In Java Mapping
    Regards,
    Geetha

  • How to Alert RFC connection failure via message mapping? Kindly Help!

    Hi Experts,
        I have a JMS - XI - RFC scenario.
    JMS receives the Rosattenet PIP contents and sends it to RFC function module in remote SAP R/3 system.
       I have a requirement where I have to monitor RFC connection failure because of the remote R/3 system being down. I have to send a email alert where the subject contains the PIP number to understand for which PIP the connection failed.
      The PIP number exists in the PIP content at the interface.
      If I use the Alert configuration in the runtime workbench for monitoring then I cannot dynamically pass the PIP number.
      Only way I think of triggering alert is in the message mapping via a Java UDF.
      But I am not sure how can I do this? How do I check in the UDF if RFC connection has failed? Is this the correct approach?
      How to acheive my requirement? Note that my email subject content is dynamic bacause if PIP number.
    Please help!
    Thanks
    Gopal
    Message was edited by:
            gopalkrishna baliga

    Hi Gopal,
    what version/sps of XI are u running?
    The easiest way to do what u want inside a UDF is to
    1. use JCo to try estabilish a connection to the remote SAP System
    2. if that fails, use JavaMail to send an email message
    Let your UDF work on the PIP number, accepting it as input, and (maybe) returning it as output if everything goes ok. Otherwise break the mapping execution as described by Michal in one of his last weblog (using Dynamic Configuration).
    Note that the above method doesn't guarantee that the message will be actually delivered, as some seconds could last between your check and the real RFC delivery operated by the Adapter Engine...
    I am evaluating a way to do the same with Alert Framework. I will let you know the result!
    Cheers,
    Alex

  • Java heap space error occured during message mapping of FILE to IDOC

    hello Friends,
                          I am trying to do the message mapping for File to Idoc scenario.
    Idoc which I am using is HRMD_A.HRMD_A06 and infotype which I want to update is 14. I am trying to map the message type which I hav created for infotype 14 with the IDOC
    Its very simple scenerio but  every time I try to save the mapping before activating it I get an error:
    Java heap space
    Internal problem occurred (INTERNAL_PROBLEM)
    Java heap space.
                I am not able to figure out what possibly is the problem wheather its from my end or the BASIS end.
    Kindly help.
    Regards,
    Lokesh

    As the server probably survives (you restart your Integration Builder and can probably connect immediately), the problem will be on your side (client). Did you add one or more large xml-test-instances to the mapping ? If yes, delete them, because they lower the performance and can make problems. If not, then this is a strange problem. Even if the Idoc structure is complex, the mapping object itself cannot be that large.Is this problem only with this one mapping ?
    CSY
    Edited by: Christian Sy on Mar 9, 2010 6:26 AM

  • How can I use loop in graphical message mapping

    The source input XML is like:
    <bookstore>
      <book>
           <item1>xxx</item1>
           <item2>yyy</item2>
      </book>
      <book>
            <item1>zzz</item1>
           <item2>www</item2> 
    </book>
    </bookstore>
    I want to create an output XML like
    <output>
       <item>
            <item1>xxx</item1>
             <item2>yyy</item2>
        </item>
       <item>
            <item1>xxx</item1>
             <item2>www</item2>
        </item>
       <item>
            <item1>zzz</item1>
             <item2>www</item2>
        </item>
       <item>
            <item1>xxx</item1>
             <item2>yyy</item2>
        </item>
    </output>
    That means I want to do permutation and combination for all <item1> <item2> under <book>.
    Of course I can write a customer function to do it, but I want to basically use the buildin functions to do the graphical message mapping for this.
    Any idea?  thank you.

    well, I'm not very clear of those 2 English words
    What I want is to list all possible combination of item1 and item2 (and in fact, we have item3, item4, ....etc).
    example
    input: 
    <item>
              <item1> 111 </item1>
              <item2> 222 </item2>
              <item3> 333 </item3>
    </item>
    <item>
              <item1> aaa </item1>
              <item2> bbb </item2>
              <item3> ccc </item3>
    </item>
    I want to get
    <item><Item1>111>/item1> <item2>222</item2> <item3>333</item3> </item>
    <item><Item1>111>/item1> <item2>222</item2> <item3>ccc</item3> </item>
    <item><Item1>111>/item1> <item2>bbb</item2> <item3>333</item3> </item>
    <item><Item1>111>/item1> <item2>bbb</item2> <item3>ccc</item3> </item>
    <item><Item1>aaa>/item1> <item2>222</item2> <item3>333</item3> </item>
    <item><Item1>aaa>/item1> <item2>222</item2> <item3>ccc</item3> </item>
    <item><Item1>aaa>/item1> <item2>bbb</item2> <item3>333</item3> </item>
    <item><Item1>aaa>/item1> <item2>bbb</item2> <item3>ccc</item3> </item>

  • How to remove space taken up by "message" on iphone

    Hello,
    Thanks for taking a look at my post. I am trying to free up some space on my iphone5. I have manually deleted old text messages but when I go into settings/general/usage I see 1.8gb of space being taken up by messages. It lists these as (saved).
    Is there a way to delete these?
    Thanks!
    Steve

    This indicates corrupt files.
    A restore should resolve.

  • How to Supress null target Elements in XSLT Mapping

    Hi Experts,
    I need to Strip off (remove) Null tags from my ouput XML document.
    My XSLT Mapping file
    <?xml version='1.0' ?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <a:A2ACU>
    <a:PartNo>
    <xsl:value-of select="Specifications/Specification/PARTNO"/>
    </a:PartNo>
    <a:Revision>
    <xsl:value-of select="Specifications/Specification/REVISION"/>
    </a:Revision>
    <a:ENERGY>
    <xsl:for-each select="Specifications/Specification/Section">
    <xsl:variable name="Sec_ID">
    <xsl:value-of select="SECTIONID"/>
    </xsl:variable>
    <xsl:if test="$Sec_ID = '700015'">
    <xsl:for-each select="Item">
    <xsl:variable name="Item_ID">
    <xsl:value-of select="ITEMID"/>
    </xsl:variable>
    <xsl:if test="$Item_ID = '701134'">
    <xsl:for-each select="PropertyGroup/Property">
    <xsl:variable name="Pro_ID">
    <xsl:value-of select="PROPERTYID"/>
    </xsl:variable>
    <xsl:if test="$Pro_ID = '700232'">
    <xsl:variable name="Atr_ID">
    <xsl:value-of select="ATTRIBUTEID"/>
    </xsl:variable>
    <xsl:if test="$Atr_ID = '700064'">
    <xsl:value-of select="STRING2"/>
    </xsl:if>
    </xsl:if>
    </xsl:for-each>
    </xsl:if>
    </xsl:for-each>
    </xsl:if>
    </xsl:for-each>
    </a:ENERGY>
    </a:A2ACU>
    </xsl:template>
    </xsl:stylesheet>
    If any one of the condition in ENRGY TAG FAILS it is giving a output as
    - <A2ACU>
    <PartNo>123456789</PartNo>
    <Revision>2</Revision>
    <ENERGY></ENERGY>
    - </A2ACU>
    But as per my new requirement I need to check the Empty value in all the tags and need to strip of them form final output ...like..
    - <A2ACU>
    <PartNo>123456789</PartNo>
    <Revision>2</Revision>
    - </A2ACU>
    Can any one please suggest me whether any function is availble to this stripping
    Thanks in Advance
    Ram

    Hi Ram,
    try to put the tag inside the IF conditions.
    It'd be something like:
    > <xsl:for-each select="Specifications/Specification/Section">
    > <xsl:variable name="Sec_ID">
    > <xsl:value-of select="SECTIONID"/>
    > </xsl:variable>
    > <xsl:if test="$Sec_ID = '700015'">
    > <xsl:for-each select="Item">
    > <xsl:variable name="Item_ID">
    > <xsl:value-of select="ITEMID"/>
    > </xsl:variable>
    > <xsl:if test="$Item_ID = '701134'">
    > <xsl:for-each select="PropertyGroup/Property">
    > <xsl:variable name="Pro_ID">
    > <xsl:value-of select="PROPERTYID"/>
    > </xsl:variable>
    > <xsl:if test="$Pro_ID = '700232'">
    > <xsl:variable name="Atr_ID">
    > <xsl:value-of select="ATTRIBUTEID"/>
    > </xsl:variable>
    > <xsl:if test="$Atr_ID = '700064'">
    > <a:ENERGY><xsl:value-of select="STRING2"/></a:ENERGY>
    > </xsl:if>
    > </xsl:if>
    > </xsl:for-each>
    > </xsl:if>
    > </xsl:for-each>
    > </xsl:if>
    > </xsl:for-each>
    Regards,
    Henrique.

  • Can't open Elements error message 150:30

    How can I open Photoshop Elementa error message 150:30?

    mac:
    http://helpx.adobe.com/x-productkb/global/error-licensing-stopped-mac-os.html
    windows:
    http://helpx.adobe.com/creative-suite/kb/error-licensing-stopped-windows.html

  • How to pass GUID in message mapping

    Hi ALL
    I would like to populate one of the target fields with SAP PI GUID or Message ID.
    Can you please let me know, how to get the GUID in my message mapping and map it to the target field.
    Thank you,
    Ritu

    Hi Ritu ,
    its simple you can pick the messageID from the streamtransformation constant and map it to ur target field .
    use this UDF it does not taes any input and its output can be mapped to target field where you want to populate the messageid.
    java.util.Map param = container.getTransformationParameters();
    String MSGID = (String) param.get (StreamTransformationConstants.MESSAGE_ID);
    return MSGID
    Regards,
    Saurabh

  • Element/ Node supression in message mapping

    Hi,
    Source Structure
    ID (Mandatory)
    FName (optional)
    Target Structure
    EmpID (mandatory)
    EmpName (optional)
    In my mapping, i mapped FName to EmpName. Since FName is optional,when i have an XML file that does not contain Name element my message mapping fails. So i used "if-then-else" and "exists" to make the mapping work.
    Name --> <b>"exists"</b> --><b>"if-then-else",</b>
         FName--> EmpName (then)
         Constant-->EmpName(else)
    But now i want that my o/p element (EmpName) should not get generated, if Name element does not exist. I mean the element Empname should be supressed in message mapping.
    I know that if a target field is mapped, it is bound to come in the target structure. But i want this target element to be supressed.
    Hope somebody can help me out...
    Cheers,
    Siva Maranani

    Hi Siva,
    If i understand u correctly you want to supress the target field if the mapped source field does not exist:
    Try using IF WITHOUT ELSE
    When the source field exists then you will have the value mapped to the target field and when the source field does not exist, the target field will not be created.
    Regards,
    Sridhar

  • How  Hash tables can be used  in PI mapping

    Hi Experts,
    I'm don't have any idea how we store the values in hash tables and how to implement them in mapping.
    In my scenario I have two fields matnum and quantity.if matnum is not null ,then we have to check whether the matnum exists in hash table and also check whether the hash table is empty or not.
    How we can do this in graphical message mapping? 
    how to store the variable matnum in a table?
    If global variables are used, how to implement in mapping.how we call the keys from hash table ?

    Divya,
    We have a similiar requirement for getting different values. Below param1 may you be matnum,param2 is quantity
    What you need to do is first declare global varaible(A), fill hash table as below(B) and retrieve(C) based on index. You can tweak code based on your requirement
    (A) Declare global variable(last icon in message mapping tool bar)
         String globlalString[] = new String[10];
    (B) Fill Hash Table
    import java.util.Hashtable;
    public void saveparam1(String[] param1,String[] param2,ResultList result,Container container){
    Hashtable htparam1 = new Hashtable();
    int Indx = 0;
    for (int i = 0 ;i < param1.length ; i++) {
      String strparam1 = param1<i>.trim();
      if (strparam1.length() > 0) {
        Object obj = htparam1.get(strparam1);
        if (obj == null){
          globlalString[Indx++] = strparam1 ;
          htparam1.put(strparam1,strparam1);
    if (Indx < globalString.length) {
      for (int i = 0;  i < param2.length ; i++) {
        String strparam2 = param2<i>.trim();
        if (strparam2.length() > 0) {
          Object obj = htparam1.get(strparam2);
          if (obj == null){
            globalString[Indx++] = strparam2 ;
            htparam1.put(strparam2,strparam2);
    result.addValue(globalString[0]); // for first value
    (C) for subsequent reading/accessing
    //pass constant whatever number is required to this function
    String retValue = "";
      int indx = Integer.parseInt(index);
      indx = indx - 1;
      if ((indx >= 0) && (indx < globalString.length)){
       retValue = globalString[indx];
    return retValue;
    Hope this helps!

  • Validations in message mapping

    Hi,
    How can we do different validations in message mapping
    and how can we trap them
    Pls suggest blogs.
    Regards

    Hi,
    you need to model them yourself
    with some standard functions like:
    - length
    - if
    - ifwithoutelse
    etc
    Regards,
    michal

Maybe you are looking for