|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MRM-XML mapping difficulty with Occurs & with XML tag na |
« View previous topic :: View next topic » |
Author |
Message
|
vickie_ews |
Posted: Mon Feb 03, 2003 4:05 pm Post subject: MRM-XML mapping difficulty with Occurs & with XML tag na |
|
|
Novice
Joined: 04 Sep 2002 Posts: 18
|
I've attached samples. I have an OCCURS that seems to be nesting 4 times instead of 2. Also the XML tags following the name convention in MRM rather than what is set in the ESQL Output. See samples below.
Here is copybook with an "OCCURS of 2" that was used to build the message set.
*****************COPYBOOK *************************
01 ALERT-0235-RSP.
05 TRANS-TYPE PIC 9(04).
05 REGION PIC X(10).
05 CONTEXT-ID PIC X(26).
05 START-POINTER PIC 9(04).
05 MORE-ALERTS-SWITCH PIC X(01).
05 NUMBER-OF-ALERTS PIC 9(02).
05 ALERT-LIST.
10 ALERT-DETAIL-ENTRY OCCURS 2 TIMES.
15 ALERT-CAT PIC X(30).
15 ALERT-DESC PIC X(60).
15 RESOURCE-ENTITY-CODE PIC X(10).
15 RESOURCE-NATIVE PIC X(30).
15 LOCATION-CODE PIC X(10).
15 LOCATION-NATIVE PIC X(30).
15 SUB-LOCATION-CODE PIC X(10).
15 SUB-LOCATION-NATIVE PIC X(30).
**************** END COPYBOOK ***********************
The message set seems to work fine. The message set created an ALERT_DETAIL_ENTRY_TYPE and on "Connection" Tab lists:
Repeat: Yes
Min Occurs: 2
Max Occurs: 2
Suspended from Use: No
Element: ALERT_DETAIL_ENTRY
The ESQL for parsing from Cobol MRM elements to XML tags is listed below:
*******************ESQL *****************************
DECLARE C INTEGER;
SET C = CARDINALITY(InputRoot.*[]);
DECLARE I INTEGER;
SET I = 1;
WHILE I < C DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I=I+1;
END WHILE;
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
-- Set Transaction Type to Null (Not needed for XML layout)
--SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."TransType" = "InputRoot"."MRM"."TRANS_TYPE";
--SET "OutputRoot"."XML"."TRANS_TYPE" = NULL;
-- Transform MRM to XML
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."Region" = "InputRoot"."MRM"."REGION";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."CntxtId" = "InputRoot"."MRM"."CONTEXT_ID";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."StartPtr" = "InputRoot"."MRM"."START_POINTER";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."MoreAlertsSw" = "InputRoot"."MRM"."MORE_ALERTS_SWITCH";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."NoRtrn" = "InputRoot"."MRM"."NUMBER_OF_ALERTS";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst" = "InputRoot"."MRM"."ALERT_LIST";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"[1] = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"[1];
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."AlertCd" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."ALERT_CAT";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."AlrtDesc" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."ALERT_DESC";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."RespRsrceEntityTypCd" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."RESOURCE_ENTITY_CODE";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."RespRsrceNativeVal" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."RESOURCE_NATIVE";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."RespLocTyp" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."LOCATION_CODE";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."RespLocNativeVal" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."LOCATION_NATIVE";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."RespSubLocTyp" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."SUB_LOCATION_CODE";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."RespSubLocNativeVal" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."SUB_LOCATION_NATIVE";
********************* END ESQL *****************************
Below are my test data results. The XML tag names are not converting. And why why are there 4 nested "ALERT_DETAIL_ENTRY" ?
***************TEST DATA IN OUTPUT QUEUE **************
<org.kp.oa.api.PatientAlertsRsp>
<Region>ABC</Region>
<CntxtId>1044050735683</CntxtId>
<StartPtr>2</StartPtr>
<MoreAlertsSw>Y</MoreAlertsSw>
<NoRtrn>2</NoRtrn>
<AlertLst>
<ALERT_DETAIL_ENTRY>
<ALERT_CAT>SECURITY</ALERT_CAT>
<ALERT_DESC>CALL MGR IF HOSTILE/THREATENS</ALERT_DESC>
<RESOURCE_ENTITY_CODE></RESOURCE_ENTITY_CODE>
<RESOURCE_NATIVE></RESOURCE_NATIVE>
<LOCATION_CODE></LOCATION_CODE>
<LOCATION_NATIVE></LOCATION_NATIVE>
<SUB_LOCATION_CODE></SUB_LOCATION_CODE>
<SUB_LOCATION_NATIVE></SUB_LOCATION_NATIVE>
</ALERT_DETAIL_ENTRY>
[color=#444444]<ALERT_DETAIL_ENTRY>[/color]
<ALERT_CAT>SECURITY</ALERT_CAT>
<ALERT_DESC>CALL SEC/POLICE IF COMES TO AB</ALERT_DESC>
<RESOURCE_ENTITY_CODE></RESOURCE_ENTITY_CODE>
<RESOURCE_NATIVE></RESOURCE_NATIVE>
<LOCATION_CODE></LOCATION_CODE>
<LOCATION_NATIVE></LOCATION_NATIVE>
<SUB_LOCATION_CODE></SUB_LOCATION_CODE>
<SUB_LOCATION_NATIVE></SUB_LOCATION_NATIVE>
</ALERT_DETAIL_ENTRY>
<org.kp.oa.api.AlertDetl>
<ALERT_CAT>SECURITY</ALERT_CAT>
<ALERT_DESC>CALL MGR IF HOSTILE/THREATENS</ALERT_DESC>
<RESOURCE_ENTITY_CODE></RESOURCE_ENTITY_CODE>
<RESOURCE_NATIVE></RESOURCE_NATIVE>
<LOCATION_CODE></LOCATION_CODE>
<LOCATION_NATIVE></LOCATION_NATIVE>
<SUB_LOCATION_CODE></SUB_LOCATION_CODE>
<SUB_LOCATION_NATIVE></SUB_LOCATION_NATIVE>
<AlertCd>SECURITY</AlertCd>
<AlrtDesc>CALL MGR IF HOSTILE/THREATENS</AlrtDesc>
<RespRsrceEntityTypCd></RespRsrceEntityTypCd>
<RespRsrceNativeVal></RespRsrceNativeVal>
<RespLocTyp></RespLocTyp>
<RespLocNativeVal></RespLocNativeVal>
<RespSubLocTyp></RespSubLocTyp>
<RespSubLocNativeVal></RespSubLocNativeVal>
</org.kp.oa.api.AlertDetl>
<org.kp.oa.api.AlertDetl>
<ALERT_CAT>SECURITY</ALERT_CAT>
<ALERT_DESC>CALL SEC/POLICE IF COMES TO KP</ALERT_DESC>
<RESOURCE_ENTITY_CODE></RESOURCE_ENTITY_CODE>
<RESOURCE_NATIVE></RESOURCE_NATIVE>
<LOCATION_CODE></LOCATION_CODE>
<LOCATION_NATIVE></LOCATION_NATIVE>
<SUB_LOCATION_CODE></SUB_LOCATION_CODE>
<SUB_LOCATION_NATIVE></SUB_LOCATION_NATIVE>
</org.kp.oa.api.AlertDetl>
</AlertLst>
</org.kp.oa.api.PatientAlertsRsp>
************** END TEST DATA IN OUTPUT QUEUE ***********
gratefully,
vickie_ews |
|
Back to top |
|
 |
TonyD |
Posted: Mon Feb 03, 2003 9:48 pm Post subject: |
|
|
Knight
Joined: 15 May 2001 Posts: 540 Location: New Zealand
|
From just a quick look, as I have to go, wouldn't:
Quote: |
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst" = "InputRoot"."MRM"."ALERT_LIST";
|
:put the entire ALERT_LIST into a single OutputRoot.XML element '......."AlertLst", into which you have then explicity added additional elements.
This snippet:
Quote: |
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."AlertCd" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."ALERT_CAT";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."AlrtDesc" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."ALERT_DESC";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."RespRsrceEntityTypCd" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."RESOURCE_ENTITY_CODE";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."RespRsrceNativeVal" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."RESOURCE_NATIVE";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."RespLocTyp" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."LOCATION_CODE";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."RespLocNativeVal" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."LOCATION_NATIVE";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."RespSubLocTyp" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."SUB_LOCATION_CODE";
SET "OutputRoot"."XML"."org.kp.oa.api.PatientAlertsRsp"."AlertLst"."org.kp.oa.api.AlertDetl"."RespSubLocNativeVal" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"."SUB_LOCATION_NATIVE";
|
: appear to have produced this output with the correct XML tags:
Quote: |
<AlertCd>SECURITY</AlertCd>
<AlrtDesc>CALL MGR IF HOSTILE/THREATENS</AlrtDesc>
<RespRsrceEntityTypCd></RespRsrceEntityTypCd>
<RespRsrceNativeVal></RespRsrceNativeVal>
<RespLocTyp></RespLocTyp>
<RespLocNativeVal></RespLocNativeVal>
<RespSubLocTyp></RespSubLocTyp>
<RespSubLocNativeVal></RespSubLocNativeVal>
|
I think you might need to loop through the piece of ESQL twice, but also change some of the other ESQL also. |
|
Back to top |
|
 |
TonyD |
Posted: Tue Feb 04, 2003 3:10 pm Post subject: |
|
|
Knight
Joined: 15 May 2001 Posts: 540 Location: New Zealand
|
...later....
If you want your output to look like:
Quote: |
<PatientAlertsRsp>
<Region>
...
<NoRtrn>
<AlertLst>
<Alert Detl(1)>
<AlertCD>
......
<RespSubLocNativeVal>
<Alert Detl(2)>
<AlertCD>
......
<RespSubLocNativeVal>
</AlertLst>
</PatientAlertsRsp>
|
Then I would suggest something like this following the line where you 'SET OutputRoot......NoRtrn':
Quote: |
DECLARE COUNT INTEGER;
SET COUNT = 1;
WHILE COUNT <= InputRoot.MRM.NUMBER_OF_ALERTS DO
SET OutputRoot.....AlertLst.AlertDet1[COUNT].AlertCD = InputRoot.....ALERT_DETAIL_ENTRY[COUNT].ALERT_CAT;
-- Repeat this for the other seven input fields
SET COUNT = COUNT +1;
END WHILE; |
|
|
Back to top |
|
 |
vickie_ews |
Posted: Tue Feb 04, 2003 5:32 pm Post subject: Successful ESQL for MRM-XML using OCCURS and XML Tag Names |
|
|
Novice
Joined: 04 Sep 2002 Posts: 18
|
yippee-skippy!
Tony D., thanks for your suggestions - which worked well. By way of example, attached is the ESQL code for reference:
****************** ESQL ****************************
DECLARE C INTEGER;
SET C = CARDINALITY(InputRoot.*[]);
DECLARE I INTEGER;
SET I = 1;
WHILE I < C DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I=I+1;
END WHILE;
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
--- Declare Variable for Repeating Fields
DECLARE COUNTER INTEGER;
-- Transform MRM to XML
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."Region" = "InputRoot"."MRM"."REGION";
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."CntxtId" = "InputRoot"."MRM"."CONTEXT_ID";
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."StartPtr" = "InputRoot"."MRM"."START_POINTER";
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."MoreAlertsSw" = "InputRoot"."MRM"."MORE_ALERTS_SWITCH";
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."NoRtrn" = "InputRoot"."MRM"."NUMBER_OF_ALERTS";
-- Loop for Number of Occurs
SET COUNTER = 1;
WHILE COUNTER <= "InputRoot"."MRM"."NUMBER_OF_ALERTS" DO
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."AlertLst"."org.abp.AlertsRsp.AlertDetl"[COUNTER]."AlertCd" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"[COUNTER]."ALERT_CAT";
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."AlertLst"."org.abp.AlertsRsp.AlertDetl"[COUNTER]."AlrtDesc" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"[COUNTER]."ALERT_DESC";
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."AlertLst"."org.abp.AlertsRsp.AlertDetl"[COUNTER]."RespRsrceEntityTypCd" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"[COUNTER]."RESOURCE_ENTITY_CODE";
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."AlertLst"."org.abp.AlertsRsp.AlertDetl"[COUNTER]."RespRsrceNativeVal" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"[COUNTER]."RESOURCE_NATIVE";
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."AlertLst"."org.abp.AlertsRsp.AlertDetl"[COUNTER]."RespLocTyp" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"[COUNTER]."LOCATION_CODE";
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."AlertLst"."org.abp.AlertsRsp.AlertDetl"[COUNTER]."RespLocNativeVal" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"[COUNTER]."LOCATION_NATIVE";
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."AlertLst"."org.abp.AlertsRsp.AlertDetl"[COUNTER]."RespSubLocTyp" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"[COUNTER]."SUB_LOCATION_CODE";
SET "OutputRoot"."XML"."org.abp.AlertsRsp"."AlertLst"."org.abp.AlertsRsp.AlertDetl"[COUNTER]."RespSubLocNativeVal" = "InputRoot"."MRM"."ALERT_LIST"."ALERT_DETAIL_ENTRY"[COUNTER]."SUB_LOCATION_NATIVE";
-- Repeat this for the other occurs
SET COUNTER = COUNTER +1;
END WHILE;
******************* END ESQL *******************************
Now the XML tag names are displayed for each occurrence of the Alert Detail.
most gratefully,
vickie_ews |
|
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
|
|
|
|