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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Object creation in txmlmap

Hi,

 

I am new to Talend and couldn't figure out the solution to my issue on the forum.

I have a job attached below. 

In txmlmap, I have generated an output in the form of JSON/XML which is attached below with the name of "output_for_API". 

For now, its generating a consolidated file like:

 

<row>
<body><StockUpdate><locationDetail><location>0102</location><event_time>2019-07-04</event_time></locationDetail><quantity_list><gtin>615</gtin><quantity>1</quantity><exclude>false</exclude></quantity_list></StockUpdate></body>
</row>
<row>
<body><StockUpdate><locationDetail><location>0102</location><event_time>2019-07-04</event_time></locationDetail><quantity_list><gtin>2330</gtin><quantity>2</quantity><exclude>true</exclude></quantity_list></StockUpdate></body>
</row>
<row>
<body><StockUpdate><locationDetail><location>0778</location><event_time>2019-07-04</event_time></locationDetail><quantity_list><gtin>2730</gtin><quantity>-1</quantity><exclude>false</exclude></quantity_list></StockUpdate></body>
</row>
<row>
<body><StockUpdate><locationDetail><location>0102</location><event_time>2019-07-04</event_time></locationDetail><quantity_list><gtin>9552</gtin><quantity>1</quantity><exclude>true</exclude></quantity_list></StockUpdate></body>
</row>
<row>

 

Now, I have two issues. Firstly, for each location (e.g <location>0102 ) I need quantity_list to be an object which contains (gtin, quantity and exclude) as its members.

(one location should appear only once) 

So, the required format is:

  1. {
    "location": "",
    "event_time": "2019-07-04T18:15:00+01:00",
    "quantity_list": [{
    "gtin": "615",
    "quantity": 1
    },
    {
    "gtin": "2330",
    "quantity": 2
    },
    {
    "gtin": "9552",
    "quantity": 1
    }]
    }

2ndly, after getting output like above,  I need a file per location to feed the API;Not a consolidated file.

 

In the attached job, output_for_API in txmlmap is going to the tfileoutputDelimited, but it's just for testing. In actual, data will be going to the API.

 

Thanks for any help.

Labels (2)
1 Reply
Anonymous
Not applicable
Author

Hi @eman 

   

     Please do not create duplicate posts for the same query as it will only slow down the request. Since you have already one post as shown below, please stick to it.

 

https://community.talend.com/t5/Design-and-Development/How-to-pass-data-to-ta/m-p/166408#M101053

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