MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Concatenate strings and variables in CLIST

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
pvrajesh31
Beginner


Joined: 10 Aug 2004
Posts: 31
Topics: 11

PostPosted: Wed Jan 31, 2007 9:48 am    Post subject: Concatenate strings and variables in CLIST Reply with quote

Hi ,
I want to concatenate strings and variables using CLIST. REXX is not available in our system. I have following strings and variables

string1 = abc.source(
variable1 = myprog
string2 = )

I want to concatenate all these and form a string
'abc.source(myprog)' .

When i tried to concatenate using below statement

Code:
SET OUTDS = &string1&variable1&string2


I am getting error 'THIS STATEMENT HAS AN EXPRESSION WITH OPERATORS OUT OF SEQUENCE'.

Please suggest me.....

Thanks in advance.
_________________
Rajesh
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Jan 31, 2007 10:01 am    Post subject: Reply with quote

if I remember correctly "operators out of sequence" always came up when I had math symbols -+.)( etc... in the string. I can not remember how to make a string x type in clists but maybe there is a STR(&string1&variable1&string2) function? also, I always used the concatenation symbol || instead, which enabled easier reading.

SET X = &string1 || &variable1 || &string2

if I need a space then " "
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Jan 31, 2007 10:06 am    Post subject: Reply with quote

pvrajesh31,

try this

Code:

SET OUTDS = &string1.&variable1.&string2


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pvrajesh31
Beginner


Joined: 10 Aug 2004
Posts: 31
Topics: 11

PostPosted: Wed Jan 31, 2007 10:51 am    Post subject: Reply with quote

Hi Kolusu,
Sorry . Even now i am getting the same error.

Regards,
_________________
Rajesh
Back to top
View user's profile Send private message
pvrajesh31
Beginner


Joined: 10 Aug 2004
Posts: 31
Topics: 11

PostPosted: Wed Jan 31, 2007 11:09 am    Post subject: Reply with quote

Hi Dick,
Sorry. If i use pipe symbol || , even pipe symbol also is coming in the output.

The output as

OUTDS as ABC.SOURCE || MYPROG || )
_________________
Rajesh
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Wed Jan 31, 2007 11:21 am    Post subject: Reply with quote

This worked for me:

SET OUTDS = &STR(&STRING1&VARIABLE1&STRING2)
Back to top
View user's profile Send private message
pvrajesh31
Beginner


Joined: 10 Aug 2004
Posts: 31
Topics: 11

PostPosted: Wed Jan 31, 2007 1:43 pm    Post subject: Reply with quote

Hi Superk,
This is close to the solution.

The only problem is to form string1, i used command

SET string1 = abc.source(

This itself is giving error as 'THIS STATEMENT HAS AN EXPRESSION WITH OPERATORS OUT OF SEQUENCE'.
If i remove the brace '(' then it is working.

I tried to do in someother way by splitting the variables as below

SET string1 = abc.source
SET string2 = (
SET string3 = )

When i use the command
SET OUTDS = &STR(&string1&string2&variable1&string3)

it went on without error but the output is

OUTDS as abc.sourcemyprog) where left brace is missing. There is some problem with left brace symbol.

i need to get OUTDS as abc.source(myprog)
_________________
Rajesh
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Jan 31, 2007 2:15 pm    Post subject: Reply with quote

try puting the braces in quotes within the &STR function

SET OUTDS = &STR(&STRING1"("&VARIABLE1")")

where &STRING1 contains the DSN
and &VARIABLE1 contains the member name
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
pvrajesh31
Beginner


Joined: 10 Aug 2004
Posts: 31
Topics: 11

PostPosted: Wed Jan 31, 2007 3:12 pm    Post subject: Reply with quote

Hi Dick,
I tried this,
output is abc.source"("myprog")".

But thanks for ur idea. I did a small change in your code. I removed quotes then it worked fine.

I changed it as below

Code:
SET OUTDS = &STR(&STRING1(&VARIABLE1))


the output is abc.source(myprog) which is my requirement.

Thanks to all who gave different kind of suggestions.

Regards,
Rajesh
_________________
Rajesh
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Jan 31, 2007 4:02 pm    Post subject: Reply with quote

thk for the feedback. obviously, my clist skills are rusty. hope i never have to write a clist again. yeah rexx.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Wed Jan 31, 2007 5:59 pm    Post subject: Reply with quote

What do you mean that Rexx is not available? If you are running OS/390 or z/OS then Rexx is available. Are you just not allowed to use it? And if not, then this question is exactly the reason that Rexx should be used for all new development and CLIST should be banned... forever (and erased from the history books, from our memories, and from the collective consciousness). String processing in CLIST is horribly error prone. And while you can use &STR() and SYSSCAN all you want to, there are always ways that your imput data can cause problems. Try Rexx. Argue for it, and fight, fight, fight. It is time to get your shop out of the 1970's.
Back to top
View user's profile Send private message Visit poster's website
advoss
Beginner


Joined: 23 Aug 2005
Posts: 26
Topics: 0

PostPosted: Fri Feb 02, 2007 11:50 am    Post subject: Reply with quote

This works for me
Code:

SET STRING1 = ABC.SOURCE                 
SET RP = )                               
SET LP = &STR((                           
SET VARIABLE = MEMBER                     
SET OUTDSN = &STR(&STRING1&LP&VARIABLE&RP)
WRITE &OUTDSN

_________________
Alan Voss
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group