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

String operation with DELIMITED BY ' ' and DELIMITED BY SIZE


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

New User


Joined: 04 May 2007
Posts: 21
Location: kuala lumpur

PostPosted: Fri Sep 02, 2011 10:35 am
Reply with quote

Hi,

I have a query.....

there is a variable ws-ust1 pic X(20) value 'asdfgh'.
i defined a literal as Lit-percent pic X(1) value '%'.

My concern is I want to run a query using WS-UST1 with 'LIKE' clause.
How should i concatenate the '%' symbol prefixed and suffixed to WS-UST1.
ALSO

wuery will be something like

Select count(*)
into :ws-count
from table1 where column like ws-ust1

I tried using STRING with DELIMITED BY ' ' and DELIMITED BY SIZE but the output string only contains all '%%%%%'.

eg i tried
STRING LT-PERCENT WS-UST1 LT-PERCENT
DELIMITED BY ' ' INTO WS-UST1 .

Please help
Thanks in advance.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Sep 02, 2011 10:42 am
Reply with quote

Hello,

Make the output field of the STRING be a separate field (i.e. ust2), not the ust1 field.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Sep 02, 2011 1:40 pm
Reply with quote

The Manual wrote:

If identifier-1 or identifier-2 occupies the same storage area as identifier-3 or identifier-4, undefined results will occur, even if the identifiers are defined by the same data description entry.


As Dick says, new ust2. You should move space first to your new ust2, each time, as the STRING does not "space fill" and you will get data left-over data from previous invocations of the string.
Back to top
View user's profile Send private message
nightbuzzz

New User


Joined: 04 May 2007
Posts: 21
Location: kuala lumpur

PostPosted: Fri Sep 02, 2011 1:42 pm
Reply with quote

Thnx guys...
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Fri Sep 02, 2011 7:22 pm
Reply with quote

a warning:
if you have
Code:
ws-ust2 pic x(20) value '%asdfgh%            '.

you're column1 like :ws-ust2 will probably not behave as you expect. Because it will only return rows with at least 12 spaces at the end of column1.
you probably want to fill ws-ust2 with '%asdfgh%%%%%%%%%%%%%'
and the easiest way to do that is

Code:
move all '%' to ws-ust2
string ws-ust1 delimited by '  ' into ws-ust2(2:)

or
Code:
string '%' delimited by size
       ws-ust1 delimited by '  '
       '%%%%%%%%%%%%%%%%%%%%' delimited by size
into ws-ust2
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Sep 02, 2011 7:40 pm
Reply with quote

Good catch icon_smile.gif

d
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 2
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
Search our Forums:

Back to Top