cancel
Showing results for 
Search instead for 
Did you mean: 

Making a Deliberate Fail in Graphical Mapping

Former Member
0 Kudos

Hello Friends,

We have a transformation logic in which we have to deliberately fail a mapping.

The Logic is

1) Concatenation of 3 fields.

2) After concat if length>9,make it boldFAIL.

If the len<=9,then pad as many zeros to make the length 11 and the add a constant 5 at the beginning

Now, how do we go about FAIL part of the mapping.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can achieve this by just a single line of code in UDF.

After check for length > 9 in if then else boolean function in graphical mapping.

call a UDF with following code.

 
public String callException(String var1, Container container) throws StreamTransformationException{ 

throw new RuntimeException("Length Greater than 9") ; 

return null; 

} 

If you want to display some message in the trace. you can use the trace object:

 

AbstractTrace trace = container.getTrace(); 
trace.addInfo("callException: Length greater than 9."); 

regards,

Aravind

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Please go through the following link which is exteremely useful:

/people/alessandro.guarneri/blog/2006/01/26/throwing-smart-exceptions-in-xi-graphical-mapping

This link should definitely solve your issue.

Thanks

Biswajit

Former Member
0 Kudos

Thanks all for the replies.

One more query.

"On availability of a CO_PA record from source, 30 CO_PA records need to be populated for E2BPACKEC segment in the Target".

How can we do this?

deepak_shah
Contributor
0 Kudos

Hi Sanjay,

can you explain your requirment more clearly?

Regards,

Deepak.

Former Member
0 Kudos

Hi Deepak,

The requirement is that there is a segment for CO PA data in a file. there are 3 segments overall. Header, Detail and COPA.

So, If the COPA segment has data in the source file, then in the Target. The segment E2BPACKEC in the Target IDoc has to occur 30 times in the Target.

Any good?

deepak_shah
Contributor
0 Kudos

Hi,

What is the occurence of segment E2BPACKEC. Is it 0..1 or 0...unbounded?

If it is 0..1, then you can duplicate the segment E2BPACKEC 30 times and put a condition that the node will occur only when there is data for COPA segment.

it is is 0 ..unbounded, youhave to write a udf.

Regards,

Deepak.

Former Member
0 Kudos

Thanks Deepak,

Yes I am aware of the fact that we need to write an UDF for it.

Could you help me out on it please?

Former Member
0 Kudos

Hi,

Here is the logic.

Copa --> exists --> Generate30Times --> Output.

UDF Generate30Times Code

//Queue type UDF

if(input[0].equals("true"))

{

for (int i=0; i<30;i++)

{

result.addValue("");

}

}

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Alternatively, you can use this mapping:


source --> lenght --> greater --> createIf --> RootNode
constant:8 ------------> /

Since it would be failing at the Root level if the condition is not met, you can use the second logic for the actual node

If the len<=9,then pad as many zeros to make the length 11 and the add a constant 5 at the beginning


source -------------> add --> target
constant: 500000000000 /

Hope this helps,

Mark

rajasekhar_reddy14
Active Contributor
0 Kudos

FAIL means>

you want to stop mapping execution , with red flag in MONI

clarify this point;

Regards,

Raj

Former Member
0 Kudos

Yes.

That would be the requirement.

Former Member
0 Kudos

hi,

create a UDF and put this in

throw new StreamTransformationException("test");