Page 1 of 1

Removing the Extra spaces in COBOL

PostPosted: Wed Dec 22, 2010 1:22 am
by JerrinThomas
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.

Re: Removing the Extra spaces in COBOL

PostPosted: Wed Dec 22, 2010 2:09 am
by NicC
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.

Re: Removing the Extra spaces in COBOL

PostPosted: Wed Dec 22, 2010 9:02 am
by dick scherrer
Hello and welcome to the forum,

What have you tried so far? Are you stuck somewhere?

Re: Removing the Extra spaces in COBOL

PostPosted: Wed Jul 20, 2011 3:47 pm
by dvsunaina
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..

Re: Removing the Extra spaces in COBOL

PostPosted: Wed Jul 20, 2011 3:55 pm
by BillyBoyo
OK, nice to have someone new around.

However, please stop dragging up old topics. The original questioner is long gone.