| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| deepa12 Beginner
 
 
 Joined: 05 Apr 2005
 Posts: 131
 Topics: 64
 Location: chennai
 
 | 
			
				|  Posted: Thu Jul 24, 2014 8:09 am    Post subject: How to avoid S0C7 in comp fields ? |   |  
				| 
 |  
				| Hi How to avoid s0c7 in comp fields since we cant do numeric check
 Scenario:
 suppose i have a LA-B in a file which is s9() comp
 I read a record & have the following code
 MOVE LA-B to WS-LA-B
 The above move will fail if LA-B has some junk
 So what to do
 Thanks
 deepa
 _________________
 deepa
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Terry_Heinze Supermod
 
 
 Joined: 31 May 2004
 Posts: 391
 Topics: 4
 Location: Richfield, MN, USA
 
 | 
			
				|  Posted: Thu Jul 24, 2014 8:16 am    Post subject: |   |  
				| 
 |  
				| What prevents you from checking for numeric? _________________
 ....Terry
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| William Collins Supermod
 
 
 Joined: 03 Jun 2012
 Posts: 437
 Topics: 0
 
 
 | 
			
				|  Posted: Thu Jul 24, 2014 9:49 am    Post subject: |   |  
				| 
 |  
				| COMP fields are binary fields. The MOVE will not fail. |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| deepa12 Beginner
 
 
 Joined: 05 Apr 2005
 Posts: 131
 Topics: 64
 Location: chennai
 
 | 
			
				|  Posted: Thu Jul 24, 2014 11:47 pm    Post subject: |   |  
				| 
 |  
				| Hi Numeric check can be made only for X(5) sort of fields Not not COMP fields
 Actually compiler will give error
 _________________
 deepa
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| William Collins Supermod
 
 
 Joined: 03 Jun 2012
 Posts: 437
 Topics: 0
 
 
 | 
			
				|  Posted: Fri Jul 25, 2014 1:10 am    Post subject: |   |  
				| 
 |  
				| For NUMERIC you can check PIC X(n) fields (if the field is not too long), PIC 9(n) USAGE DISPLAY, USAGE COMP-3, USAGE PACKED-DECIMAL. 
 USAGE COMP, COMP-1, COMP-2, COMP-4, COMP-5, BINARY cannot be checked for NUMERIC simply because all bits may be relevant to the result, there is no "junk", there are no non-NUMERIC values (there are incorrect values, but unfortunately we can't test for that).
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Terry_Heinze Supermod
 
 
 Joined: 31 May 2004
 Posts: 391
 Topics: 4
 Location: Richfield, MN, USA
 
 | 
			
				|  Posted: Fri Jul 25, 2014 9:17 am    Post subject: |   |  
				| 
 |  
				| Thanks, William. Sorry for the misleading answer, deepa12. Since all values are valid for COMP fields, one option would be to check for a valid numeric range, right? _________________
 ....Terry
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 | 
			
				|  Posted: Fri Jul 25, 2014 11:25 am    Post subject: |   |  
				| 
 |  
				|  	  | deepa12 wrote: |  	  | Hi Numeric check can be made only for X(5) sort of fields Not not COMP fields
 Actually compiler will give error
 | 
 
 Deepa12,
 
 You do realize that your COMP field can be redefined as alphanumeric field and you can use that field for NUMVAL function?
 
 How about you show us the definitions of LA-B and WS-LA-B and the contents of the LA-B in hex that is causing the S0C7 abend? May be we can suggest an alternative.
 _________________
 Kolusu
 www.linkedin.com/in/kolusu
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| deepa12 Beginner
 
 
 Joined: 05 Apr 2005
 Posts: 131
 Topics: 64
 Location: chennai
 
 | 
			
				|  Posted: Sat Jul 26, 2014 12:52 am    Post subject: re. how to avoid s0c7 in comp fields |   |  
				| 
 |  
				| Actually i tried the folln but i get U4038 abend 
 ws-a pic s9(9)comp.
 ws-b redefines ws-a pic x(4)
 ws-c pic 9(9)
 move 1234 to ws-a
 compute ws-c= function numval(ws-x)
 
 The requirement is i have to avoid soc7 in a comp field binary if it contains junk
 LA-B S9(4)V9(4) COMP
 WS-B S9(4)V9(4).
 MOVE LA-B TO WS-B
 _________________
 deepa
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| William Collins Supermod
 
 
 Joined: 03 Jun 2012
 Posts: 437
 Topics: 0
 
 
 | 
			
				|  Posted: Sat Jul 26, 2014 1:54 am    Post subject: |   |  
				| 
 |  
				| The requirement itself is junk. 
 There are no junk values in a binary field. Depending on how your field is defined, you will always get 0-maximum-picture or 0-maximum-binary value for an unsigned field, for a signed field your range will include negatives.
 
 S0C7 only comes from one of the six decimal machine instructions. It is impossible that a decimal machine instruction will be used directly on a binary field, so impossible, impossible, can't be done, to get a S0C7 on a binary field.
 
 NUMVAL will only work with "chjaracter" data. If you give it actual binary data, it will give you that abend.
 
 Why use decimal places in a binary field?
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| deepa12 Beginner
 
 
 Joined: 05 Apr 2005
 Posts: 131
 Topics: 64
 Location: chennai
 
 | 
			
				|  Posted: Sat Jul 26, 2014 6:27 am    Post subject: |   |  
				| 
 |  
				| Thanks  for this Could you pls elaborate
 on what  are  the six decimal machine instructions. Not clear about this
 
 I dont know why thre record structure has been defined with virtual decimal in comp field
 _________________
 deepa
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| William Collins Supermod
 
 
 Joined: 03 Jun 2012
 Posts: 437
 Topics: 0
 
 
 | 
			
				|  Posted: Sat Jul 26, 2014 6:55 am    Post subject: |   |  
				| 
 |  
				| You locate the Principles of Operation You search there. One is an Add Packed (AP). I think they are all dealt with together. There may be seven... let us know. |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 | 
			
				|  Posted: Sat Jul 26, 2014 9:47 pm    Post subject: Re: re. how to avoid s0c7 in comp fields |   |  
				| 
 |  
				|  	  | deepa12 wrote: |  	  | The requirement is i have to avoid soc7 in a comp field binary if it contains junk | 
 
 Deepa12,
 
 You haven't even show what the JUNK is. The MOVE statement will NOT cause an S0C7 . So there is something else that you are not disclosing.
 
 Can you show us what the JUNK value looks like in HEX?
 _________________
 Kolusu
 www.linkedin.com/in/kolusu
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| deepa12 Beginner
 
 
 Joined: 05 Apr 2005
 Posts: 131
 Topics: 64
 Location: chennai
 
 | 
			
				|  Posted: Sat Jul 26, 2014 11:40 pm    Post subject: |   |  
				| 
 |  
				| actually am an offshore developer It was suggested that we need to avoid s0c7 in this comp field Am not having a real time scenario for this. i tried various combinations of non numeric value in WS-B E.g. ":,'%" , etc in all these combinations finally since its all in bits of 0,1 the subsequent instructions like add 1 to WS-A also works fine. So i think it wouldnt happen in live
 _________________
 deepa
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| William Collins Supermod
 
 
 Joined: 03 Jun 2012
 Posts: 437
 Topics: 0
 
 
 | 
			
				|  Posted: Sun Jul 27, 2014 2:36 am    Post subject: |   |  
				| 
 |  
				| Well, I can 100% guarantee no S0C7. 
 If the analyst is so keen on this field, you could do the range-checking suggested by Terry. If there is no upper limit for the field, you could set your own as 9999.9999 and do something if the value is greater than that.
 
 However, if using compiler option TRUNC(STD) this would be pointless as it would never find anything. If using compiler option TRUNC(OPT) it would be pointless unless someone is doing some "clever" coding with the filed (using REDEFINES, explicitly or imploicitly).
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| deepa12 Beginner
 
 
 Joined: 05 Apr 2005
 Posts: 131
 Topics: 64
 Location: chennai
 
 | 
			
				|  Posted: Sun Jul 27, 2014 7:21 pm    Post subject: |   |  
				| 
 |  
				| thanks _________________
 deepa
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  | 
	
		|  |