Help in UDF

Hi,
Need ur help in creating UDF, i have source fields in Order IDOC under subsegment EDP35 of EDP01 segment.
QUALZ
CUSADD
CUSADD_BEZ
and target fields:
RT
RU
RC
ET
I tried graphical maping as follows:
1) If Qualz = 001 and CUSADD exists then RT else Constant
2) If Qualz = 004 and CUSADD exists then ET else Constant
3) If Qualz = 001 and CUSADD_BEZ exists then RC else Constant
4) If Qualz = 004 and CUSADD_BEZ exists then RU else Constant
It is not throwing any mapping error but the values containing in the fields are not populating properly, as CUSADD & CUSADD_BEZ fields are repeating based on EDP01 segment.
Can any body suggest me a suitable UDF plz?
regards

Hi Vijaya,
as I told a UDF will probably NOT solve your mapping.
As I told use right-mouse ( in the graphical mapping field) --> queue an "debug" your mapping. Therefor create first a test-message in tab "test".
Play a litte with this; you will find it out
The other suggestion is to create a simplified version. Create a data-type that is similar to the IDOC (same hierachy but DO NOT use all IDOC fields. This ist irritating you)
Maybe splitByValue could also be a solution.
Is the hierarchy of the IDOC you wrote correct?
Is the occurance of the fields you compare the same?
Regards Mario
Message was edited by:
        Mario Müller

