View previous topic :: View next topic
|
Author |
Message |
inamadugu Warnings : 1 New User
Joined: 23 Aug 2007 Posts: 18 Location: Delhi
|
|
|
|
I am using the STRING function in my Cobol programe like this:
String data item-1 data item-2
delimited by size into data item-3
End-string.
I am getting lot of space between the two data items(1 and 2) in data item-3. But I need single space between these two data items. What is the procedure to achieve this? |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
The space is in the size of dta item-1, you need to delimit it with something other than size...... |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
If data-item-1 has no spaces in the string that you want to move into 3 then you could use the following:
Code: |
string data-item-1
delimited by space
pointer ptr
into data-item-3
string data-item-2
delimited by space
pointer ptr
into data-item-3
|
However, if there are embedded spaces in your strings you will need to find the actual length of the data and do this:
Code: |
perform varying d1-len from length of data-item-1 by -1
until data-item-1(d1-len:1) NOT = X'40' or data-item-1 = 0
perform varying d2-len from length of data-item-2 by -1
until data-item-2(d2-len:1) NOT = X'40' or data-item-2 = 0
string data-item-1(1:d1-len)
delimited by size
pointer ptr
into data-item-3
string data-item-2(1:d2-len)
delimited by size
pointer ptr
into data-item-3
|
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Code: |
String data item-1
delimited by space
' '
delimited by size
data item-2
delimited by spaces
into data item-3
End-string
|
|
|
Back to top |
|
|
inamadugu Warnings : 1 New User
Joined: 23 Aug 2007 Posts: 18 Location: Delhi
|
|
|
|
Hi friends,
Thank you for your replies.
My requirement was fulfilled. |
|
Back to top |
|
|
|