Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

String function in Cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: String function in Cobol
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: 2150
Location: At my coffee table

PostPosted: Mon Nov 12, 2007 3:37 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Reply to: String function in Cobol
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us