|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Mapping XML in lt-gt format to CCB |
« View previous topic :: View next topic » |
Author |
Message
|
arpanm |
Posted: Tue Dec 26, 2023 4:47 am Post subject: Mapping XML in lt-gt format to CCB |
|
|
Newbie
Joined: 26 Dec 2023 Posts: 1
|
I have the xml in following structure:
Code: |
<GM xmlns="xyz">
<H>
<E1>aaaa</E1>
<E2>bbbbb</E2>
</H>
<I>
<E1>ccc</E1>
<E2>ddd</E2>
<E3>eeeee</E3>
</I>
<B>
<E1>ff</E1>
<E2>gg</E2>
<E3>hhhh</E3>
</B>
<B>
<E1>ii</E1>
<E2>COIL</E2>
<E3><Rp>
<e1>ar</e1>
<e2>pa</e2>
<e3>n</e3>
<s>
<es1>jh</es1>
<es2>il</es2>
<es3>ke</es3>
<es4>ps</es4>
</s>
<s>
<es1>it</es1>
<es2>am</es2>
<es3>eg</es3>
<es4>ha</es4>
</s>
<s>
<es1>li</es1>
<es2>na</es2>
<es3>uv</es3>
<es4>wx</es4>
</s>
</Rp></E3>
</B>
<B>
<E1>jj</E1>
<E2>kk</E2>
<E3>llll</E3>
</B>
</GM> |
And I have the following CCB structure,
Code: |
01 DATA
03 A.
05 A1 PIC X(10).
05 A2 PIC X(5).
05 A3 PIC X(5).
05 A4 PIC X(5).
05 A5 PIC X(5).
05 A6 OCCURS 3.
07 B1 PIC X(4).
07 B2 PIC X(4).
07 B3 OCCURS 3.
09 C1 PIC X(2).
09 C2 PIC X(2).
09 C3 PIC X(2).
09 C4 PIC X(2).
|
To transfrom from this xml to CCB I've written the following esql code in IBM ACE tool:
Code: |
CREATE COMPUTE MODULE POC_LOGIC_Mapping
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
-- CALL CopyEntireMessage();
SET OutputRoot.MQMD.CodedCharSetId = 1140;
SET OutputRoot.MQMD.Encoding = 785;
SET OutputRoot.Properties.MessageSet = 'K9IDEGS002001';
SET OutputRoot.Properties.MessageType = 'msg_DATA';
SET OutputRoot.Properties.MessageFormat = 'Binary1';
DECLARE ns1 NAMESPACE 'xyz';
DECLARE i INTEGER 1;
DECLARE ms BLOB;
SET OutputRoot.MRM.A.A1 = coalesce(InputRoot.XMLNSC.ns1:GM.ns1:H.ns1:E1, '');
SET OutputRoot.MRM.A.A2 = coalesce(InputRoot.XMLNSC.ns1:GM.ns1:H.ns1:E2, '');
SET OutputRoot.MRM.A.A3 = coalesce(InputRoot.XMLNSC.ns1:GM.ns1:I.ns1:E1, '');
SET OutputRoot.MRM.A.A4 = coalesce(InputRoot.XMLNSC.ns1:GM.ns1:I.ns1:E2, '');
SET OutputRoot.MRM.A.A5 = coalesce(InputRoot.XMLNSC.ns1:GM.ns1:I.ns1:E3, '');
DECLARE obj1 REFERENCE TO InputRoot.XMLNSC.ns1:GM.ns1:B;
X1: WHILE LASTMOVE(obj1) DO
IF (obj1.ns1:E2 = 'COIL') THEN
SET ms = CAST(obj1.ns1:E3 AS BLOB CCSID InputRoot.Properties.CodedCharSetId);
LEAVE X1;
ELSE
MOVE obj1 NEXTSIBLING;
END IF;
END WHILE;
DECLARE blobXML REFERENCE TO InputRoot.XMLNSC;
CREATE LASTCHILD OF blobXML PARSE(ms, InputRoot.Properties.Encoding, InputRoot.Properties.CodedCharSetId);
DECLARE sRef REFERENCE TO blobXML.Rp.s;
DECLARE j INTEGER 1;
FOR obj2 AS InputRoot.XMLNSC.ns1:GM.ns1:B[] DO
SET OutputRoot.MRM.A.A6[i].B1 = coalesce(obj2.ns1:E1, '');
SET OutputRoot.MRM.A.A6[i].B2 = coalesce(obj2.ns1:E2, '');
WHILE LASTMOVE(sRef) DO
SET OutputRoot.MRM.A.A6[i].B3[j].C1 = coalesce(CAST(sRef.es1 AS CHARACTER), '');
SET OutputRoot.MRM.A.A6[i].B3[j].C2 = coalesce(CAST(sRef.es2 AS CHARACTER), '');
SET OutputRoot.MRM.A.A6[i].B3[j].C3 = coalesce(CAST(sRef.es3 AS CHARACTER), '');
SET OutputRoot.MRM.A.A6[i].B3[j].C4 = coalesce(CAST(sRef.es4 AS CHARACTER), '');
MOVE sRef NEXTSIBLING;
SET j = j + 1;
END WHILE;
SET i = i + 1;
END FOR;
RETURN TRUE;
END;
END MODULE;
|
This providing error: "there is a mismatch between the logical definition and the message tree. Message: msg_DATA Element: C1" Now I am stuck. After setting the xml which is in lt-gt format inside <E1> element where <E2> equals to 'COIL', I need to populate B3 segments according to the occurrence of <s> segments. And C1 will be mapped to s.es1, C2 will be mapped to s.es2, C3 will be mapped to s.es3 and C4 will be mapped to s.es4. |
|
Back to top |
|
 |
timber |
Posted: Mon Jan 01, 2024 8:32 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
I see that you are using the MRM parser, which is not recommended since WMB v8. The DFDL parser is much easier to debug, especially when you are doing non-trivial mappings like this. There is a COBOL copybook importer for DFDL, so you do not need to construct the model manually.
If you insist on using MRM then you should follow these steps:
* make sure that the structure of the message tree is exactly as you expected it to be. I use a Trace node for this - the message flow debugger does not display namespaces.
* check that the structure of the message tree exactly matches the structure of the message set.
* if all else fails, take a debug-level user trace, and carefully read the trace entries from the MRM parser.
but once again...the DFDL parser would make this much easier. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|