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

field length

Former Member
0 Likes
608

I have a data

lv_var1(18) type c.

I have to assign value "LOAN" and "HP" to this variable.

but it should not compress the value means after LOAN it should add 14 spaces and after hp it should add 16 spaces and store the value.

how to do this ?

I have a data

lv_var1(18) type c.

I have to assign value "LOAN" and "HP" to this variable.

but it should not compress the value means after LOAN it should add 14 spaces and after hp it should add 16 spaces and store the value.

how to do this ?

4 REPLIES 4
Read only

Former Member
0 Likes
580

By the nature of the field being type C, and moving character data to it, the field will be left justified as you need.

Read only

Former Member
0 Likes
580

I dont think thats possible only using String Data type you can have variable length variables.

santhosh

Read only

Former Member
0 Likes
580

Hi

lv_var1(4) = 'LOAN'.

or

lv_var1(2) = 'HP'.

here the remaing chararters of variable LV_VAR1 will be blank, now if you don't want to lose these space it depends on where you transfer it.

Max

Read only

Former Member
0 Likes
580

Hi Santosh B,

when u assign it to the variable the left space will be blank only...

may be this code will clear ur doubt...

See below code...


data : lv_var1(18) type c,
      lv_var2(18) type c.

lv_var1+0 = 'LOAN'.

lv_var2+0 = 'AFTER SPACES'.

WRITE : lv_var1 ,lv_var2 .


data : lv_var1(18) type c,
      lv_var2(18) type c,
      lv_var3(10) type c.

lv_var1 = 'LOAN'.

lv_var2 = 'AFTER SPACES'.

lv_var3 = lv_var1. " here from 18 to 10 so it will remove extra spaces...

WRITE : lv_var1 ,lv_var2 ,lv_var3,'a' .

Hope it will solve your problem...

Reward points if useful...

Thanks & Regards

ilesh 24x7