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 

truncation of spaces

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


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Thu May 10, 2007 10:39 am    Post subject: truncation of spaces Reply with quote

My requirement is to move a file variable of 8 char to a variable in VSAM of 6 chars.

Code:
01 File-var     pic x(8)
01 vsam-var  pic x(6)

File-var - 8 CHAR
--------
values can be :

Code:
1)  A2B2C6    - first 2 char are spaces
2)A2B8C5       - last 2 char are spaces
3) A2B6C5     - first 1 char is space
4)A2B7C5       - last  2 char are spaces

All the case, if its moved to 6 char field then it should display the 6 char value. i.e truncate the spaces and move.

Code:
1)A2B2C6
2)A2B8C5
3)A2B6C5
4)A2B7C5



Please provide me some simple logic to do this in cobol and not in JCL.

regds,
radkrish
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu May 10, 2007 10:53 am    Post subject: Reply with quote

radkrish,

hmm is this a trick question? It is fairly simple with just a single perform statement.

try this untested code

Code:

01 ISUB         PIC S9(04) COMP.
01 OSUB         PIC S9(04) COMP.

MOVE +0     TO OSUB                                   
PERFORM VARYING ISUB FROM 1 BY 1                       
  UNTIL ISUB > 8                                       
     IF FILE-VAR (ISUB : 1) > SPACES                   
        ADD +1                   TO OSUB               
        MOVE FILE-VAR (ISUB : 1) TO VSAM-VAR (OSUB : 1)
     END-IF                                           


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
radkrish
Beginner


Joined: 12 Aug 2005
Posts: 102
Topics: 19

PostPosted: Thu May 10, 2007 11:25 am    Post subject: Reply with quote

Thanks, Kolusu. I will test it. Its not a tricky question though I was using evaluate verb and peforming through more number of coding lines. I got a shorter form comparably from yourside.your code is usefull for me.

Generally, I will get a solution by doing some crap/bulk codes for atleast 50 percentage of queries. The major point to raise the query here is that i will get a solution definitely and I feel this forum gives me best possible answers out of many options available considering performance and optimisation. You ppl stick to basics and working out the code. Iam learning those capabilities one by one. Thanks to all best repliers. Iam proud of being a member here.

regds,
radkrish
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