Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Dynamic Schema for Mapping in tMap

Hi, I have an XML file which I receive on daily basis but the schema is given as follow,

 

C1

C2

C3, where the value of C1, C2, C3 fluctuates it can be one of {Location, Date, and Confirmation Number}.

Example of raw file of different date shared below.

0683p000009M1SZ.jpg0683p000009M1fw.jpg0683p000009M1g1.jpg

I need to map these fluctuations on a dynamic basis, please have a look at below screenshot `tMap`.0683p000009M1g6.jpg

How can I achieve this? Please help.

Thanks, 

Meet

 

 

Labels (3)
11 Replies
manodwhb
Champion II
Champion II

@meetmahajan,can you check below link. may be useful for your use case

 

https://www.youtube.com/watch?v=bLq8ip6nH5g

Anonymous
Not applicable
Author

Hi Meet,

 

     You will have to use the java functions to identify whether the input data is alphabet or number or date and based on the true or false condition, you can move them to target columns.

 

     But my recommendation would to educate your source team that they have to stick to the XML schema definition. For any systems where integration need to happen, the first step is to have an understanding about the interface schema definition and it is missing in this case.

 

      You are now trying to overcome it through additional logic in target systems. Could you please convey this message to them and check with them what is stopping them from transferring data in an agreed format?

 

Warm Regards,

 

Nikhil Thampi

Anonymous
Not applicable
Author

Hi @manodwhb 
Thanks for sharing your valuable knowledge, the video you've suggested is gradually containing different schema in a different file, but I have same input schema and same output schema in different files but the difference is having the attributes contains different values each day.
Please let me know if i've misguided and if you've any queries regarding this.
Thanks,

Meet

Anonymous
Not applicable
Author

Hi @nthampi

 

Can you please illustrate an example regarding Java function?

Thanks,
Meet

Anonymous
Not applicable
Author

Hi,

 

    Please refer below links to create the user defined functions for your need. You can embed it in routine and call them as functions from tMap. I would also suggest you to check the numeric and date operation functions of tMap.

StringHandling.IS_ALPHA("abc")
TalendDate.isDate(mydate,"yyyy-MM-dd HH:mm:ss")

 

https://stackoverflow.com/questions/1102891/how-to-check-if-a-string-is-numeric-in-java

 

https://stackoverflow.com/questions/226910/how-to-sanity-check-a-date-in-java

 

https://stackoverflow.com/questions/5238491/check-if-string-contains-only-letters

 

If the answer has helped you, could you please mark the topic as resolved? Kudos are also welcome 🙂

 

Warm Regards,

 

Nikhil Thampi

Anonymous
Not applicable
Author

Hi @nthampi

 

The issue is not to convert the values, it is to map input `Attributes`  to output `Schema` on the basis of `Values of Attribute`.

 
The detailed structure of an implementation @manodwhb 

Suppose for 11th Dec,

C1's value is `10-12-2018`, then it should map with `Date` attribute.

let say, for 12th Dec,

C1's value is `Ahmedabad`, then it should map with `Location` attribute.

Please let me know if you've any queries.
Thanks and Regards,

Meet Mahajan

Anonymous
Not applicable
Author

Hi Meet,

 

     That is quite straightforward using if else conditions. Following are the high level steps.

 

1) Input is C1, C2, C3

2) Verify each column as per the functions in above link and identify whether it is Alphabet(A), Number(N) or Date (D)

     eg:-     if (StringHandling.IS_ALPHA(input_row.C1) is true

                              {

                                 C1_flag="A";

                               }

                else if (call C1 is date function) is true

                               {

                                C1_flag="D";

                                }

                 else if (call C1 is number function)  is true

                               {

                              C1_flag="N";

                                }

     Similarly you can do the other two columns also and you can perform this action using intermediate Var variables.

 

Now you have the values for example C1_flag="A", C2_flag="N", C3_flag="D"

 

3) In the output section of each variable, assign the values based on flag values.

eg:- For confirmation number, please check using condition checks C1_flag=="N"?C1 : (C2_flag=="N" ? C2: C3)

    This will make sure that the column with only number will be assigned to target column.

 

   Sorry, I do not have enough time to do full coding else I would be more than happy to create the full flow. But I hope you got the logic to do it.

 

If the answer has helped you, could you please mark the topic as resolved? Kudos are also welcome 🙂

 

Warm Regards,

 

Nikhil Thampi

 

Anonymous
Not applicable
Author

Hi @nthampi

We receive all the `input attributes` as String( Your condition is based on dataType), is there any solution for this type of scenario?

Regards 
Meet

Anonymous
Not applicable
Author

Hi,

 

    My logic is based on the fact that all the input variables are string.

 

     I have mentioned in earlier posts that you will have to use java functions to verify whether the input string is alphabet or number or date. Based on this verification only, you are setting the flag values. Could you please refer the stackoverflow links to create the appropriate verification functions?

 

     Point to be noted is that at least your source team should agree to a common date format. If the format of date is also not given, you will have to do multiple date format checks in your isdate() function.

 

Warm Regards,

 

Nikhil Thampi