View previous topic :: View next topic |
Author |
Message |
pvrajesh31 Beginner
Joined: 10 Aug 2004 Posts: 31 Topics: 11
|
Posted: Wed Jan 31, 2007 9:48 am Post subject: Concatenate strings and variables in CLIST |
|
|
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 |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Wed Jan 31, 2007 10:01 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Wed Jan 31, 2007 10:06 am Post subject: |
|
|
pvrajesh31,
try this
Code: |
SET OUTDS = &string1.&variable1.&string2
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
pvrajesh31 Beginner
Joined: 10 Aug 2004 Posts: 31 Topics: 11
|
Posted: Wed Jan 31, 2007 10:51 am Post subject: |
|
|
Hi Kolusu,
Sorry . Even now i am getting the same error.
Regards, _________________ Rajesh |
|
Back to top |
|
|
pvrajesh31 Beginner
Joined: 10 Aug 2004 Posts: 31 Topics: 11
|
Posted: Wed Jan 31, 2007 11:09 am Post subject: |
|
|
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 |
|
|
superk Advanced
Joined: 19 Dec 2002 Posts: 684 Topics: 5
|
Posted: Wed Jan 31, 2007 11:21 am Post subject: |
|
|
This worked for me:
SET OUTDS = &STR(&STRING1&VARIABLE1&STRING2) |
|
Back to top |
|
|
pvrajesh31 Beginner
Joined: 10 Aug 2004 Posts: 31 Topics: 11
|
Posted: Wed Jan 31, 2007 1:43 pm Post subject: |
|
|
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 |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Wed Jan 31, 2007 2:15 pm Post subject: |
|
|
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 |
|
|
pvrajesh31 Beginner
Joined: 10 Aug 2004 Posts: 31 Topics: 11
|
Posted: Wed Jan 31, 2007 3:12 pm Post subject: |
|
|
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 |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Wed Jan 31, 2007 4:02 pm Post subject: |
|
|
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 |
|
|
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Wed Jan 31, 2007 5:59 pm Post subject: |
|
|
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 |
|
|
advoss Beginner
Joined: 23 Aug 2005 Posts: 26 Topics: 0
|
Posted: Fri Feb 02, 2007 11:50 am Post subject: |
|
|
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 |
|
|
|
|