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: 6967
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
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


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