Removing the Extra spaces in COBOL



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Removing the Extra spaces in COBOL

Postby JerrinThomas » Wed Dec 22, 2010 1:22 am

Hi,
I am having a requirement such as below:-
I have an address field and a Pin code which i need to concatenate and put together after removing all the trailing spaces.
01 Address Char(140)
01 Pin Code PIC 9(8)
Address :- 123 WESTFIELD FORTMINOR BROOKLYN
Pin Code :- 12345

The resultant should look like 123 WESTFIELD FORTMINOR BROOKLYN,12345

I have tried out using DELIMITED BY SPACES but couldnt remove the extra spaces and it will delimit by the first space that it encounters.In PL/1 we can use TRIM and later a SUBSTR which will resolve the issue. Can anyone give any possible solutions in cobol that i could work on see if its fine. Thanks.
JerrinThomas
 
Posts: 1
Joined: Wed Dec 22, 2010 1:06 am
Has thanked: 0 time
Been thanked: 0 time

Re: Removing the Extra spaces in COBOL

Postby NicC » Wed Dec 22, 2010 2:09 am

I believe that if you search this section of the forum, which you should have done before posting, then you will find some threads dealing with the removal of trailing spaces, or finding the first trailing space. With reference modification, which is similar to SUBSTR in PL/1 and Rexx, you can cut out the data and/or overlay trailing blanks with the comma and pin code.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Removing the Extra spaces in COBOL

Postby dick scherrer » Wed Dec 22, 2010 9:02 am

Hello and welcome to the forum,

What have you tried so far? Are you stuck somewhere?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Removing the Extra spaces in COBOL

Postby dvsunaina » Wed Jul 20, 2011 3:47 pm

you know the length of two strings,
using perform varying length by -1 and find the non space char value.
find second string value also,
move reference to other variable of big(concatination) and ,
repeat same step for new varible ,
finally you get the exat result..
dvsunaina
 
Posts: 2
Joined: Fri Jun 24, 2011 2:33 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Removing the Extra spaces in COBOL

Postby BillyBoyo » Wed Jul 20, 2011 3:55 pm

OK, nice to have someone new around.

However, please stop dragging up old topics. The original questioner is long gone.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post