Author |
Message
|
KIT_INC |
Posted: Wed Mar 21, 2012 9:11 am Post subject: Accessing fields inside COBOL re-define |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
I am using WMB V7
I created a message definition by importing a cobol copy book like this
Code: |
01 T1MESSAGE. 00000600
03 T1-AA PIC X(02). 00000700
03 T1-BB PIC X(02). 00000800
03 T1-CC PIC X(08). 00004200
03 T1-REDCC REDEFINES T1-CC. 00004300
05 T1-C1 PIC X(03). 00004400
05 FILLER PIC X(03). 00004500
05 T1-C2 PIC X(01). 00004610
05 T1-C3 PIC X(01). 00004620
/ |
I use a simple flow to test
MQInput --> Compute --> MQOutput
MQInput node has the message set and defintion specified.
The ESQL I used
Code: |
SET OutputRoot.XMLNSC.MSG.DATA1 = InputRoot.MRM.T1_AA;
SET OutputRoot.XMLNSC.MSG.DATA2 = InputRoot.MRM.T1_BB;
SET OutputRoot.XMLNSC.MSG.DATA3 = InputRoot.MRM.T1_CC;
SET OutputRoot.XMLNSC.MSG.DATA7 = InputRoot.MRM.T1_REDCC.T1_C1;
SET OutputRoot.XMLNSC.MSG.DATA8 = InputRoot.MRM.T1_REDCC.T1_C2;
SET OutputRoot.XMLNSC.MSG.DATA9 = InputRoot.MRM.T1_REDCC.T1_C3; |
My input message is 123456789abc
The output I got was
Code: |
<MSG>
<DATA1>12</DATA1>
<DATA2>34</DATA2>
<DATA3>56789abc</DATA3>
</MSG> |
A user trace shows
Code: |
(0x0100001B:Name+):MRM = ( ['mrm' : 0x1f2c0790]
(0x0300000B:NameValue+ ):T1_AA = '12' (CHARACTER)
(0x0300000B:NameValue+ ):T1_BB = '34' (CHARACTER)
UNRESOLVED CHOICE = X'3536373839616263'
)
) |
Executing statement ''SET OutputRoot.XMLNSC.MSG.DATA7 = InputRoot.MRM.T1_REDCC.T1_C1;'' at ('.MY_MSG_COBOL2XML_MF_Compute.CopyEntireMessage', '9.3').
2012-03-21 12:52:15.547027 6260 UserTrace BIP2543I: Node 'MY_MSG_COBOL2XML_MF.Compute': ('.MY_MSG_COBOL2XML_MF_Compute.CopyEntireMessage', '9.37') : Failed to navigate to path element number '3' because it does not exist.
How can I access get the value inside the redefine ( e.g. T1_REDCC.T1_C1) ? |
|
Back to top |
|
 |
Vitor |
Posted: Wed Mar 21, 2012 9:23 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Check the report from the COBOL copybook importer & the message set. The REDEFINES should have been expressed as a choice & may not be called T1-REDCC. The user trace is clearly showing that the parser has insufficient information to pick which of the choice elements to use for the input.
WMBv61's importer did stutter a little with REDEFINES. Not tried it on v7 but the same may be happening.
Depending on how you're using the data, it may be simplest to manually remove the PIC X( 8 ) element and just have the structure in the message set. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Mar 21, 2012 9:54 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
The other problem with redefines is that the broker maps them to a choice. It is not like in COBOL where you can access both forms at the same time.
At runtime you have to choose whether you want to access the primary form or the redefined form...
Tough Luck  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Vitor |
Posted: Wed Mar 21, 2012 10:04 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
fjb_saper wrote: |
The other problem with redefines is that the broker maps them to a choice. It is not like in COBOL where you can access both forms at the same time. |
Oooo.....well spotted! I've clearly gone from too little coffee to too much!
My most worthy associate is quite right; you're assigning T1.CC to DATA3. This means that T1.CC is the chosen element so T1-Cn don't exist as the error indicates.
So you can either access T1.CC or T1.REDCC and it's children. You can't access both. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
KIT_INC |
Posted: Wed Mar 21, 2012 10:37 am Post subject: |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
Thanks Vitor and fjb_saper. If I understand you correctly than, I either do
SET OutputRoot.XMLNSC.MSG.DATA3 = InputRoot.MRM.T1_CC; or
SET OutputRoot.XMLNSC.MSG.DATA7 = InputRoot.MRM.T1_REDCC.T1_C1;
Is this true for the entire ESQL module or just for a ESQL functin or procedure? For example in my logic I first need to get T1_C1 and later on I need to get T1_CC, can I split that into 2 ESQL procedures or functions and call them according to my need ? |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Mar 21, 2012 10:42 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
The choice is resolved at the first point of determination. After that, the logical message tree is fixed.
So you can access either one, up to the point that you access one or the other. Once you have accessed one of the choices you can no longer access the other choices. |
|
Back to top |
|
 |
KIT_INC |
Posted: Wed Mar 21, 2012 10:51 am Post subject: |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
Thanks mqjeff, I just tested it and what you say is correct. If I need to access it a different way, I need to use another compute node (i.e. the first compute node access T1_CC and the second compute node access REDCC.T1_C1..) |
|
Back to top |
|
 |
|