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 » Mapping XML in lt-gt format to CCB

Post new topic  Reply to topic
 Mapping XML in lt-gt format to CCB « View previous topic :: View next topic » 
Author Message
arpanm
PostPosted: Tue Dec 26, 2023 4:47 am    Post subject: Mapping XML in lt-gt format to CCB Reply with quote

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>&lt;Rp&gt;
   &lt;e1&gt;ar&lt;/e1&gt;
   &lt;e2&gt;pa&lt;/e2&gt;
   &lt;e3&gt;n&lt;/e3&gt;
   &lt;s&gt;
      &lt;es1&gt;jh&lt;/es1&gt;
      &lt;es2&gt;il&lt;/es2&gt;
      &lt;es3&gt;ke&lt;/es3&gt;
      &lt;es4&gt;ps&lt;/es4&gt;
   &lt;/s&gt;
   &lt;s&gt;
      &lt;es1&gt;it&lt;/es1&gt;
      &lt;es2&gt;am&lt;/es2&gt;
      &lt;es3&gt;eg&lt;/es3&gt;
      &lt;es4&gt;ha&lt;/es4&gt;
   &lt;/s&gt;
   &lt;s&gt;
      &lt;es1&gt;li&lt;/es1&gt;
      &lt;es2&gt;na&lt;/es2&gt;
      &lt;es3&gt;uv&lt;/es3&gt;
      &lt;es4&gt;wx&lt;/es4&gt;
   &lt;/s&gt;
&lt;/Rp&gt;</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
View user's profile Send private message
timber
PostPosted: Mon Jan 01, 2024 8:32 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Mapping XML in lt-gt format to CCB
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.