Author |
Message
|
EricCox |
Posted: Tue Oct 16, 2012 6:06 am Post subject: How to handle REDEFINES in MB 6.0.0.9 |
|
|
Master
Joined: 08 Apr 2011 Posts: 292
|
To all,
How do you suggest I handle a Copybook with three REDEFINES...in MB 6.0.0.9?
I have a structure like this:
FIELD1 PICS9(3) COMP-3 <<<<holds a code to select which REDEFINE TRAN-DATA PIC X(2048)
TRAN-DATA1 REDEFINES TRAN-DATA
TRAN-DATA2 REDEFINES TRAN-DATA
TRAN-DATA3 REDEFINES TRAN-DATA
Should I split it into Four Copybooks/Message Sets and use the first one which has FIELD1 and TRAN-DATA to get the code and then resetContentDescriptor to one of the other three COBOL Copybooks/MessageSets based on the Code found in FIELD1?
Is there an easier way to handle this? Is there a sample or pattern that I should use that you can point me to?
Thanks,
EMC |
|
Back to top |
|
 |
lancelotlinc |
Posted: Tue Oct 16, 2012 6:30 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
mqjeff |
Posted: Tue Oct 16, 2012 6:33 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Typically there is some mechanism for resolving the choice that the redefine mentions. |
|
Back to top |
|
 |
EricCox |
Posted: Tue Oct 16, 2012 6:38 am Post subject: FIELD1 will give a code to choose the REDEFINES |
|
|
Master
Joined: 08 Apr 2011 Posts: 292
|
i can create a base Copybook and MessageSet that holds the FIELD1 to select the code and the base TRAN-DATA.
then i'll create three Copybook/MsgSet for each of the REDEFINES and use three ResetContentDescriptors according to which REDEFINES and MsgSet i need to use.
I was wondering if there was an easier more eloquent way to accomplish this.
Yes, I know it is obviously unsupported.
Thanks you guys. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Oct 16, 2012 6:42 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Use FIELD1 as a TAG to resolve a choice in a single message definition. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Oct 16, 2012 7:51 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Try this:
- import the copybook to create a message set with a CWF physical format
- in your message flow, just code the logic that you need to code. Don't think too hard about the REDEFINES. Your code will either need to access something in the REDEFINESS or it won't. If it does need to, then the CWF parser will have the clue that it requires to resolve the choice. Obviously, make sure that yourESQL only references TRAN-DATA2 if FIELD1 is set to the correct value - otherwise the CWF parser will throw an error.
For v8 users who are using DFDL this option is
a) not available and
b) not required
DFDL is a more powerful parser, and you can add the required logic to resolve the choice in the DFDL model. That might involve deleting FIELD1 and turning it into an initiator for the three arms of the xs:choice. Or it might involve adding some asserts/discriminators to the branches of the xs:choice. |
|
Back to top |
|
 |
EricCox |
Posted: Tue Oct 16, 2012 8:32 am Post subject: Trying to find Docs |
|
|
Master
Joined: 08 Apr 2011 Posts: 292
|
Do you happen to have a link to a doc? I can't find the right stuff on InfoCenter.
I think I know what you are referring to in the Message Definition but have not used that functionality. |
|
Back to top |
|
 |
EricCox |
Posted: Tue Oct 16, 2012 8:35 am Post subject: Implicit Recognition of REDEFINES Area |
|
|
Master
Joined: 08 Apr 2011 Posts: 292
|
Thanks Kimbert.
Is it correct that by accessing the correct fields per the code found in FIELD1 the MessageDefition and parser will pick the correct REDEFINES?
This makes sense to me based on how I see this parser working. I just haven't seen this in action. I'll definitely try that first.
Thanks,
Eric |
|
Back to top |
|
 |
kimbert |
Posted: Tue Oct 16, 2012 9:43 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Is it correct that by accessing the correct fields per the code found in FIELD1 the MessageDefition and parser will pick the correct REDEFINES? |
Yes - that's exactly how it works. We call it an 'unresolved choice' until the message flow provides enough information to allow it to be parsed. |
|
Back to top |
|
 |
