cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Logic

Former Member
0 Kudos

Dear friend's

I have one requirement as follows

There is field - First Name from soure . This file is mandatory to Target based on condition.

Condition:

There is field Application Type from source.

When the Application type is "P" then First Name is Mandatory in target

When the Appication Type is "A" then First name is optional in target.

How to make this possible?

Renu

Accepted Solutions (1)

Accepted Solutions (1)

rajasekhar_reddy14
Active Contributor
0 Kudos

>

> There is field Application Type from source.

>

> When the Application type is "P" then First Name is Mandatory in target

>

> When the Appication Type is "A" then First name is optional in target.

>

> How to make this possible?

When you define target data type structure , you will specify the occurance of of your field , mandatory or 0 to 1 ot 1 to unbounded or 0 to unbounded.

in your case you have to define File name field not mandatory becayse one case you no need to pass the value.

you can check the condition using boolean equals like

ApplicationType
                               BooleanEquals---------->if then else------>target
   Constant[P]

if applicatuon type P then pass the value as per your requirement else pass othe rvalue.

one you define occurace of the element in data type,it is not possible to change in mapping level.

Regards,

Raj

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Renu,

As mentioned earlier, we are surely required to make the field 0:1.

However, if it is something like a runtime exception that you want to implement if the condition fails, one option would be to make the mapping fail using a udf which would fail if the field is empty like what is given below:-

-


String testFirst="";

String res=firstname;

if(type.equalsIgnoreCase("P"))

{

testFirst = firstname.substring(0,1);

}

else

{

res= firstname;

}

return res;

-


Here if firstname is emply, the substring would fail and would raise a runtime exception. Now if you dont want a runtime exception and just a trace is required, then we can go for a try catch block in the if.

Former Member
0 Kudos

HI,

There is field Application Type from source.

When the Application type is "P" then First Name is Mandatory in target

When the Appication Type is "A" then First name is optional in target.

Make the target field optional.

If Application type is "P" then map to the target field from source.

If Application type is "A" then DONT map to the target field from source.

Babu