MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Formatting Alphanumeric in COBOl

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
kris_madras
Beginner


Joined: 07 Apr 2004
Posts: 46
Topics: 29

PostPosted: Wed Oct 20, 2004 7:15 am    Post subject: Formatting Alphanumeric in COBOl Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Oct 20, 2004 8:34 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
kris_madras
Beginner


Joined: 07 Apr 2004
Posts: 46
Topics: 29

PostPosted: Fri Oct 22, 2004 4:07 am    Post subject: Reply with quote

Hi,
Its working ...It doesn't make any sense to reply thanks to You and MVSFORUMS lot of thanks..

Kris
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group