Author |
Message
|
skediyal |
Posted: Thu Nov 17, 2005 2:02 pm Post subject: mapping repeated fields |
|
|
Newbie
Joined: 02 Nov 2005 Posts: 7
|
Hi, I am trying to map incoming xml to cobol copybooks. I have created mapping file to accomplish this. The schema and copybook have repeated fields. I have created message defintion for schema and copybook. The schema and copy books looks like this.
XML Schema
---------
Customer
- Name
- ItemCnt
- Items occurs 0 ---10
- itemCd
- itemDesc
Copy Book
------------
01 Customer
05 Name PIC X(20)
05 ItemCnt PIC 9(2)
05 Items occurs 0 to 20 depending on ItemCnt
10 itemCd PIC X(8)
10 itemDesc PIC X(20)
Now when i drop both the message defintion file in the mapping file. The files are created with Source created with Items[] and Items[All] and target with Items[],Items[ALL],Items[1].
For Name and itemCnt fields i have create mapping using "create mapping" menu item. But for array how do create mapping. Which nodes should i use for mapping ([] or [ALL]?). I see option for "Create loop assignment mapping". Should i use this create mapping.
Again items list could be 0 or 10. Please help. Thanks in advance for help.
S |
|
Back to top |
|
 |
vk |
Posted: Thu Nov 17, 2005 2:41 pm Post subject: |
|
|
Partisan
Joined: 20 Sep 2005 Posts: 302 Location: Houston
|
You can use [ALL] for mapping all elements which repeat in input to all elements which repeat at output.
Since in the output message, the cardinality is more then the input message cardinality, it is not an issue. Even though the output element can repeat from 1 to 20, it will created only that many times, the input is present.
You can also rigt click on Items[] and choose Create Instances (Specify). Then for both input and output elements specify the value 10. Then you can individually map the occurances.
Regards,
VK. |
|
Back to top |
|
 |
skediyal |
Posted: Fri Nov 18, 2005 10:34 am Post subject: |
|
|
Newbie
Joined: 02 Nov 2005 Posts: 7
|
VK, thanks for your help. There were typo. Actaully the number of occurences are same both the sides. i.e. 20. I have trried mapping [all].
I am now mapping one on one item in [all].
But the mapping fails gives following error
CWF Output: Mismatch between logical definition and message tree.
Message : msg_CUSTOMER
Element : 114^CPY_itemCd
The CWF writer has been given a message tree which does not match the logical message definition.
The elements may have been added to the message tree in the wrong order, or there may be elements missing from the message tree.
The message type or message set may be incorrect.
If the output message was assembled in a Compute node, check that the elements were added to the message in the order specified in the logical message definition.
Check that the output message contains all the elements in the logical message definition (perhaps you need to copy the entire input message to the output tree before modifying it)
Check that the output message has the correct message set and message type properties.
Check that the output message does not contain self-defining elements.
Thanks,
S |
|
Back to top |
|
 |
wooda |
Posted: Mon Nov 21, 2005 3:46 am Post subject: |
|
|
 Master
Joined: 21 Nov 2003 Posts: 265 Location: UK
|
Hi skediyal,
Your flow has failed trying to serialize the CWF message as some aspect of an occurence of your CPY_itemCd element does not match your message set definition.
It would be helpful if you could trace the message after the mapping has occured (trace node with pattern=${Root} or using the debugger)
and post the message tree here.
With this information and the copybook you posted earlier it should be clear what your problem is. |
|
Back to top |
|
 |
wooda |
Posted: Mon Nov 21, 2005 8:58 am Post subject: |
|
|
 Master
Joined: 21 Nov 2003 Posts: 265 Location: UK
|
skediyal,
Both your CWF and XML messages seem to have the same structure..
If they are actually defined by the same type in your message set then
You can just drag Items[All] in the source to Items[All] in the target and that will map all instances (as they are the same type this is all that is needed).
Don't map the children of Items individually as this will cause the wrong output strucutre (This may be your current problem ??) as all the itemCd fields will be mapped first then all the itemDesc's and you will end up with double the number of Items.
If your target and source message are of different types then when you attempt to map the Items[All] in your source to the target you will be asked if you wish to create a sub-mapping. In this case you must then create the sub-mapping to make it work and this will be used for each occurence of the array in the top level mapping. |
|
Back to top |
|
 |
gakana |
Posted: Tue Nov 22, 2005 7:59 pm Post subject: |
|
|
Apprentice
Joined: 27 Jul 2005 Posts: 28 Location: Michigan
|
If you are in MB 5.0.4 then you have to install intrem fix23 from the update manager site.
I think I have a better understand what you want and you need to use
sub-mapping. This is the small example
that looked like the following:
<ManyMsg>
<Field1>aaaaa</Field1>
<Field2>bbbbb</Field2>
<Field3>
<subF1>sub1</subF1>
<subF2>sub2</subF2>
<subF3>sub3</subF3>
<subF4>sub4</subF4>
</Field3>
<Field3>
<subF1>sub5</subF1>
<subF2>sub6</subF2>
<subF3>sub7</subF3>
<subF4>sub8</subF4>
</Field3>
<Field3>
<subF1>sub9</subF1>
<subF2>sub10</subF2>
<subF3>sub11</subF3>
<subF4>sub12</subF4>
</Field3>
<Field4>ccccc</Field4>
</ManyMsg>
To help clearly see what you wanted I decided to output just the SubF1
and SubF2 to the output message making sure they were ordered per
occurance and not grouped together regardless of occurance. Essentially
you wanted an output message like the following:
<?xml version="1.0"?>
<MRM xmlns="www.mrmnames.net/E5BJHT4002001">
<ManyMsg>
<Field3>
<subF1>sub1</subF1>
<subF2>sub2</subF2>
</Field3>
<Field3>
<subF1>sub5</subF1>
<subF2>sub6</subF2>
</Field3>
<Field3>
<subF1>sub9</subF1>
<subF2>sub10</subF2>
</Field3>
</ManyMsg>
</MRM>
Note: I have not added in any fields but they could be added as well (eg
field4 etc...)
Here is how I changed the example I gave you to generate the output from
above:
1) Create a mapping and add in to the mapping the source and target
message (manymsg).
2) Expand Field3[All] on source panel.
3) Select BOTH subF1 and subF2 at the sametime. You can use shift or
control key to select multiple fields.
4) Drag them over to the target panel and drop them onto Field3[all].
5) You should get a pop up window called create or reuse a mapping.
6) Click on create (or you could reuse an existing one if you already have
one) and type in a name e.g subF1andSubF2toField3
7) This creates a new mapping and you should see subF1 and SubF2 in the
source panel and Field3 in the target panel.
Drag just subF1 onto subF1 in the target field subF1 and repeat for
subF2 to subF2.
9) save this new mapping and the first one you created.
I suggest you go through these steps with the example I provided to get a
better understanding. You should then be able to use this example to
modify your actual mapping to get the desired output.
Please update me if it helps you
Thanks
Gakana |
|
Back to top |
|
 |
|