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 operation with DELIMITED BY ' ' and DELIMITED BY SIZE

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: String operation with DELIMITED BY ' ' and DELIMITED BY SIZE
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

Site Director


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

PostPosted: Fri Sep 02, 2011 10:42 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Fri Sep 02, 2011 1:40 pm    Post subject: Reply to: String operation
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Fri Sep 02, 2011 7:40 pm    Post subject: Reply to: String operation
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    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
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Sort Card to Remove Duplicate records... raj4neo SYNCSORT 2 Wed Jan 25, 2017 4:44 am


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