cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help In The Mapping!!

Former Member
0 Kudos

Hi,

The scenario is,

The Characteristic Name is a 0-unbounded field,

If the Characteristic Name endsWith u201CSTATEu201D,

Then,

We have to check the Characteristic Value, if it is u201CFreshu201D, u201CFrozenu201D or u201CDryu201D,

Accordingly we have to return value( map to stateIndicator ).

If I am using Graphical Mapping, it is getting partially solved.

Problem:

If the case is,

Characteristic Name occurs only once and it is ending with STATE or it is not ending with STATE, the mapping works fine.

But,

If it occurs more than 1, and if the 1st Characteristic Name is not ending with u201CSTATEu201D then, it is not checking the Characteristic Name which follows, and directly returns an empty value.

If I am using the following UDF instead graphically checking th "STATE" part,

int flag=0;
while(var1.indexOf("STATE")!=-1)
{
        if(var1.endsWith("STATE"))
        {
                flag=1;
        }
 }
if (flag==1)
{
    return true;
}

//Since the default return value of the UDF is String in PI, I am getting ERROR "Type Imcompatibility Required String, Getting Boolean"

Please reply with what change can I make to the UDF or a solution which I can use instead.

Thanks and Regards,

NehaSingh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mr,

For return value, try this:

String result;

if (flag==1)

{

result = "X"

return result;

}

For occurences:

Where you have mapped the UDF?

Answers (4)

Answers (4)

deepak_shah
Contributor
0 Kudos

Hi Neha,

Change the context of both source field to Parent node.

If this doesnt work the you can use node function to solve it.

This can be achived using node function rather than going for UDF.

Regards,

Deepak

Former Member
0 Kudos

Hi All,

Thanks for your reply.

I used "REMOVE CONTEXT" function, after my if else logic in graphical mapping,

i.e

if(classificationName endsWith "STATE" then "REMOVE CONTEXT" --> stateIndicator)

Because of the using the above part in the mapping, when classification name is occuring more than once, all the relative classifictaion value are mapped to the state indicator.

This has worked for me.

Thanks,

NehaSingh

former_member333459
Participant
0 Kudos

Hi,

You can give the LOGIC in GRAPHICAL mapping like if the source field Characteristic Name ends u201CSTATEu201D, AND if the Characteristic Value,is u201CFreshu201D,OR u201CFrozenu201D OR u201CDryu201D,

then map the target field using if without else condition provided if the targer is also 01 or o-unbounded.

Hope this may help.

Regards,

Neethu

Former Member
0 Kudos

Hi Neha ,

try this UDF it will work for ur requirement .

two input Cname and Cvalue ( your corresponding name and value field )

while creating the UDF make it as queue level . when u will be creating the UDF then it will ask .By default it is as value u have to make it as queue level .

UDF is :

for ( int i=0;i<Cname.length;i++)

{

if ( Cname<i>.endsWith('STATE" ))

{

result.addValue(Cvalue<i> );

}

}

This UDF will map the corresponding CValue to target in which Cname satisfy the condition .

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>>//Since the default return value of the UDF is String in PI, I am getting ERROR "Type Imcompatibility Required String, Getting Boolean"

One solution for the above error ...You are returning boolean here. You can return string as below

int flag=0;
while(var1.indexOf("STATE")!=-1)
{
        if(var1.endsWith("STATE"))
        {
                flag=1;
        }
 }
if (flag==1)
{
    return "TRUE";

}else{
   return "FALSE";
}

In mapping..

check equals function at the output of target and see it has "TRUE" , if true then do what you want...