| Author | 
		  Message
		 | 
		
		  | CHERIANV | 
		  
		    
			  
				 Posted: Tue Aug 06, 2002 12:48 pm    Post subject: Using CREATE FIELD with PROPAGATE | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 15 Feb 2002 Posts: 43 Location: New York 
  | 
		  
		    
			  
				Hi, 
 
I am facing a  problem when using CREATE FIELD along with PROPAGATE. 
 
Any input would be appreciated!
 
 
Suppose I use it like the following for an XML to MRM transformation for assigning my OutputRoot.MRM fields,it ofcourse doesnt work as it expects the CREATE FIELD and outref REERENCE declaration to be within WHILE loop as I PROPAGATE . I just want to figure out the most efficient way to use REFERENCE in the OutputRoot  as I have several lines of similiar field assignments and  different scenarios to PROPAGATE within the WHILE loop. 
 
 
DECLARE inref REFERENCE to InputRoot.XML.PARENT.CHILD[1]; 
 
CREATE FIELD OutputRoot.MRM.LEVEL1.LEVEL2; 
 
DECLARE outref REFERENCE to OutputRoot.MRM.LEVEL1.LEVEL2; 
 
 
WHILE LASTMOVE(inref) THEN 
 
Assign Properties; 
 
Assign MQMD; 
 
 
Set outref.field1 = 'a'; 
 
Set outref.field2 = 'b'; 
 
Set outref.field3 = 'c'; 
 
PROPAGATE; 
 
 
MOVE inref TO NEXTSIBLING REPEAT NAME; 
 
 
END WHILE;
 
 
RETURN FALSE; | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kirani | 
		  
		    
			  
				 Posted: Tue Aug 06, 2002 1:25 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Jedi Knight
 
 Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA 
  | 
		  
		    
			  
				Are you trying to create multiple output messages in MRM format from a single XML input message? Could you post an example of your input and output message? _________________ Kiran
 
 
 
IBM Cert. Solution Designer & System Administrator - WBIMB V5
 
IBM Cert. Solutions Expert - WMQI
 
IBM Cert. Specialist - WMQI, MQSeries
 
IBM Cert. Developer - MQSeries
 
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | CHERIANV | 
		  
		    
			  
				 Posted: Tue Aug 06, 2002 2:57 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 15 Feb 2002 Posts: 43 Location: New York 
  | 
		  
		    
			  
				Yes,Kiran. I  am creating multiple MRM messages  of a single XML msg. Iam able to iterate thru  my  Input  XML msg. using  REFERENCE, LASTMOVE  and MOVE  without any  problem. Its only  when I create  my  output  msg. do I hit into problems when using  PROPAGATE  within a WHILE loop. 
 
 
My  output MRM  structure  looks  like :  
 
 
01  STRUCT1.
 
      03  LEVEL1.
 
           05  LEVEL2.
 
                 07 FIELD1  PIC  X(01).
 
                 07 FIELD2  PIC  X(03).
 
...etc.
 
 
I attempted to declare a reference to my output  msg.  like  the  following  and  then  used STRUCT1_REF  to assign fields  within  my  WHILE loop  with PROPAGATE like my prev.  post.
 
 
CREATE FIELD OutputRoot.MRM.STRUCT1.LEVEL1;
 
DECLARE  STRUCT1_REF  REFERENCE OutputRoot.MRM.STRUCT1.LEVEL1;
 
 
I  tried  to playaround by  using MOVE STRUCT1_REF  to  FIRSTCHILD etc. for every  iteration  and it still doesnt  work.It  works  if I put  the  above CREATE FIELD and DECLARE STRUCT_REF1 declaration within the loop but  I  want to be  able to use STRUCT_REF1  in the entire  Compute  node  (if  u know what I mean)  and dont want  that.  Any ideas ? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kirani | 
		  
		    
			  
				 Posted: Tue Aug 06, 2002 3:20 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Jedi Knight
 
 Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA 
  | 
		  
		    
			  
				You could move the DECLARE statement out of WHILE loop and then do CREATE FIELD inside the while loop?
 
 
   
	| Code: | 
   
  
	
 
DECLARE inref REFERENCE to InputRoot.XML.PARENT.CHILD[1]; 
 
CREATE FIELD OutputRoot.MRM;
 
DECLARE outref REFERENCE to OutputRoot.MRM;
 
 
WHILE LASTMOVE(inref) THEN 
 
  -- Assign properties
 
  -- Assign MQMD
 
 
  CREATE FIELD OutputRoot.MRM.LEVEL1.LEVEL2;
 
  MOVE outref OutputRoot.MRM.LEVEL1.LEVEL2;
 
 
  Set outref.field1 = 'a'; 
 
  Set outref.field2 = 'b'; 
 
  Set outref.field3 = 'c'; 
 
  ...
 
  PROPAGATE; 
 
 
  MOVE inref TO NEXTSIBLING REPEAT NAME; 
 
END WHILE; 
 
 
RETURN FALSE;
 
 | 
   
 
 _________________ Kiran
 
 
 
IBM Cert. Solution Designer & System Administrator - WBIMB V5
 
IBM Cert. Solutions Expert - WMQI
 
IBM Cert. Specialist - WMQI, MQSeries
 
