Hierarchical mapper - if then else condition maintaining loop

Five Stars

Hierarchical mapper - if then else condition maintaining loop

Hi,

I have to map EDI file to Text file. I am getting issue in mapping using Hierarchical mapper.

I am getting below error "Change loop Specification" -

 

The output map element: /root/Loop-NP17/NP34/Starttidspunkt_for_fapportperiode

is already looping using: in$/Transaction-SLSRPT/Loop-UNB/Loop-UNH/Loop-S005 (SimpleLoop)

which is not compatible with: in$/Transaction-SLSRPT/Loop-UNB/Loop-UNH/Loop-S005/DTM

Do you want to change the output map element looping?

 

Can anyone help me in this issue fix.

Tags (1)

Accepted Solutions
Community Manager

Re: Hierarchical mapper - if then else condition maintaining loop

I'm afraid I can't tell you how to fix this using a variable. I would have to use an element of trial and error on this even if I had your data. My suggestion is to go back to try using the IF condition that you tried, but change the outputs to true or false. The errors you had trying that were because you were not outputting true or false.

View solution in original post


All Replies
Community Manager

Re: Hierarchical mapper - if then else condition maintaining loop

Can you share a screenshot of your map? Also, is this error caused by adding the IFThenElse function?

Five Stars

Re: Hierarchical mapper - if then else condition maintaining loop

Hi,

Thanks for your reply. I have attached map screenshot.

I have progressed in map output.

Now ,the issue is I am getting NULL values too in output,which I do not want. Can you please let me know how to remove NULL values from output.

 

like output is coming as -

NP34
NP34
NP34 201910012300201910022300

 

But I want output only asNP34 201910012300201910022300

 

Please suggest.

Five Stars

Re: Hierarchical mapper - if then else condition maintaining loop

attached output file which is currently coming.

Community Manager

Re: Hierarchical mapper - if then else condition maintaining loop

Do you get the looping on this field if you remove the IF condition?

Five Stars

Re: Hierarchical mapper - if then else condition maintaining loop

yes, get the looping on this field if you remove the IF condition.

 

I only want the fields where source field is 51 or 52. Others are coming as NULL now, but we do not want to come those as NULL too.

Community Manager

Re: Hierarchical mapper - if then else condition maintaining loop

It's really difficult to think about this without having access to the actual mapper. But have you tried using the EMIT tab? This should help you conditionally remove the field.

Five Stars

Re: Hierarchical mapper - if then else condition maintaining loop

Hi,

 

Thanks for your replies.

 

I tried emit tab. but my target node NP34 requires a Null value coming to source to Emit. But, I have condition to check 51 or 52 value,otherwise its giving null value as output.

 

How to put these condition in Emit. Can you please try to give any example in screenshot from talend studio. The example should check all values of incoming node and emit only values like 51,52 or any other constant.

 

One of the error I am getting while emit usage is -

Overall: Error
1: Error - The referenced map element loops but there is no looping function that specifies how to handle this loop. (222) (INPUT)
Expression: Emit
Referenced Element : Map: Maps/SLSRPT_Recognition.xml - Map Element: in$/Transaction-SLSRPT/Loop-UNB/Loop-UNH/Loop-S005/DTM
Enclosing [Map] Element : Map: Maps/SLSRPT_Recognition.xml - Map Element: out$/root/Loop-NP17/NP34

 

 

Community Manager

Re: Hierarchical mapper - if then else condition maintaining loop

