View previous topic :: View next topic |
Author |
Message |
radkrish Beginner

Joined: 12 Aug 2005 Posts: 102 Topics: 19
|
Posted: Thu May 10, 2007 10:39 am Post subject: truncation of spaces |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12382 Topics: 75 Location: San Jose
|
Posted: Thu May 10, 2007 10:53 am Post subject: |
|
|
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 |
|
 |
radkrish Beginner

Joined: 12 Aug 2005 Posts: 102 Topics: 19
|
Posted: Thu May 10, 2007 11:25 am Post subject: |
|
|
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 |
|
 |
|
|