cancel
Showing results for 
Search instead for 
Did you mean: 

Correct my UDF

Former Member
0 Kudos

If TXT02 is null then Blank

else

OBJ=

TXT02 is under one segment say X

My logic which dint work

If X and TX02 exist and

TXT02 =(Equals ,text function) null ->if

Then " "

else TXT02="OBJ= "

actually we used BPM in this scenario.

Using the above logic,it shows error in swwl.

I tried to use a UDF.

TXT02-> if ! ( a[0].equals(null) ){

result.addValue("OBJ=");

}else{

result.addValue(" ");

}

The above logic doesn't throw any error in swwl,but even if TXT02=null or blank it always show OBJ=

ie it doestn't goto elsepart.

I am my using whitesapce assigned to the field TXT02 as it is one of the fields in the IDOC Segments,the Scenario is IDOC to FILE..I tried many ways using graphicl mapping it doesn't work.

Please suggest .

Thanks,

Srinivasa

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

As Sudhir had said, the whitspace is responsible to fail the condition.

Either instead of checking for Null, along with whitespaces you may check the length of a[0]. If its zero then pass OBJ= or else " ".

Thanks

Swarup

Former Member
0 Kudos

Hi ,

To avoid whitespace issue,I also tried this code

if(!(inval[0].length.equals(""))){

result.addValue("");

}

else{

result.addValue("OBJ=");

}

Thsi too dint take me to else part.

Former Member
0 Kudos

Hi,

Use as below



if(!(inval[0].length==0)){

Length function returns integer value i.e. 0 and no "" will work.

Thanks

Swarup

SudhirT
Active Contributor
0 Kudos

Hi,

To check the required condition try like this

if((a<i>.trim().length()) == 0){
result.addValue("");
}
else{
result.addValue("OBJ=");

}

Thanks!

Former Member
0 Kudos

when I used this code,I am getting the below error.

/usr/sap/XD1/DVEBMGS30/j2ee/cluster/server0/./temp/classpath_resolver/Map189e7b00d58c11dd94e00003bacd2461/source/com/sap/xi/tf/_MM_INT040_WIRE_FUNDSTRANSFER_ITEMS_.java:2036: cannot resolve symbol symbol : variable length location: class java.lang.String if ( !(a[0].length== null )) ^ 1 error

Former Member
0 Kudos

I tried this,

if((a[0].trim().length()) == 0){

result.addValue("");

}

else{

result.addValue("OBJ=");

}

Still it shows OBJ=, even if TXT02 is blank.

SudhirT
Active Contributor
0 Kudos

This should work with output as "". Save the UDF first and then the mapping and then activate and test it again. Also check in display Queue in mapping step what value it is displaying before the UDF in source Field.

Thanks!

Former Member
0 Kudos

No ,This is not working.

I tried in the same way as you told.

Answers (4)

Answers (4)

Former Member
0 Kudos

Please use the UDF like below

if ( a[0] != null)

{

result.addValue("OBJ=");

}

else

{

result.addValue(" ");

}

tell me if it works

SudhirT
Active Contributor
0 Kudos

Hi,

I am my using whitesapce assigned to the field TXT02 as it is one of the fields in the IDOC Segments

This is the reason thats why its not going to else part, You are comparing with Null Value(Node TXT02 not existing) and passing always with the whitespaces. Your condition will work only if the node TXT02 is not coming in the source file.

Thanks!

Former Member
0 Kudos

Hi,

Try following graphical mapping

Don't change any context for input fields.

                                           (if true)TXT02 --> CollapseContext --> 

TXT02 --> CollapseContext --> 
                                  Equals-->     If  --> SplitByValue-->TargetField
            Constant(Blank)-->

                                             (if false)OBJ--> CollapseContext -->

-Rohit

Former Member
0 Kudos

Have you used value or context when creating this mapping?

If it is value; use a instead if a[0].