First of all, the values that are being returned (which aren't null) are they the correct aggregate values? If this is the case, you should be able to apply the same logic in your EMIT logic. Alternatively you could try setting a variable with this aggregate logic and checking the variable value to see if it is null or holds a value.

Five Stars

Re: Hierarchical mapper - if then else condition maintaining loop

Hi,

Thanks for your reply.

 

If i copy the same logic in NP34 node in emit, I am getting error. Error attached in Map_3.jpg

 

regarding variable, can you please let me know how and where can I create variable and access it in Hierarchical mapper.

Five Stars

Re: Hierarchical mapper - if then else condition maintaining loop

I tried to SetVariable and GetVariable.

I am calling GetVariable and checking its Null or not for main node NP34. But it gave error -

2: Error - The transformation code (XQuery/XSLT) failed to compile. (201)
Exception: net.sf.saxon.trans.XPathException: Axis step attribute::attribute({http://www.w3.org/2001/XMLSchema-instance}nil, xs:anyAtomicType) cannot be used here: the context item is an atomic value
at net.sf.saxon.expr.AxisExpression.typeCheck(AxisExpression.java:85)
at net.sf.saxon.expr.ExpressionVisitor.typeCheck(ExpressionVisitor.java:181)
at net.sf.saxon.expr.FilterExpression.typeCheck(FilterExpression.java:181)
at net.sf.saxon.expr.ExpressionVisitor.typeCheck(ExpressionVisitor.java:181)
at net.sf.saxon.expr.FunctionCall.typeCheck(FunctionCall.java:118)
at net.sf.saxon.expr.ExpressionVisitor.typeCheck(ExpressionVisitor.java:181)
at net.sf.saxon.instruct.Choose.typeCheck(Choose.java:249)
at net.sf.saxon.expr.ExpressionVisitor.typeCheck(ExpressionVisitor.java:181)
at net.sf.saxon.instruct.ParentNodeConstructor.typeCheck(ParentNodeConstructor.java:165)
at net.sf.saxon.expr.ExpressionVisitor.typeCheck(ExpressionVisitor.java:181)
at net.sf.saxon.expr.ForExpression.typeCheck(ForExpression.java:119)
at net.sf.saxon.expr.ExpressionVisitor.typeCheck(ExpressionVisitor.java:181)
at net.sf.saxon.query.XQueryFunction.compile(XQueryFunction.java:365)
at net.sf.saxon.query.XQueryFunctionLibrary.fixupGlobalFunctions(XQueryFunctionLibrary.java:198)
at net.sf.saxon.query.QueryModule.fixupGlobalFunctions(QueryModule.java:1033)
at net.sf.saxon.instruct.Executable.fixupQueryModules(Executable.java:625)
at net.sf.saxon.query.QueryParser.makeXQueryExpression(QueryParser.java:107)
at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:343)
at com.oaklandsw.transform.runtime.xquery.saxon9.Saxon9AdaptorImpl.compile(Saxon9AdaptorImpl.java:395)
at com.oaklandsw.transform.runtime.xquery.XQueryAdaptorImpl.compile(XQueryAdaptorImpl.java:66)
at com.oaklandsw.transform.runtime.xquery.XQueryAdaptorImpl.compile(XQueryAdaptorImpl.java:93)
at com.oaklandsw.transform.runtime.StandardMapRuntimeImpl.compile(StandardMapRuntimeImpl.java:162)
at com.oaklandsw.transform.runtime.StandardMapRuntimeImpl.runSubclass(StandardMapRuntimeImpl.java:232)
at com.oaklandsw.transform.runtime.MapRuntimeImpl$1.run(MapRuntimeImpl.java:405)
at com.oaklandsw.transform.runtime.RuntimeEngineImpl.runSansEditor(RuntimeEngineImpl.java:1147)
at com.oaklandsw.transform.runtime.MapRuntimeImpl.runMap(MapRuntimeImpl.java:396)
at com.oaklandsw.transform.runtime.MapOrStructRuntimeImpl.run(MapOrStructRuntimeImpl.java:805)
at com.oaklandsw.transform.editor.AbstractEditorContributor$6.run(AbstractEditorContributor.java:871)
at com.oaklandsw.gui.AppEditorImpl$22.run(AppEditorImpl.java:2417)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

Community Manager

Re: Hierarchical mapper - if then else condition maintaining loop

The EMIT value needs to be true or false. Your errors are based on the fact that the aggregate calculation does not return a boolean. You will need to shift this expression around to produce true or false.

Five Stars

Re: Hierarchical mapper - if then else condition maintaining loop

please suggest how to create variable and use it.

Community Manager

Re: Hierarchical mapper - if then else condition maintaining loop

I'm afraid I can't tell you how to fix this using a variable. I would have to use an element of trial and error on this even if I had your data. My suggestion is to go back to try using the IF condition that you tried, but change the outputs to true or false. The errors you had trying that were because you were not outputting true or false.

View solution in original post

Five Stars

Re: Hierarchical mapper - if then else condition maintaining loop

Hi, Thanks again for your reply.

If I am using boolean function (isNull then IF) on main node NP 34, it gives below error -

 

Cannot paste 'IfThen' on 'Input Value'

Caused by: 'IfThen' has a type of 'Simple Category' which is not compatible with the expected type of 'None/Sequence'

 

Please advise.

Community Manager

Re: Hierarchical mapper - if then else condition maintaining loop

Can you raise a support call on this issue? Problems with the TDM are very difficult to resolve remotely. Support will be able to share your screen and see your issue live. This should help them identify the issue and get it resolved.

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 3

Read about some useful Context Variable ideas

Blog