IBM Cert. Developer - MQSeries
 
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | CHERIANV | 
		  
		    
			  
				 Posted: Tue Aug 06, 2002 4:22 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 15 Feb 2002 Posts: 43 Location: New York 
  | 
		  
		    
			  
				Hi, 
 
 Thanks for your suggestion.  I  presume the st.  MOVE outref  OutputRoot.MRM.LEVEL1.LEVEL2 within  the WHILE  loop is MOVE outref  TO OutputRoot.MRM.LEVEL1.LEVEL2 .  I just tried this and its failing with error msg. "An  unexpected NULL value  was  encountered". Also, the  logical  tree in my  Trace node  during the 2'nd  iteration has all  Properties  fields as NULL. Am I  missing something? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kirani | 
		  
		    
			  
				 Posted: Tue Aug 06, 2002 5:09 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Jedi Knight
 
 Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA 
  | 
		  
		    
			  
				I know similar logic works for XML messages. I will have to test this on my machine for output MRM message. 
 
I will post the results here. _________________ Kiran
 
 
 
IBM Cert. Solution Designer & System Administrator - WBIMB V5
 
IBM Cert. Solutions Expert - WMQI
 
IBM Cert. Specialist - WMQI, MQSeries
 
IBM Cert. Developer - MQSeries
 
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | warrenpage | 
		  
		    
			  
				 Posted: Tue Aug 06, 2002 8:56 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Acolyte
 
 Joined: 19 Feb 2002 Posts: 56 Location: Australia 
  | 
		  
		    
			  
				We do exactly as you are asking using the following code
 
 
 
DECLARE GlobalParms REFERENCE TO "InputDestinationList"."Scratch"."Global"."Properties";
 
DECLARE CurrRec REFERENCE TO "InputDestinationList"."Scratch"."Record";
 
 
WHILE LASTMOVE(CurrRec) DO
 
  SET OutputRoot.Properties  = InputRoot.Properties;
 
  SET OutputRoot.MQMD        = InputRoot.MQMD;
 
  SET OutputRoot.MQMD.Format = 'MQSTR';
 
 
        SET "OutputRoot"."Properties"."MessageSet"     = GlobalParms."MessageSet";
 
        SET "OutputRoot"."Properties"."MessageDomain"  = GlobalParms."MessageDomain";
 
        SET "OutputRoot"."Properties"."CodedCharSetId" = GlobalParms."CodedCharSetId";
 
        SET "OutputRoot"."Properties"."MessageFormat"  = GlobalParms."MessageFormat";
 
 
        SET "OutputRoot"."Properties"."MessageType"    = CurrRec."Properties"."MessageType";
 
 
        SET "OutputRoot"."MRM" = NULL;
 
        SET "OutputRoot"."MRM" = CurrRec.MRM;
 
  PROPAGATE;
 
  MOVE CurrRec NEXTSIBLING REPEAT TYPE NAME;
 
END WHILE;
 
 
RETURN FALSE; | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kirani | 
		  
		    
			  
				 Posted: Tue Aug 06, 2002 9:18 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Jedi Knight
 
 Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA 
  | 
		  
		    
			  
				CHERIANV,
 
 
I have tested REFERENCE with PROPAGATE for XML to MRM conversion and it works fine. My code looks very similar to warrenpage's code. 
 
 
   
	| Code: | 
   
  
	
 
DECLARE I INTEGER;
 
SET I = 1;
 
WHILE I < CARDINALITY(InputRoot.*[]) 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 inref REFERENCE TO InputRoot.XML.Parent.Child[1]; 
 
SET OutputRoot.Properties = Environment.Variables.Properties;
 
SET OutputRoot.MQMD = Environment.Variables.MQMD;
 
CREATE FIELD OutputRoot.MRM;
 
DECLARE outref REFERENCE TO OutputRoot.MRM;
 
 
WHILE LASTMOVE(inref)  DO
 
  SET OutputRoot.Properties = InputRoot.Properties;
 
  SET OutputRoot.MQMD = InputRoot.MQMD;
 
  SET OutputRoot.MRM = NULL;
 
 
  CREATE FIELD OutputRoot.MRM.LEVEL1.LEVEL2; 
 
  MOVE outref TO OutputRoot.MRM.LEVEL1.LEVEL2; 
 
  SET outref.field1 = 'a';
 
  SET outref.field2 = 'b';
 
  SET outref.field3 = 'c';
 
 
  SET OutputRoot.Properties.MessageSet = 'DPUAIHK07A001';
 
  SET OutputRoot.Properties.MessageType = 'm_COB';
 
  SET OutputRoot.Properties.MessageFormat = 'CWF';
 
  PROPAGATE; 
 
 
  MOVE inref NEXTSIBLING ; 
 
END WHILE; 
 
 
RETURN FALSE; 
 
 | 
   
 
 _________________ Kiran
 
 
 
IBM Cert. Solution Designer & System Administrator - WBIMB V5
 
IBM Cert. Solutions Expert - WMQI
 
IBM Cert. Specialist - WMQI, MQSeries
 
IBM Cert. Developer - MQSeries
 
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | CHERIANV | 
		  
		    
			  
				 Posted: Wed Aug 07, 2002 7:02 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 15 Feb 2002 Posts: 43 Location: New York 
  | 
		  
		    
			  
				Thanks much Kiran and warren for your suggestions and examples. I was able to fit this functionality into a fairly large and complex piece of code.
 
 
Cherian | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |