IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

String function in Cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
inamadugu
Warnings : 1

New User


Joined: 23 Aug 2007
Posts: 18
Location: Delhi

PostPosted: Mon Nov 12, 2007 11:42 am
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Nov 12, 2007 3:37 pm
Reply with quote

The space is in the size of dta item-1, you need to delimit it with something other than size......
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Mon Nov 12, 2007 7:19 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Nov 13, 2007 1:23 pm
Reply with quote

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
View user's profile Send private message
inamadugu
Warnings : 1

New User


Joined: 23 Aug 2007
Posts: 18
Location: Delhi

PostPosted: Tue Nov 13, 2007 3:45 pm
Reply with quote

Hi friends,

Thank you for your replies.
My requirement was fulfilled.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top