ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL - copy subtree

Post new topic  Reply to topic
 ESQL - copy subtree « View previous topic :: View next topic » 
Author Message
tom_1
PostPosted: Fri Feb 21, 2014 5:13 am    Post subject: ESQL - copy subtree Reply with quote

Newbie

Joined: 21 Feb 2014
Posts: 6

I have two different data structures in different NS, but fields in the subtrees are the same.
Structure 1: Source data - webservice
Structure 2: Destination data - IDOC


Structure 1 (source):
Code:
Root
...
  address
    CITY
    STREET
    POSTAL_CODE
  user
    FIRSTNAME
    LASTNAME


Structure 2 (destination):
Code:
Root
...
  customer_addr
    CITY
    STREET
    POSTAL_CODE
  contact
    FIRSTNAME
    LASTNAME


Of course I can copy each field from source to output,
but I have that structures with more than 20 fields.
Is there any way (pattern , procedure) in ESQL to do it more easily?


Regards
Tom
Back to top
View user's profile Send private message
Esa
PostPosted: Fri Feb 21, 2014 5:17 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

Code:
CREATE LASTCHILD of <reference> FROM <reference>
Back to top
View user's profile Send private message
Gralgrathor
PostPosted: Fri Feb 21, 2014 5:18 am    Post subject: Re: ESQL - copy subtree Reply with quote

Master

Joined: 23 Jul 2009
Posts: 297

tom_1 wrote:
Is there any way (pattern , procedure) in ESQL to do it more easily?


Have you considered using a mapping node? Mapping nodes provide ways to easily map collections of fields with the same or similar names.
Back to top
View user's profile Send private message Send e-mail
tom_1
PostPosted: Fri Feb 21, 2014 5:23 am    Post subject: Reply with quote

Newbie

Joined: 21 Feb 2014
Posts: 6

Esa wrote:
Code:
CREATE LASTCHILD of <reference> FROM <reference>


Thank you , I wil check it

T.
Back to top
View user's profile Send private message
Gralgrathor
PostPosted: Fri Feb 21, 2014 5:23 am    Post subject: Reply with quote

Master

Joined: 23 Jul 2009
Posts: 297

Esa wrote:
Code:
CREATE LASTCHILD of <reference> FROM <reference>


Doesn't that copy namespaces as well?
Back to top
View user's profile Send private message Send e-mail
tom_1
PostPosted: Fri Feb 21, 2014 5:25 am    Post subject: Re: ESQL - copy subtree Reply with quote

Newbie

Joined: 21 Feb 2014
Posts: 6

Gralgrathor wrote:
tom_1 wrote:
Is there any way (pattern , procedure) in ESQL to do it more easily?


Have you considered using a mapping node? Mapping nodes provide ways to easily map collections of fields with the same or similar names.


Unfortunately I also have to do some complex transformations and conditions that I cannot do with MappingNode
Back to top
View user's profile Send private message
Esa
PostPosted: Fri Feb 21, 2014 5:32 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

Gralgrathor wrote:
Esa wrote:
Code:
CREATE LASTCHILD of <reference> FROM <reference>


Doesn't that copy namespaces as well?


Yes, it does, but changing namespaces recursively afterwards is quite straightforward.
Back to top
View user's profile Send private message
tom_1
PostPosted: Fri Feb 21, 2014 5:46 am    Post subject: Reply with quote

Newbie

Joined: 21 Feb 2014
Posts: 6

Esa wrote:
Gralgrathor wrote:
Esa wrote:
Code:
CREATE LASTCHILD of <reference> FROM <reference>


Doesn't that copy namespaces as well?


Yes, it does, but changing namespaces recursively afterwards is quite straightforward.


What about solution: procedure which setting fields in a loop (below)?


...
Code:
SET outputStructure.{FIELDNAME(inputStructure.*[I]} = FIELDVALUE(outputStructure.*[I]);
Back to top
View user's profile Send private message
Gralgrathor
PostPosted: Fri Feb 21, 2014 5:54 am    Post subject: Reply with quote

Master

Joined: 23 Jul 2009
Posts: 297

FIELDVALUE returns scalar values only.

tom_1 wrote:
Code:
SET outputStructure.{FIELDNAME(inputStructure.*[I]} = FIELDVALUE(outputStructure.*[I]);


The FIELDVALUE(elementA) of
Code:
<ElementA><ElementB>Value</ElementB></ElementA>
is NULL.

Last edited by Gralgrathor on Fri Feb 21, 2014 5:56 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Fri Feb 21, 2014 5:56 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

esa said:
Quote:
Yes, it does, but changing namespaces recursively afterwards is quite straightforward.
This is the correct answer.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
tom_1
PostPosted: Fri Feb 21, 2014 5:58 am    Post subject: Reply with quote

Newbie

Joined: 21 Feb 2014
Posts: 6

Gralgrathor wrote:
tom_1 wrote:
Code:
SET outputStructure.{FIELDNAME(inputStructure.*[I]} = FIELDVALUE(outputStructure.*[I]);


The FIELDVALUE(elementA) of
Code:
<ElementA><ElementB>Value</ElementB></ElementA>
is NULL.


Sorry, should be:

SET outputStructure.{FIELDNAME(inputStructure.*[I]} = FIELDVALUE(inputStructure.*[I]);
Back to top
View user's profile Send private message
Gralgrathor
PostPosted: Fri Feb 21, 2014 5:59 am    Post subject: Reply with quote

Master

Joined: 23 Jul 2009
Posts: 297

Gralgrathor wrote:

tom_1 wrote:
Code:
SET outputStructure.{FIELDNAME(inputStructure.*[I]} = FIELDVALUE(outputStructure.*[I]);


Besides, I think that the above code would overwrite recurring elements in the source to the first element in the target.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL - copy subtree
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.