TxmlMap separating Two output insteat of one output

Six Stars

TxmlMap separating Two output insteat of one output

Hi every one,

i have a job which is handling xml input and validating based on some conditions and getting output response.
my xml having multiple preference loops and im comparing this with existing pre_lookup table data if data matches the data should save in pre_match output ,if not data should save to pre_notmatch output, but the problem is my job txmlamp checking the 1st loop if its correct saving data in pre_match output and if 2nd loop is wrong its saving data in pre_notmatch output . i want my job should check both loops if both should match then only it should save the data to pre_match else it should save data in pre_notmatch output.
below is my xml input formet
<?xml version="1.0" encoding="UTF-8"?>
<PublishCustAccountMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://tuiuk.com/xsd/interface/customer/pubcustaccount/v1">
<CustomerAccount>
<CustomerID>1077563054</CustomerID>
<CustomerAccountID>444</CustomerAccountID>
<Status>Active</Status>
<Preferences>
<Preference>
<CustomerPrefID>1000000172</CustomerPrefID>
<CustomerPrefType>PREFERRED_BOARD_BASIS</CustomerPrefType>
<CustomerPrefValue>SELF CATERING</CustomerPrefValue>
<CustomerPrefValidFrom></CustomerPrefValidFrom>
</Preference>
<Preference>
<CustomerPrefID>1000000177</CustomerPrefID>
<CustomerPrefType>PREFERRED_BOARD_BASIS</CustomerPrefType>
<CustomerPrefValue>ROOM</CustomerPrefValue>
<CustomerPrefValidFrom></CustomerPrefValidFrom>
</Preference>
</Preferences>
</CustomerAccount>
</PublishCustAccountMessage>
and this is my existing pre_lookup table
pref_type pref_value
PREFERRED_BOARD_BASIS ALL INCLUSIVE
PREFERRED_BOARD_BASIS FULL BOARD
PREFERRED_BOARD_BASIS HALF BOARD
PREFERRED_BOARD_BASIS ROOM ONLY
PREFERRED_BOARD_BASIS SELF CATERING
so i am giving wrong input pref_value as ROOM instead of ROOM ONLY, its checking and sending this data to pre_notmatch.
but my requirement is to check input if one loop is wrong either 'CustomerPrefType' or 'CustomerPrefValue' it should send output to pre_notmatch. How can i handle this ? should i give any conditions in txmlMap ??
i have attached my job screenshots ,Thanks in advance.
Community Manager

Re: TxmlMap separating Two output insteat of one output

Do an inner join between the main flow and lookup table on tXMLMap, and set Catch Lookup Inner Join Reject option as true for the output table with not matched rows.
I do a testing with your example data and I can get the expected result.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Six Stars

Re: TxmlMap separating Two output insteat of one output

Hi shong,
thanks for your reply, but my requirement is different , my job should send the data to matchedoutput table only when both loops matched, else it should data to notmatched table. see below logic

this is my existing pref_lookup table
pref_type pref_value
PREFERRED_BOARD_BASIS ALL INCLUSIVE
PREFERRED_BOARD_BASIS FULL BOARD
PREFERRED_BOARD_BASIS HALF BOARD
PREFERRED_BOARD_BASIS ROOM ONLY
PREFERRED_BOARD_BASIS SELF CATERING

Input
loop 1
CustomerPrefType: PREFERRED_BOARD_BASIS
CustomerPrefValue: SELF CATERING
loop 2
CustomerPrefType: PREFERRED_BOARD_BASIS
CustomerPrefValue: ROOM
output
not matched
Input
loop 1
CustomerPrefType: PREFERRED_BOARD_BASIS
CustomerPrefValue: SELF CATERING
loop 2
CustomerPrefType: PREFERRED_BOARD_BASIS
CustomerPrefValue: ROOM ONLY
output
matched
Input
loop 1
CustomerPrefType: PREFERRED_BOARD_
CustomerPrefValue: SELF CATERING
loop 2
CustomerPrefType: PREFERRED_BOARD_BASIS
CustomerPrefValue: ROOM ONLY
output
not matched
Input
loop 1
CustomerPrefType: PREFERRED_BOARD_BASIS
CustomerPrefValue: SELF RING
loop 2
CustomerPrefType: PREFERRED_BOARD_BASIS
CustomerPrefValue: RO ONLY
output
not matched
i hope you understand now, thanks in advance
Community Manager

Re: TxmlMap separating Two output insteat of one output

Hi
I think I understand you now, however, tMap process the incoming data row by row, you can't achieve it only with tMap component. A solution is to check the number of records in reject output after tMap, if it has records, meaning the current input has unmatched loop, all loops in this input should be output to unmatched table/file. For example:
....tMap--reject---tLogRow_2--runIf_1-->tFileInputXML--main--tMysqlOutput_1
--runIf_2---tFileInputXML--main---tMysqlOutput_2
We use a runIf connector to fires another a processing that read the current input file again and insert all the loops to a matched table or a unmatched table.
set the condition of runIf_1 as below, if the condition met, read the current input file again and insert all loops to unmatched table.
((Integer)globalMap.get("tLogRow_2_NB_LINE"))>0

set the condition of runIf_2 as below, if the condition met, read the current input file again and insert all loops to matched table.
((Integer)globalMap.get("tLogRow_2_NB_LINE"))==0

Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business