EricCox |
Posted: Tue Oct 16, 2012 12:23 pm Post subject: SET the Body and resp DECLARE |
|
|
Master
Joined: 08 Apr 2011 Posts: 292
|
To all,
I need to SET the Body and resp DECLARE with values from concantenated strings.
When I do this it doesnt' seem to like what I've done and produces no results.
Here is what I try:
--Set the Body
SET completeOutputRootString = ''; <<<this doesn't appear to work
--SET OutputRoot.XMLNS.soap_env:Envelope.soap_env:Body.AbendResponse = ''; <<<this works
--Populate the Result
--DECLARE resp REFERENCE TO OutputRoot.XMLNS.soap_env:Envelope.soap_env:Body.AbendResponse; <<<this works
DECLARE resp REFERENCE TO completeOutputRootString;<<<this doesn't work
Here is the result of the concantenation which looks correct:
This resolved to '''OutputRoot.XMLNS.soap_env:Envelope.soap_env:Body.' || 'getCustConsLoanLoanAcctsRs'''. The result was '''OutputRoot.XMLNS.soap_env:Envelope.soap_env:Body.getCustConsLoanLoanAcctsRs'''.
It looks like the whole string is correct.
Do I need to use escape characters...how correctly? What do you see I'm doing wrong? The string manipulation looks correct. Am I doing something that isn't allowed doing the SET Body and DECLARE resp?
Thanks |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Oct 16, 2012 12:30 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I can barely understand what you are trying to ask about, but it clearly has nothing to do with your COBOL REDEFINES question.
I believe you're trying to ask how to set the contents of a field to be the full bitstream of a logical message tree - if so, the answer is to use ASBITSTREAM.
You might be trying to ask how to refer to a field using a dynamic name, such that you have the actual name of a field stored in a variable named "completeOutputRootString", and you want to access a child of OutputRoot.XMLNS.soap_env:Envelope.soap_env.Body?
If so that would be done by saying OutputRoot.XMLNS.soap_env:Envelope.soap_env.Body.{completeOutputRootString}
Where the {} indicates that you should evaluate the value of the variable to find the name of the element.
THIS ONLY WORKS FOR A SINGLE LEVEL, so you can't have "CustomerName.getData" in completeOutputRootString and expect to navigate to the getData child of the CustomerName child of the Body. that just doesn't work.
If neither of these work, please try your question again and use CODE TAGS to clearly indicate where you have CODE and be specific about values and message tree structures. |
|
Back to top |
|
 |
EricCox |
Posted: Tue Oct 16, 2012 12:35 pm Post subject: Answered...I think |
|
|
Master
Joined: 08 Apr 2011 Posts: 292
|
Thanks mqjeff.
I think you answered me. I'm trying to do something with the full name.name.name. that isn't allowed.
Let me try the last level only as you show.
I'll let you know.
Regards |
|
Back to top |
|
 |
EricCox |
Posted: Tue Oct 16, 2012 12:42 pm Post subject: As it is now |
|
|
Master
Joined: 08 Apr 2011 Posts: 292
|
Now I have this following your suggestion:
Code: |
SET intServiceName = "InputBody"."ALLTEL_MQ_HEADER"."ACAI_SERVICE_NAME";
SET serviceName = intServiceName || 'Rs';
|
I need to add Rs to indicate response to the end of the service name. Then I need to use the serviceName in the SET Body and DECLARE resp.
Code: |
--Set the Body
SET OutputRoot.XMLNS.soap_env:Envelope.soap_env:Body.{serviceName} = '';
--Populate the Result
DECLARE resp REFERENCE TO OutputRoot.XMLNS.soap_env:Envelope.soap_env:Body.{serviceName};
|
I need to pass in the service name to this dynamically so I can use common code/subflow for several services.
Here the serviceName variable = ServiceOneRs.
Thanks |
|
Back to top |
|
 |
EricCox |
Posted: Tue Oct 16, 2012 12:45 pm Post subject: Nuances Abound |
|
|
Master
Joined: 08 Apr 2011 Posts: 292
|
Thanks alot mqjeff. I didn't know about the curly braces to have a variable evaluated to a result. This isn't TSQL or PL/SQL is it? I like the way the {} work though...very elegant. |
|
Back to top |
|
 |
|