Skip to Content
author's profile photo Former Member
Former Member

Java udf

Hello Sdn

File to IDOC

In my file : i have a text field which will have a value : purchase order nuber is purchord;customer number is cust1;invoice number is inv1;account number is acct1

In my target i have an idoc and there is a segment E1EDK01. I have to create this segment only if text value in the file contains : "customer number is "

In other words ,if the text in the file contains : purchase order nuber is purchord;ivoice number is inv1;account number is acct1

Then in this case E1EDK01 should not be formed.

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 30, 2008 at 10:14 AM

    Hi,

    Try with the below mapping

    src-->contain(udf)-->equalsS---->createIf--->E1EDK01
       constant(exist)--->
    

    UDF

    use cache parameter context

    public void contain(String[] a,ResultList result,Container container)
    {
     //write your code here
     int i,pos;
    for( i =0 ;i != a.length; i++)
    {
      pos =  a.indexOf("customer number is ");
      if(pos.equals("-1"))
           result.addValue("does not exists");
      else
           result.addValue("exist");
    }
    }
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 30, 2008 at 03:11 AM

    use the default function.. . creatIf node function...provide the condition and the node only be created if it satisfy the condition

    http://help.sap.com/saphelp_nw04/helpdata/en/c8/98e7d5c1620642973565ea3dd319d1/frameset.htm

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi

      If you have

      purchase order nuber is purchord;customer number is cust1;invoice number is inv1;account number is acct1

      always coming in this format.

      then you can try with standard mapping functions

       source -> Substring(33, 48) -> equalS(customer number) -> createif -> target node 

      if you are not sure of the position of customer number in the string then use this code

      source -> UDF ParseLine -> = (function) "null" (constant) -> not -> createif -> Target 

      source code for ParseLine

      String compare ="customer number";
      int x = a.indexOf(compare);
      if (x>0){
      return a;}
      else{
      return "null";}

      Thanks

      Gaurav

  • author's profile photo Former Member
    Former Member
    Posted on Oct 30, 2008 at 03:32 PM

    Thanks guys for the responses.

    Will award points and close the thread.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.