Similar Messages

  • 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.

  • Help with UDF code ...

    I got the below code. It returns the FileName from File sender adapter. Works fine when running the complete scenario, but when running it from the mapping test utility it FAILS. Obviously because there is no filename since I am testing in my mapping but how to code it so I can run it during my testing of the graphical mapping?
    UDF ->
    String tomstreng = ingenting[0];
    //write your code here
    DynamicConfiguration attrib =
    (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    //to create key
    DynamicConfigurationKey fileKey = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
    String navnpaafil =  attrib.get(fileKey);
    if (navnpaafil |= null)
    result.addValue(navnpaafil);
    result.addValue("");

    >
    sunil chandra wrote:
    > You can't test it independently in test tab. Need to run the full scenario for testing the mapping.
    >
    > Regards,
    > Sunil Chandra
    you can always use a try catch to handle the code and thus help test it independently - refer my blog

  • Need help in UDF

    Hello Gurus,
    Could you please help me if v need any UDF for splitting or can i do it with graphical mapping.
    Below is the source structure
    <header>id123</header>  
    <item>item123</item>         
    <data>abd1232011
    ^^efg4562011
    ^^hij7892012</data>
    Required target structure
    <header>id123</header>       1:1
    <item>item123</item>             1:1
    <content>                               1:1          
    <data>                                    1:unbounded
        <char>abd</char>
        <num>123</num>
        <date>2011</date>
    </data>
    my requirement is to break the 1 source field "data" into  3 target fields "char","num","date". Field data is of type string and received as a raw string. The new line is determined by "^^" in the string. fields are separated by "~"
    Kindly help
    Thanks in advance.

    which version of PI u r working on??
    In case ur version is PI7.1 (or greater) then chk this code:
    UDF1:
    Input will be: var1 of type argument
    and add 3 result type with name result1, result2, result3
    Execution type: all values of a context
    String [] temp = var1[0].split("^^");
    for(int i=0;i<temp.length;i++)
    String [] split1 = temp<i>.split("~");
    result1.addValue(split1[0]);
    result2.addValue(split1[1]);
    result3.addValue(split1[2]);
    result1.addContextChange();
    result2.addContextChange();
    result3.addContextChange();
    UDF2:
    String [] temp = var1[0].split("^^");
    for(int i=0;i<temp.length;i++)
    result.addValue("");
    mapping:
    Input----UDF2---data
                           -----char
    Input----UDF1 -------num
                        -------date

  • Mapping help or UDF

    Hello Friends,
    I need some help in mapping through regular or UDF.
    Requirment is I have target field CORD_CODE,
    This needs to ge the value based on the segment values of EIEDT44-VSTEL
    If VSTEL = CO10 then 1055
    If VSTEL = CO11 then 1054
    If VSTEL = CO13 then 1057
    If VSTEL = CO12 then 1056
    Like this.
    Can we create UDF for the same or anyt other alternative?
    <removed by moderator>
    Regards
    Ramesh
    Edited by: Mike Pokraka on Jul 24, 2008 1:46 PM

    Hi Ramesh,
    This error Cannot produce target element /ns0:MT_GuiaTransport/DELIVERY_RECORDS[2]/MERCK_COORD_CODE could be becaus of two reasons
    1. Node VSTEL would have not been in the source structure.
    2. Value in the node would have been different than the possible values.
    Solution:
    In addition to this graphical mapping
    If VSTEL = CO10 then 1055 else drag and drop another if-then-else and if VSTEL = CO11 then 1054 else drag and drop another if-then-else and if VSTEL = CO13 then 1057 and drop another if-then-else and if VSTEL = CO12 then 1056 .....
    1. First check if the node VSTEL exist then check the conditions else map a constant.
    2. Add a constant to the else part of the last condition check i.e if VSTEL = CO12 then 1056 else constant.
    Thanks
    SaNv...

  • Help with UDF

    Hi,
    I would like to send a email using UDF.
    Requirement: if xyz == "9" then send a email and also pass the value .......
                          else directly pass the value
    I want to do it without Looksups, exclusively using Java code inside UDF.
    has anyone done this earlier? Can someone help me?
    thanks,
    Venkat.
    Edited by: Venkat A on Jul 22, 2009 10:58 PM

    >
    Venkat A wrote:
    > I have following doubts in the actual code.
    > 1. "<mailhost>"  - What should I enter the value for this?
    this is your mail server .. ex. smtp.yahoo.com etc
    > 2. do I need to provide a sender ID that is existing? I mean if I provide the xi.adm at dev.com... does it really need to exist in real?
    it can be anything that you want to be in the from id of your email
    > 3. How do I use imported archieve?i mean I have a normal MM now. how do I link that imported achieve?
    >
    > Thanks,
    > Venkat.
    >
    > Edited by: Venkat A on Jul 23, 2009 12:03 AM
    in the UDF give you package name in the imports section ... the screenshot of the UDF in the link also shows this

  • Help on UDF

    In an UDF, I want to access the whole XML string the mapping is applied to i.e. the <b>complete</b> source message structure. Is it possible?
    Regards,
    Amol

    Hello Arnol,
    you cannot do this in an UDF.
    The following thread explains how to map the whole source message to a single target field with XSLT or Java mapping, it might be helpful:
    XML to single element: Attn: Henrique
    Regards,
    Matthias

  • Need help on udf by my requirement

    Hi folks,
    I am working on file to idoc
    My input file has 1 field and output Idoc has 5 records.
    in my input Account field has length 16.   in this length 16. this field is mapping to all the fields of output.
    for example account field has    1234 67 86 34 33.  I need to map 1234 to field 1
    67 to field 2
    86 to field 3
    34 to filed 4
    33 to field 5.
    for every space we need to split and need to map output field.   after completing this I need to sort the field 1 of output.  please explain me.   Account data may very
    examples  input file :
    1238 67 86 34 33
    1234 66 86 34 33
    need output as   1234  67 86 34 33
                                1238  66 86 34 33
    here only first field is sorted i.e 1234 and 1238 ....remainiing fields need to be same
    ur help is highly appreciated.
    Thanks,
    enivass

    Hi,
    Since you can have spaces any where in the file/field, use "String Tokenizer" concept, you will not need java mapping, you can use graphical mapping and write UDF by selecting "All values of the Queue/Context"
    Here are some useful links:
    Re: Split a string with character "+" as separator
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/StringTokenizer.html
    http://www.javafaq.nu/java-example-code-195.html
    http://www.devdaily.com/java/edu/pj/pj010006/ - Concept
    http://download-llnw.oracle.com/javase/1.4.2/docs/api/java/util/StringTokenizer.html - Concept
    http://www.java-examples.com/java-stringtokenizer---specify-delimiter-example - with Delimiter
    Regards,
    Pavan

  • Help regarding udf

    Hi Experts ,
    I have a requirement in which I have to pad an incoming string with spaces based on it's length so that it's size ultimately become 10 character...can anyone give me a udf code for the same.I  have tried myself but it didn't work

    <i>>>>i hope under no circumstances the length will exceed 10</i>
    You can guard against this by putting in another statement at the beginning:
    if (str.length() > 10)
        return str.substring(0,10);
    ...  rest of your original code
    Regards,
    Jin

  • UDF - Removing Header Record from File

    Hi Team,
    In my file(File Content Conversion) to ABAP server proxy scenario...
    The source File structure is like this...
    KUNNR|Matnr|Description----->(This is Hearder Record.Each File contains this header record.)
    1001|0077321|Special Materials
    1002|0077323|Raw Material
    File adapter will picks the file , In Message Mapping The first record is the Header Record from the above file structure.So I need to remove the Header Record.
    Can we handle  this requirement with any FCC parameter ;I think we can do it with the help of UDF in MessageMapping?
    Can anybody ghelp me the sample code for this.
    Thanks.
    Drumi

    Hi,
    You can use Document Offset in FCC to  specify the number of lines that are to be ignored at the beginning of the document.
    Regards,
    Priyanka

  • What is an UDF and UDT

    Hi everyone,
    we are using SAP Business one 2007 A and I would like to know what are User Defined Fields and User Defined Tables? What are the uses of both and what do they do? Please explain how to create a UDF and a UDT? Thank you.

    >What kind of customization can be done with the help of UDF and UDT. If I set up a UDF and UDT in my workstation, will it >be shared by everyone or only I can use those UDF and UDT?
    The authorization is controlled in SAP B1 through Setup->User defaults and Admin->User Authorizations panel. The authorizations are based on what you provide above to marketing documents, production documents, service documents etc.
    UDF is just part of above SAP B1 authorization control. You can not control authroization for just UDF you created. It is based upon what user, what authorization it has.
    >For example: If I am seeing an AP invoice list, can I add a field to show the check number with which the invoice was paid? Why I am asking this because we have an AP person in our company and whenever a vendor calls, she has to browse through 5-6 screens to get to that payment information and the check number does not show up when she pulls up the invoice list.
    >Yes above is possible. And these are the real world examples of why UDFs are used. The queries you use to populate them can get tricky, there are highly talented and able people on forum who can help you out with those. But you have to get started somewhere.
    >With the help of UDF, can I pull any information anywhere? How does this work? Where can set the UDF and UDT meaning in what areas? Can it be set only in master data?
    There are limitation to UDF, you can not pull anything everywhere or anywhere. That level of visibility will require SDK development. You just have to try and learn about the scope. I am not sure about it.
    When you go tools->Customization tools->User defined field management, you will see the areas and sub levels you can use.
    The rule of the forums is one question per thread. It helps if you can adhere to that.  Also, please close the thread, if it is answered. Welcome again!

  • Map Field names to target side

    Hi Gurus,
    I have a critical Requiremnet where in i need to map the field names from Source structute to the target structure..
    For Example:
    My Source structure:                                                       
    <matnr> 123</matnr>                                                          
    <maktn>XYZ</maktn>
    Expected Target structure:
    <Node>
    <Fieldname>matnr </DFieldname>
    <Fieldvalue>123</Fieldvalue>
    </Node>
    <Node>
    <Fieldname>maktn </DFieldname>
    <Fieldvalue>XYZ</Fieldvalue>
    </Node>
    Any Blog on this is highly Appreciated.
    Best regards,
    Sainath Chutke
    Edited by: Sainath Chutke on Feb 23, 2009 8:42 PM

    Hi Sainath,
    This is possible using graphical mapping with the help of UDF.
    A simplified mapping will look like this:
    For Fieldname
    constant: MATNR --> useOneAsMany --> 1. UDF -
    > Fieldname
    MATNR --> removeContext --> /
    MATNR --> removeContext --> /
    constant: MAKTN --> useOneAsMany --> 2.
    MATNR --> removeContext --> /
    MATNR --> removeContext --> /
    where 1 and 2 are the inputs to the UDF.
    For Fieldvalue
    MATNR --> removeContext --> 1. UDF --> Fieldvalue
    MAKTN --> removeContext --> 2.
    Note that you can eliminate the node removeContext just make sure that you set the context to the topmost level of the hierarchy.
    The UDF that will be used is of context type: There are two input arguments, input1 and input2:
    Here is the code:
    StringBuffer e = new StringBuffer();
    String b = null;
    for (int a = 0; a<input1.length; a++){ e = e.append( "/" + input1[a]);}
    for (int a = 0; a<input2.length; a++){ e = e.append( "/" + input2[a]);}
    e = new StringBuffer(e.substring(1,e.length())); b = e.toString();
    String c[] = b.split("/");
    for (int a = 0; a<c.length; a++){result.addValue(c[a]);}
    What this UDF does is to add the contexts of the input, it is also taken into consideration multiple occurrences of the MATNR and MAKTN e.g.
    MATNR = 12,1234
    MAKTN = XYW,XYZ
    The output for Fieldname is MATNR,MATNR,MAKTN,MAKTN
    The output for Fieldvalue is 12, 1234, XYW, XYZ
    Hope this helps,

  • Disabling TAB key for specific users

    Good day,
    I am new to SAPand the company will start pretty soon using SAP B1 8.8. We are facing the problem of disabling the TAB key function which give access to a complete list of some tables (in the particular case of financials, all G/L accounts) which is considered confidential and should not be available to any employee. Our actual SAP consultant says that the only solution is to make a special chargeable modification to standard SAP. I find it strange that SAP gives such an open an uncontrolled access to such vital information of the company. I am sure some one on this forum will give me a practical, elegant solution built in SAP authorization mecanism.

    Hello,
    Yes we can do it by Addional authorization
    You can do it by Additional Authorization windows using by Form ID.
    and then goto general authorization select Additinal Athorization as (No authorization) for selected user.
    now selected user can not open Buisness partner on any transaction form .
    then Make a Query for selected BP for selected User and set in on that field .
    1>
    First make new Authorization in Additional Authorization Creator window.
    And select Edit button fill 10001 as form ID.
    OK
    2 >
    Goto General Authorization select perticular user and select same Subject which was created in Additional Authorization window setup. and give no authorization for selected user. ok
    3.Make a FMS from OCRD ,but first you should make filter in master for selected user in SAP. so with the help of we can filetr the record on transaction .
    4.After make FMS with then help of UDF set it in where you want .
    Now Your system is ready for your client requirement.
    Please visit this link
    Re: BP according to user
    Thanks
    Manvendra Singh Niranjan

  • Warehouse Setup

    Dear All,
    Can anyone help in maping following scenarioo for warehouse.
    Our client maintains inventory in follwing manner:
    There is only 1 Main warehouse for eg WH01.
    This warehouse is divided in to different segments like Shelf and Blocks. The structure is as follows:
    Warehouse--ShelfBlockLevel-----Final Destination of Material
    WH01--S1A1--
    WH01-S1-A1
    WH01--S1A2--
    WH01-S1-A2
    WH01--S1A3--
    WH01-S1-A3
    WH01--S1A4--
    WH01-S1-A4
    Like wise total  is as follows:
    No of Shelf: 6 ( S1 to S6)
    No of BLocks: 13 ( A to M)
    No of Levels: 4 (Leval 1 to Level 4).
    This will be general scenarion for companies which stores material in such manner.
    Any solutions for the same will be highly appreciated.
    S.R.P.

    Hi!
    I have two recommendations for the same,
    1. Create as many combination of warehouse.
    -- This will help u to track the stock at its exact location.
    -- You can avail all the SAP B1 Reports for inventory.
    2. Create only warehouses, not those shelf,...
    -- Manage those details in Document Level using the help of UDF's.
    -- The Report Precision will highly depend on Data Entery.
    -- No SAP Default Reports will help.
    -- Customised Reports only give expected output.
    -- Very Difficult to do Opening Balances, Stock Counting, Revaluations etc..
    450 warehouse in not a matter. But, you should be very keen in adding warehouse to items. Don't add all warehouses to all items.

  • 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.

Maybe you are looking for