View previous topic :: View next topic
|
Author |
Message |
Ambili S
Active User
Joined: 06 Sep 2007 Posts: 112 Location: India
|
|
|
|
Hi
I have two variable VAR1 and VAR2 which i need to concatenate or string using STRING.
VAR 1 - is of var length (but max is 20)
VAR2 - is of var length (but max is 30)
VAR3 - is o/p and max length is 30.
VAR1 is input . For e.g let there be to cases where VAR1 - can be " Hello" or " Excellent" ..So length in both cases is diferent . It's 5 for 1st case and 9 for 2nd case.
VAR2 - "Good Work,keep it up"
Now when i string VAR1 and VAR2 , i should get o/p as
"Hello Good work,keep it up" with 1st input. and
"Excellent Good work,keep it up" with 2nd input.
My doubt is how should VAR1 and VAR2 be declared and what should be syntax of STRING to get the desired result as data present in VAR1 and VAR2 keep varyng. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Assuming that var1 & var2 have double spaces only after the data and not between the words....
Code: |
var1 pic x(20)
var2 pic x(30)
var3 pic x(30)
Move whatever to var1
Move whatever-else to var2
Move spaces to var3 (very important)
String var1 delimited by ' ' (two spaces)
' ' delimited by size (single space)
var2 delimited by size
into var3 |
STRING statement |
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
Ambili S, what if var1 and var2 use their maximum lengths provided.In that case it would certainly exceed the output variable var3 length (i.e. 30).
Its better to increase the length of the output variable to 50 as to avoid data truncation.
WTF |
|
Back to top |
|
|
|