| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| kris_madras Beginner
 
 
 Joined: 07 Apr 2004
 Posts: 41
 Topics: 30
 
 
 | 
			
				|  Posted: Wed Oct 20, 2004 7:15 am    Post subject: Formatting Alphanumeric in COBOl |   |  
				| 
 |  
				| Hi, I am struggling to solve this problem in COBOL
 
 The requirements is
 Two data items
 
 XHR-SRA1     is defined as   x(10).  and
 
 XHR-SRA2     is defined as 9(10) comp-3.
 
 
 
 There is no guarantee that XHA-SRA1 always contains the same length value(can be 123 , 1234, 12345.....)
 
 when I move XHR-SRA1 value to XHA-SRA2,
 
 for example
 
 XHA-SRA1  = 12345678
 
 MOVE XHA-SRA1 TO XHA-SRA2 then
 the value in XHA-SRA2 i am getting 1234567800
 The data what I need is   0012345678 in the computational field.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| kolusu Site Admin
 
  
 
 Joined: 26 Nov 2002
 Posts: 12394
 Topics: 75
 Location: San Jose
 
 | 
			
				|  Posted: Wed Oct 20, 2004 8:34 am    Post subject: |   |  
				| 
 |  
				| Kris_madras, 
 Try this
 
 
  	  | Code: |  	  | 01 XHR-SRA1               PIC X(10).
 01 XHR-SRA2               PIC 9(10) COMP-3.
 01 WS-TALLY               PIC S9(04) COMP.
 01 WS-LEN                 PIC S9(04) COMP.
 01 WS-TEMP                PIC 9(10).
 
 
 INSPECT FUNCTION REVERSE(XHR-SRA1) TALLYING WS-TALLY
 FOR LEADING SPACES
 
 COMPUTE WS-LEN = LENGTH OF XHR-SRA1 - WS-TALLY
 
 MOVE ZEROES               TO  WS-TEMP (1 : WS-TALLY)
 
 MOVE XHR-SRA1(1 : WS-LEN) TO
 WS-TEMP (WS-TALLY + 1 : WS-LEN)
 
 MOVE WS-TEMP              TO  XHR-SRA2
 
 
 
 
 | 
 
 Hope this helps...
 
 Cheers
 
 kolusu
 _________________
 Kolusu
 www.linkedin.com/in/kolusu
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| kris_madras Beginner
 
 
 Joined: 07 Apr 2004
 Posts: 41
 Topics: 30
 
 
 | 
			
				|  Posted: Fri Oct 22, 2004 4:07 am    Post subject: |   |  
				| 
 |  
				| Hi, Its working ...It doesn't make any sense to reply thanks to You and MVSFORUMS lot of thanks..
 
 Kris
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  | 
	
		|  |