UDF in SAP PI

Hi Experts,
I am writing a UDF for testing purpose which is like this.
int ABAPCount = 0,PICount =0;
for (int i =0;i<Design.lenght;i++)
if(design<i>.equals("ABAP"))
ABAPCount++;
else if (Design<i>.equals("PI"))
PICount++;
if(ABAPCount !=0)
result.addValue("BS_FILE_RECEIVER");
if(PICount >=0)
result.addValue("BS_FILE_RECEIVER2");
But it is showing error as "cannot resolve symbol symbol : variable design" under if and for statements.
Can anyone please tell me the reason ?
Any kind of suggestion will be appreciated.
Thanks
Rabi

Hi Rabi,
              I guess one of your input to the UDF is as shown below
String Design[]
Then you need to alter your code as shown
int ABAPCount = 0,PICount =0;
for (int i =0;i<Design.length;i++)
if(Design.equals("ABAP"))
           ABAPCount++;
else if (Design.equals("PI"))
            PICount++;
if(ABAPCount !=0)
result.addValue("BS_FILE_RECEIVER");
if(PICount >=0)
result.addValue("BS_FILE_RECEIVER2");
regards
Anupam

Similar Messages

  • Executing/debugging udf in sap nwds

    Hi,
    I need to test/debug a udf in sap nwds.
    I have installed the nwds tool.
    I tried searching for step by step approach in google/sdn.
    if anybody knows the links or can provide the steps to do the same........will be helpfull....
    i need to create the udf in nwds & test/debug it........
    santosh.

    http://www.conspicio.dk/blog/bjarne/using-eclipse-for-developing-sap-xi-user-defined-functions

  • Mail attachment generated in UDF in SAP PI 7.1 - Issue with line feed

    Hello,
    Situation is:
    Implemented a scenario in SAP PI 7.1 with a mail receiver following this thread:
    /people/samuel.chandrasekaran2/blog/2008/10/06/xi-mail-adapter-dynamically-building-attachment-and-message-body-content-using-a-simple-udf
    which is about moving message lines from sender into an attachment forn the receiver mail.
    It is working great!
    The receiver gets the mail including the attachment with all added lines.
    But when opening this mail there is an issue depending on the program we are using to open the attachment
    which is defined as txt file
    - Using MS Editor 5.1 (Windows XP 2007, SP3) the Carriage returns and line feeds (added with
    in the UDF) to separate the message lines are not recognized. In the Editor each 
        is shown as □   within the text.  Word wrap (flag set in the editor) is different to the carriage return/line feeds set in the file.
    - Using MS Notepad 5.1 (Windows XP 2007, SP3)   situation is the same but
        is NOT shown as □ , it simply seems to be unvisible. Word wrap (flag set in the editor) is different to the carriage return/line feeds set in the file.
    - Using Word 2007 the carriage returns are recognized and used in a correct way to display the file content. But now mutated vowels (äüö) are not recognized. They are displayed as
    So I followed this thread:
    http://help.sap.com/saphelp_nw04/helpdata/en/96/f04142099eb76be10000000a155106/content.htm
    Nice....
    In the editors there is no change, but when opening the file in Word it asks now how to convert the file content
    (proposing UTF-8) and Word recognizes mutual vowels.
    But there seems to be a side effect....
    Following the second link,  PI recognizes an error.
    This is the error message.
    MP: exception caught with message Null as XI message received (PrincipalData in ModulData is null)
    Adapter Framework caught exception: Null as XI message received (PrincipalData in ModulData is null)
    Delivering the message to the application using connection Mail_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.lang.Exception: Null as XI message received (PrincipalData in ModulData is null).
    But the message is sent to the mail recipient which could be ok if PI would not repeat the mail sending now for several times.
    So we will receive not one but a number of mails.
    So we removed the modul recommended in this help link from the channel.
    Result: Behaviour in Word changed now to the described one. But the errors are no longer coming up in channel monitoring incl. message send repetition. So this is a first success. But the partner wants to process the files first with one of the named editors. So we are looking for another solution now to fix the last issue!
    Your ideas are really welcome!
    Best regards
    Dirk

    Hi,
    as I found this in wikipedia:
    Another common problem is the use of '\n' when communicating using an Internet protocol that mandates the use of ASCII CR+LF for ending lines. Writing '\n' to a text mode stream works correctly on Windows systems, but produces only LF on Unix, and something completely different on more exotic systems. Using "\r\n" in binary mode is slightly better, as it works on many ASCII-compatible systems, but still fails in the general case. One approach is to use binary mode and specify the numeric values of the control sequence directly, "\x0D\x0A".
    Back to my issue:
    In the UDF I am adding "\r\n" but only the "\n" seems to survive!
    In Mapping test line feeds are available and the lines are shown as expected.
    Using Notepad ++ to open the created txt file from the mail shows that LF is in the file at each end of line but CR is missing.
    CR is only at the end of the last line in the file and is not from the UDF that creates the mail or the UDF that creates the attachment lines. Seems that this is added somewhere else behind the mapping.
    This is what I found in galileo computing
    (http://www.galileocomputing.de/glossar/gp/anzeige-11241/FirstLetter-Z, SORRY, only available in german language!):
    In Parsing of XML-Documents the XML-Parser changes the end of line delimiter internally in general to a simple line feed (LF, #0A) as usual in UNIX. ..... In Windows this could result in problems with readability of  source texts (e.g. in Notepad) which can be solved by choosing the right editor.
    My target application is on Windows and not able to "choose" the right editor (PI system is on windoes OS too) !
    But Im wondering where the CR at the end of the text comes from when all the \r\n will be replaced with \n as described.
    Ideas are really welcome!
    Best regards
    Dirk
    Edited by: Meinhard Dirk on May 31, 2011 2:45 PM

  • Mail attachment with UDF in SAP PI 7.1

    Hello,
    I need to reproduce this solution in PI 7.1
    /people/samuel.chandrasekaran2/blog/2008/10/06/xi-mail-adapter-dynamically-building-attachment-and-message-body-content-using-a-simple-udf
    It is about  adding lines of a message as an attachment to a mail.
    The UDF works for all elements except the lines for the attachment itself.
    In order to build the content of the attachment (for this particular requirement) they are using a global variable declared and initialized in the global sections.
    But the button for the Java Section to use an imported archive is no longer available in PI.....
    So how to solve that issue?
    I tried to use a graphical variable instead of a global variable but I have no idea how to add the n lines
    from the source message as one import object into the UDF via that graphical variable.
    Your ideas are very appreciated!
    Best Regards
    Dirk

    Hi,
    yes, it is a little bit different. This is the issue.....  
    But I am not sure if your links will help:
    1) /people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-graphical-variable
    is about a different solution. I do not need to count the number of lines of the source message.
    And the second variable is about concat line by line from unbound node to unbound node.
    My issue is:
    Souce:
    Message line (0...unbound) ! ! ! ! ! ! ! !
    .    ResultLine   (1..1)
    Mapping:
    =>   ResultLine1
           ResultLine2
           ResultLine........          => into UDF to an element  (1..1) in one mapping operation.
    So that all "ResultLine"s are included.
    The result is explained in the given link for Mail attachment with UDF.
    So I am not sure how to use this thread for my issue.
    In the comments of that blog Christoph Gerber writes that the new variable feature can only handle single values.
    So it is not suitable for my purposes as I have a list of values here that needs to be moved into the target message field.
    2) http://wiki.sdn.sap.com/wiki/display/Java/UsingEditJavaSectioninMessageMapping
    shows where to find the button "Java section" which is not available here in 7.1
    3) /people/sap.user72/blog/2005/10/01/xi-new-features-in-sp14
    too is about the nice little button for Java Section that is no longer existing on PI 7.1 screen for mappings.  
    So my issue is: How to replace the Java section function with global variables in PI 7.1?
    Best regards
    Dirk

  • Auto update a UDF in SAP B1

    Hi, I am new to SAP Business One. I need to update automatically the value of a UDF. The value will be calculated using data from related tables. Calculation includes -summation, divide and minus etc. Could you provide guide.
    For example a new UDF should contain the suggested quantity to order. this is calculated considering the running average sales quantity as of current time for this month and deduct the available quantity on hand and also deduct the quantity already ordered (arriving soon to be delivered to warehouse). I appreciate your input.

    Continuation of this thread is in:
    SAP Business One Application

  • Creating a UDF in SAP XI

    Hi,
    I have Idoc to File Mapping in SAP XI, where I need to populate "Spaces" in most of the Target fields Dynamically. I need to create a UDF for this mapping. Since I have n no.of Target fields where I need to populate Sapces and Target fileds has different lengths. As of now I have cretated a simple UDF which is usefull only for one field mapping. Below is the UDF:
    String s;
         char []c = new char[10];
         for(int i=0; i<10; i++)
            c<i> = 'S';
         s = new String(c);
         return s;
    2. My source file will be having 1000 records where 999 records will be mapped to Traget sturucture and the end of the Record should be mapped to the other Traget structure(Traget sturcture is same in the both the cases).
    Please let me know how can I go about on this.
    Thanks in Advance.
    Jose

    Hi Joseph,
    Give a try to use the below UDF for the fields where you want to have some hardcoded values :
    a : Field you would like to change
    b : New hardcoded value for the field.
    for( int i=0; i<a.length; i++)
      if (i==(a.length-1))
          result.addValue(b[0]);
      else
         result.addValue(a<i>);
    input_field_1   --------------------
                                           UDF  -------------------- target_field_1
    new_constant_EOD  ------------------
    Rest all mappings should remain as it is.
    Let me know if you face any issue.
    Thanks,
    Pooja

  • Create UDF for table not in the List of tables

    Hi all,
    I know that my question maybe easy or been asked before, but I couldn't find the answer.
    To create a UDF in SAP B1 version 9.0 you should go Tools -> Customization Tools -> User-Defined Fields - Management...
    which is ok and working perfect. but my question is:
    If I want to create UDF for a table not in the list of tables there what should I do? I need to create 2 UDFs for table OMRC [Manufacturers], and can't find it in master data tables.
    anyone had this issue before?
    EDIT  : Is it good to add the field by using sql server? I know it's possible, but will it be visible in SAP
    thank you
    Message was edited by: Samira Haroun

    Hi Samira,
    There is noit a simple link for this, I advise you to study the documentation for TB1300 SBO Development Certification.
    Ypu should also have knowledge of .net, and C# or VB, because you have to make a small program/addon to add the fields
    Kind regards
    Ad Kerremans

  • Usertable error after adding a udf

    I have a UI add-on that assigns values ​​to a UDT by usertable object of the DI API, the problem is generated after adding a UDF from SAP menu and try to assign a value from the DI. The error is Invalida Field Name
    My question is, is necessary to wait a while until SAP records the new field to be accessible by usertable?
    Any suggestions?
    oUserTable.UserFields.Fields.Item("U_" + colName).Value = respuesta;

    Hi Ricardo,
    As far as I know, you can use this field as soon as it is added to the usertable. But please make sure that this has been added successfully in your table and also make sure that ("U_" + colName ) is the same as it appears in SQL Server. Make sure that you are providing the right field name.
    Hope it helps.
    Thanks & Regards
    Ankit Chauhan

  • Existance of decimal point in String using UDF

    hi,
    How would i know the existance of decimal point in String using UDF in SAP XI message mapping?
    Regards,
    Sanghamitra

    public String calculate(String var1, Container container) throws StreamTransformationException
    Boolean b=var1.contains(".");
    if(b)
    return "true";
    else
    return "false";
    Also using standard function IndexOf you can achive this.

  • Selection of multiple option in udf

    I want to select more than one field in my document by means of check box or any.
    I cant use drop down option in udf coz that allows me to select one field only.
    Is there any other way to do this?
    Thanks

    Hi Malhotra,
       Its a Default behaviour of UDF in SAP B1
    Regards
    Jambulingam.P

  • UDF with list

    Hi,
    In Item Master Data we have a UDF which is a LIST directly made when creating the UDF
    In SAP when we add a new item and let this field empty we don't know how SAP handle this but
    by SDK when we try to save an empty string or a DBNull.Value it isn't accepted.
    What do we have to put in this UDF when creating an item by SDK ?
    if I do nothing it's ok but this isn't not always practible.
    Is there anything in the SDK to set a UDF as nothing ?

    Finally I see that we just have to let it go and not try to set it if there's no default for it.
    I now check if the interface have nothing, don't do anything with the field.  SAP will handle it itself
    if the interface have something then and only then I set what was selected on the interface into the field and it seems to work ok that way.
    Of course in case someone have set Mandatory, I presume he'll need to set this field mandatory in his interface as well.
    Thank you anyway

  • Create UDT and UDF while installing theAdd-on

    Dear Sir,
    Can someone help me by providing me code sample of how can i create UDT and UDF into SAP BO while installing my Add-On.
    Thanks in advance
    Best Regards

    Hi Mary,
    Please refer to this thread database
    Regards
    Aravind

  • Is is possibel to do an RFC Lookup from The Graphical Mapping?

    Greetings,
    While doing a message mapping I need to get the value from R3 system using an RFC, is it is possible ?

    Hi
    we can do by using rfc look ups
    Lookup in mapping is the feature provided by SAP to lookup the data in the target R/3 or DB systems with the API provided.
    You need to write UDF in order to implement the API's provided by SAP.Consider the below example
    VendorNumber-UDF--CURR
    The scenario is legacy to SAP. The legacy system doesn't provide the currency details. But the target field need's to be populated with currency value.
    "The business rules says there are values maintained in SAP Table where if you pass VendorNumber it will return thr currency to you"
    So what you can do? You can write UDF implementing SAP Provided API's and do a lookup in the SAP System and get back the currency value and populate them in CURR field.
    I hope it clears a bit.
    Please find the below blogs
    DB Lookup: /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
    RFC Lookup:https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1b439
    There are three types of look ups u can do
    RFC look up
    SOAP look up
    JDBC look up
    What is Lookup and why we need:
    Within an XI mapping it is a common requirement to be able to perform data lookups on-the-fly. In particular, there may be a need to look up some data that is maintained in an R/3 application.
    In the error handling topic we have seen the different validations which need to be performed on file. This can be done through Lookup.
    Some use cases:
    • Look up material number from table MARA.
    • Look up cost center budget.
    • Look up employee information.
    • Look up unit-of-measure (UOM) information from table t006a.
    • Lookup for raising an alert.
    The purpose of the lookup may be:
    • To perform application-level validation of the data, before sending it to the backend.
    • To populate fields of the XML document with some additional data found in the backend application.
    This is a form of value transformation.
    The "value mappings" offered by XI are not adequate in this case, since the data would have to be manually entered in the Integration Directory.
    There are two ways in which we can do lookup:
    • Call lookup method from GUI mapping.
    • Call lookup method from XSLT mapping.
    Lookup method from GUI mapping can be called using any of the following ways.
    • RFC lookup using JCO (without communication channel)
    /people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups
    • RFC lookup with communication channel.
    /people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
    • Lookup using JDBC adapter.
    /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
    /people/sap.user72/blog/2005/12/06/optimizing-lookups-in-xi
    • CSV file lookup.
    /people/sundararamaprasad.subbaraman/blog/2005/12/09/making-csv-file-lookup-possible-in-sap-xi
    Lookups with XSLT - https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8e7daa90-0201-0010-9499-cd347ffbbf72
    /people/sravya.talanki2/blog
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/05a3d62e-0a01-0010-14bc-adc8efd4ee14
    DB lookup - /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
    SOAP Lookup - /people/bhavesh.kantilal/blog/2006/11/20/webservice-calls-from-a-user-defined-function
    You can refer to these links.
    /people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer Absolute stealer.
    /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
    For Java APIs and also here you can map that how many types of lookups are possible in XI.
    http://help.sap.com/javadocs/NW04/current/pi/com/sap/aii/mapping/lookup/package-summary.html

  • Lookup performance

    any idea on the performance of the mappings in lookup

    Hello,
    <b>          The inclusion  of the Lookup in MAppping is not suggestable...unless the scenrio demands for it .Becaouse Lookup consumes more resources as it is nothing but logical jump of the Control flow from IR to R/3 or External data base and retrieving the info and getting back...
    </b>
    Lookup in mapping is the feature provided by SAP to lookup the data in the target R/3 or DB systems with the API provided.
    You need to write UDF in order to implement the API's provided by SAP.Consider the below example
    VendorNumber-UDF--CURR
    The scenario is legacy to SAP. The legacy system doesn't provide the currency details. But the target field need's to be populated with currency value.
    "The business rules says there are values maintained in SAP Table where if you pass VendorNumber it will return thr currency to you"
    So what you can do? You can write UDF implementing SAP Provided API's and do a lookup in the SAP System and get back the currency value and populate them in CURR field.
    I hope it clears a bit.
    Please find the below blogs
    DB Lookup: /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
    Edited by: BVS on Jun 27, 2008 1:08 PM

  • Integration with Restful webservice i..e Request details

    Dear Experts,
    After going through several blogs and attempting in system , I am not really convinced with the way my results are shaping up.
    There are 2 systems SAP ABAP portal and JAVA portal. I am having a scenario when any user logs in ABAP web dynpro portal and executes task, his details from JAVA portal should fire response with user details.To achieve this , SAP PI is used to integrate the JAVA application supporting JSON format i.e. Restful adapter.
    I referred the excellent blog  http://scn.sap.com/community/pi-and-soa-middleware/blog/2012/08/11/calling-synchronous-restful-web-service-with-pi--i  and but still issues keep cropping with unexpected one.
    If experts come across any of suitable answers , please hit my queries with the solution.
    1.I created a message type with single node , but unable to perform proxy test in Sender ECC as the execute button in greyed out.Is this is the correct way to create a MT with a single node.
    2.Should the UDF mapping for the dynamic URL be mapped to the primary node of request and response MT.
    3.How does the JAVA UDF in SAP PI captures the User details in ECC during runtime.
    4.Which URL i.e. the parameter entered in the SOAP adapter or the URL in the TServerLocation connects the receiver JAVA application.
    5.Whether the receiver SOAP adapter with HTTP Axis, be able to perform HTTP Method = POST and Content Type = application/x-www-form-urlencoded.
    6.The connection URL to the JAVA application has character "&". Would it cause error during runtime.
    7.I am using chrome POSTMAN test toll.
    Request experts to push the answers in sequence wise.
    Many thanks in advance..
    Regards
    Rebecca Alice.....

    Dear Experts,
    Any suggestions and , is greatly appreciated..
    Regards......

Maybe you are looking for

  • How Would you Know if Mountain Lion is Downloading?

    Hi. App Store had me update the info in the billing section which I did. When I updated it and click done it came back to the Mountain Lion page still with the icon Buy App. I clicked that for a second time but it said (something like) that I I've al

  • Email Notification of Purchase Order

    Hi Gurus We are on SAP 4.7 doing an MM implementation. We have the following requirement: We have 2 levels of PO release. When the PO is created or changed, an email notification should be sent to the person responsible for 1st release. When the 1st

  • WiDi or Miracast on a Pavilion 400-297hk

    I have a Pavilion 400-297hk which I bought a few months ago on the understanding that it was "WiDi-ready". But now I come to try to set up the WiDi I can't get the system to recognise that it is capable of it. I'm running Windows 8.1. This Pavilion m

  • Illustrator cs4 will not open

    I have tried everything Illustrator CS4 will not open

  • I would like to combine two external hard drives into one?  How do I go about doing this?

    Hello:   In iPhoto I have an old external hard drive (EHD) with a photo library and a new one EHD with a photo library which has more space.  I would like to move all the photos from the old EHD to the new EDH.  Can you show me the steps to get this