| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| deepa12 Beginner
 
 
 Joined: 05 Apr 2005
 Posts: 131
 Topics: 64
 Location: chennai
 
 | 
			
				|  Posted: Mon Aug 25, 2014 2:03 pm    Post subject: Numeric deedit |   |  
				| 
 |  
				| Consider the following WS-A PIC S9(V4)V99 COMP.
 WS-A1 PIC S9(V4)V99.
 WS-B PIC ZZ99.99
 
 Consider the following code
 
 move ws-b to ws-a
 what i understand is using numeric dedit in this fashion is not correct coding practice. Is this true
 
 move ws-b to ws-a1  - is this safer than the above?
 i.e using DISPLAY field rather than COMP Field
 _________________
 deepa
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 | 
			
				|  Posted: Mon Aug 25, 2014 2:27 pm    Post subject: Re: numeric deedit |   |  
				| 
 |  
				|  	  | deepa12 wrote: |  	  | Consider the following WS-A PIC S9(V4)V99 COMP.
 WS-A1 PIC S9(V4)V99.
 WS-B PIC ZZ99.99
 | 
 
 Deepa,
 
 Can you please enlighten me as to which COBOL version supports the PIC S9(V4)V99 COMP definitions?
 
 
 
  	  | deepa12 wrote: |  	  | Consider the following code
 move ws-b to ws-a
 what i understand is using numeric dedit in this fashion is not correct coding practice. Is this true
 
 move ws-b to ws-a1  - is this safer than the above?
 i.e using DISPLAY field rather than COMP Field
 | 
 
 Safer in what sense? No matter which Move Instruction you use you will end with a 0C7 abend if either WS-B or WS-A1 contain uninitialized/Garbage values.
 
 You need to remember that every line you code is internally translated to a machine language by your compiler. So your main goal should be to reduce the number of instructions that your code generates.  In order to see the machine instructions generated you just need to use the compiler option LIST
 
 Run this sample JCL and look at the sysprint output from this step and determine which move is appropriate.
 
  	  | Code: |  	  | //STEP0100 EXEC PGM=IGYCRCTL
 //SYSPRINT DD SYSOUT=*
 //SYSTERM  DD SYSOUT=*
 //SYSUT1   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)
 //SYSUT2   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)
 //SYSUT3   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)
 //SYSUT4   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)
 //SYSUT5   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)
 //SYSUT6   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)
 //SYSUT7   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)
 //SYSLIN   DD DSN=&&LOADSET,
 //            DISP=(MOD,PASS),
 //            UNIT=SYSDA,
 //            SPACE=(CYL,(1,1),RLSE)
 //SYSIN    DD *
 CBL LIST
 IDENTIFICATION DIVISION.
 PROGRAM-ID. TEMP1.
 ENVIRONMENT DIVISION.
 DATA DIVISION.
 WORKING-STORAGE SECTION.
 01 WS-A           PIC S9(4)V99 COMP.
 01 WS-A1          PIC S9(4)V99.
 01 WS-B           PIC ZZ99.99.
 PROCEDURE DIVISION.
 MOVE 12.34 TO WS-A1
 WS-B
 PERFORM 1000-WS-B-MOVE
 PERFORM 2000-WS-A1-MOVE
 GOBACK
 .
 
 1000-WS-B-MOVE.
 MOVE WS-B        TO WS-A
 .
 2000-WS-A1-MOVE.
 MOVE WS-A1       TO WS-A
 .
 /*
 | 
 _________________
 Kolusu
 www.linkedin.com/in/kolusu
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| deepa12 Beginner
 
 
 Joined: 05 Apr 2005
 Posts: 131
 Topics: 64
 Location: chennai
 
 | 
			
				|  Posted: Mon Aug 25, 2014 7:34 pm    Post subject: |   |  
				| 
 |  
				| Sorry that was aa typo The folln should have been WS-A PIC S9(4)V99 COMP
 _________________
 deepa
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| William Collins Supermod
 
 
 Joined: 03 Jun 2012
 Posts: 437
 Topics: 0
 
 
 | 
			
				|  Posted: Tue Aug 26, 2014 9:35 am    Post subject: |   |  
				| 
 |  
				| What is the content of your data? If you have an actual decimal-point in your data, the de-editing is one way to MOVE the data to a numeric field - using a numeric field whilst there is still an actual decimal-point lurking will get you a S0C7. 
 There is a more-code-but-validate-the-data solution if you have an atcual decimal-point as well.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| deepa12 Beginner
 
 
 Joined: 05 Apr 2005
 Posts: 131
 Topics: 64
 Location: chennai
 
 | 
			
				|  Posted: Tue Aug 26, 2014 11:39 pm    Post subject: |   |  
				| 
 |  
				| WS-B PIC ZZ99.99 will have data like <space><space>12.34 i.e it will have actual decimal point Now we have actually changed the code to the folln:
 MOVE WS-B TO WS-A1
 instead of
 MOVE WS-B TO WS-A
 Pls suggest
 _________________
 deepa
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| William Collins Supermod
 
 
 Joined: 03 Jun 2012
 Posts: 437
 Topics: 0
 
 
 | 
			
				|  Posted: Wed Aug 27, 2014 2:31 am    Post subject: |   |  
				| 
 |  
				| An appropriate data-type depends on what you are going to do with the thing. 
 If I have edited numbers arriving, I de-edit them (a different way) to a USAGE DISPLAY field (so a PIC 9 or PIC X of the correct length). If I want to do something else with that (like use it in a calculation) they I'd MOVE it to a packed-decimal.
 
 Long ago I was told not to use binary fields with decimal places. So I don't. Which now means I don't know if that is good advice or not.
 
 As to which of your examples is "safer", if the source field contains data which will cause a S0C7 then the MOVE to the binary field will cause the S0C7 (on a CVB (convert to binary) instruction) and the MOVE to the USAGE DISPLAY item will not cause a S0C7 - until you do something with the field which causes a decimal instruction (or CVB) to be used.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| deepa12 Beginner
 
 
 Joined: 05 Apr 2005
 Posts: 131
 Topics: 64
 Location: chennai
 
 | 
			
				|  Posted: Wed Aug 27, 2014 3:35 am    Post subject: |   |  
				| 
 |  
				| Many thanks _________________
 deepa
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  | 
	
		|  |