Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

sting operations

Former Member
0 Likes
713

how to add extra space for a variable which is having already data in it dynamically...

for ex: if var1 contains 'asfsd' now at runtime i want to increase to increase the length so that some extra space is added at the end with the specified length

for length = 10

my result should b1 var1 = 'asfsd '

so at the last five space is added.

how to achieve this...

6 REPLIES 6
Read only

Former Member
0 Likes
670

Hi,

data : str(10) type c,

str(11) type c.

str = 'hello'.

concatenate str ' ' into str1.

Read only

Former Member
0 Likes
670

Hi Kiran,

U can try using the Shift command

DATA: A1(10) TYPE C VALUE 'ABCDEFGHIJ',

A2 TYPE STRING,

FIVE TYPE I VALUE 5.

A2 = A1.

SHIFT ALPHA1 BY FIVE PLACES.

SHIFT ALPHA2 RIGHT BY 2 PLACES

Now A1 now has the contents 'FGHIJ '

and A2 will have contents ' ABCDEFGHIJ'.

regrads,

Kalyan..

Read only

Former Member
0 Likes
670

hi

u can try this.

len = strlen( var1 ).

while len le 10.
  concatenate var1 ' ' into var1.
add 1 to len.
endwhile.

this will help u in adding any no of spaces at runtime.

Regards

Sumit Agarwal

Read only

Former Member
0 Likes
670

hi Kiran,

do like this.

len = strlen( var1 ).

rem_len = 10 - len.

Do rem_len times.

concatenate var1 SPACE into var1.

rem_len = rem_len = 1.

enddo.

Reward points if useful

Chandra

Read only

0 Likes
670

Hi

concatenation or shift does not give correct result.....

my requirement:::

var1 = 'abcd'.

var2 = 'efgh'.

write var1 var2.... o/p: abcdefgh

now at runtime i want to increase the length of var1 to 8 so that it has to consider the remaining 4 characters as spaces and now this space need to be concatenated and displayed along with data...(normally any extra space wont get displayed- but here i need display of this extra space)

so finally o/p should :::: abcd efgh not abcdefgh

Read only

0 Likes
670

Hi Kiran,

Concatenate the 2 variables in 3 variable of type string using space.

Eg)

Var1 = 'abc'

Var2 = 'def'

Var3 Type String.

Concatenate Var1 Var2 int oVar3 seperated by Sapce.

Write : Var3.

Your o/p will be: abc def.

Reward points if helpful.

Thanks & Regards

Jitendra