| Author | 
		  Message
		 | 
		
		  | lozaza | 
		  
		    
			  
				 Posted: Mon Oct 13, 2014 4:09 pm    Post subject: Incorrect numeric parsing and conversion | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 04 Mar 2013 Posts: 27
  
  | 
		  
		    
			  
				It is my very first message flow, so please be bearable if it sounds gibblish:) I am converting some data from XML to COBOL , all workig fine but the numbers.
 
 
below is part of my Copybook:
 
 
           
   
	| Code: | 
   
  
	 05 NUMBER-OF-ITEMS   PIC 9(4) BINARY.
 
            05 ITEM OCCURS 1 TO 100 DEPENDING ON NUMBER-OF-ITEMS.
 
          10 PRODUCT-ID      PIC X(9).
 
             10 QUANTITY        PIC 9(4) BINARY.
 
             10 UNIT-COST       PIC 9(8)V99 COMP-3.
 
 | 
   
 
 
and ESQL code:
 
   
	| Code: | 
   
  
	
 
      DECLARE I INTEGER 1;
 
      DECLARE J INTEGER; 
 
      DECLARE A DECIMAL;
 
      DECLARE B INTEGER;
 
      SET J = CARDINALITY(InputRoot.XMLNSC.p:Order.p:Order_Items.p:Item[]);
 
      SET OutputRoot.DFDL.ORDERS.NUMBER_OF_ITEMS = J ;
 
      WHILE I <= J DO
 
         SET OutputRoot.DFDL.ORDERS.ITEM[I].PRODUCT_ID = InputRoot.XMLNSC.p:Order.p:Order_Items.p:Item[I].p:Part_Number;
 
         SET OutputRoot.DFDL.ORDERS.ITEM[I].QUANTITY = InputRoot.XMLNSC.p:Order.p:Order_Items.p:Item[I].p:Quantity;
 
         SET A = CAST (InputRoot.XMLNSC.p:Order.p:Order_Items.p:Item[I].p:Price AS DECIMAL );
 
         SET B = CAST (InputRoot.XMLNSC.p:Order.p:Order_Items.p:Item[I].p:Quantity AS INTEGER );
 
         SET OutputRoot.DFDL.ORDERS.ITEM[I].UNIT_COST = A / B ; 
 
         SET I = I + 1;
 
      END WHILE; 
 
 | 
   
 
 
So basically for the XML, there are 3 items and one of the items for example as below:
 
 
   
	| Code: | 
   
  
	  <p:Part_Number>20000002</p:Part_Number> 
 
  <p:Quantity>4</p:Quantity> 
 
  <p:Description>Railway Track</p:Description> 
 
  <p:Price>10000.00</p:Price> 
 
 | 
   
 
 
 
This is what I can from RFHUtil:
 
 
   
	| Code: | 
   
  
	10    99     2 INT     1 QUANTITY                       0400
 
***** RFHUtil format error - Invalid Packed Decimal data in next field
 
10   101     6 PD      1 UNIT-COST                      0F0050020000
 
05   107    17         2 ITEM
 
10   107     9 CHAR    2 PRODUCT-ID                     20000003 
 
10   116     2 INT     2 QUANTITY                       0100 | 
   
 
 
 
the number is not BigEndian and the packed decimal incorrect. As I can understand I don't need to do any conversion in ESQ for the numeric because
 
 they will be parsed automatically. I imported the message model for Copybook as 
 
 
Target z/os IBM500 for encoing and floating 390. I also defined CCSID 500 and encoding 785 in my esql. Anything wrong or any advice?
 
 
JS | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Tue Oct 14, 2014 3:15 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
			  
				DFDL may be taking its numeric 'encoding' ( endianness ) from InputRoot.Properties. Look at the numeric field in the DFDL editor - if it is set to $dfd:encoding then my guess is correct. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | lozaza | 
		  
		    
			  
				 Posted: Tue Oct 14, 2014 6:16 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 04 Mar 2013 Posts: 27
  
  | 
		  
		    
			  
				Hi Kimbert thanks for your reply, 
 
 
if the DFDL editor is the properties part in right of the tools kit when I select the cobol schema definition, they are all IBM500 for 'Encoding' and bigEndian for 'Byte Order'. I can see {$dfdl:encoding} at the very top but. Normal number is ok for example PIC 9(4), but when Binary and PD involved it shows error.
 
 
btw it is Integration bus 9 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Wed Oct 15, 2014 5:02 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				When dealing with MQ as a transport, you need to consider three things to help resolve conversion questions/problems.
 
 
1) Are you using the right thing to view the actual contents of the actual message - i.e. you need to eliminate the tool you're using to view the data as the *cause* of the problem.
 
 
2) Is the message moving over an MQ channel that has conversion set?
 
 
3) Does the CCSID and Encoding accurately represent the *data* in the message.  Not what you think it should be, but what it actually IS. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | lozaza | 
		  
		    
			  
				 Posted: Sun Oct 26, 2014 9:16 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 04 Mar 2013 Posts: 27
  
  | 
		  
		    
			  
				Hello MqJeff and Kimbert. Thanks very much for your help! and problem resolved. I am using wrong option in rfhutil to view the message. So DAMN easy. everything is right with message model and my esql.  
 
 
good learning experience thou   | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |