cancel
Showing results for 
Search instead for 
Did you mean: 

Java udf

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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");
}
}

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks guys for the responses.

Will award points and close the thread.

Former Member
0 Kudos

deleted the messg

Edited by: Guest1 guest on Oct 31, 2008 2:41 PM

Former Member
0 Kudos

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

Former Member
0 Kudos

thats what i m asking ,how to parse the text field?

I want a condition like if in source text field : have a string in the text as "Customer number" ,then the Target node should be created.

Thanks

Former Member
0 Kudos

check under heading "1. Mapping of <OrderCreateProductLineItem>". this uses "Exists" function....try

Former Member
0 Kudos

Hi

Create a UDF

pass the string to the UDF

check till the length of string equals "Customer number" return -> createif -> target node.

Thanks

Gaurav

Former Member
0 Kudos

I m not good in writing java code, can you tell what exactly what u r trying to tell by writing this code?

Thanks

Former Member
0 Kudos

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